Ignore:
Timestamp:
05/15/10 01:04:11 (2 years ago)
Author:
Luper Rouch <luper.rouch@…>
Children:
3d477f9e40ceaedf2ee58027d5e0a5c098150f62
Parents:
811533e58cd3e57fc04f2e7809d3f6ddd6198a82
git-committer:
Luper Rouch <luper.rouch@…> (05/15/10 01:04:11)
Message:

pompilop:

  • fixed base96() (needs testing on real hardware)
  • 'input' is now a keyword argument of Command
  • more tests
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pompilop/pompilop/serial/__init__.py

    r811533e r0280387  
    8989    AUX_MAX = 32 
    9090 
    91     def __init__(self, command, input, channel, data, aux=None, device=0): 
     91    def __init__(self, command, channel, data, aux=None, device=0, input=True): 
    9292        self.command = command 
    9393        if device < 0 or device >= self.DEVICES_MAX: 
     
    121121        ret.append(CHANNEL_HEADER) 
    122122        ret.append(chr(CHANNEL_VALUE_BASE + self.channel)) 
     123        # Aux bytes 
     124        if self.aux is not None: 
     125            ret.append(AUX_HEADER) 
     126            ret.append(chr(AUX_VALUE_BASE + self.aux)) 
    123127        # Data bytes 
    124128        dumped_data = base96(self.data) 
     
    141145        return "\x20" 
    142146    bytes = [] 
    143     while value: 
    144         byte = value & 0x5f 
    145         bytes.append(chr(byte + 0x20)) 
    146         value >>= 5 
    147     print bytes 
     147    while value > 0: 
     148        if value >= 0x60: 
     149            bytes.append("\x7f") 
     150        else: 
     151            bytes.append(chr(value + 0x20)) 
     152        value -= 0x60 
    148153    return "".join(reversed(bytes)) 
    149154 
Note: See TracChangeset for help on using the changeset viewer.