Changeset 0280387b4a7b139df25cf2a418e85037ea3d7b1b
- Timestamp:
- 05/15/10 01:04:11 (21 months ago)
- Children:
- 3d477f9e40ceaedf2ee58027d5e0a5c098150f62
- Parents:
- 811533e58cd3e57fc04f2e7809d3f6ddd6198a82
- git-committer:
- Luper Rouch <luper.rouch@…> (05/15/10 01:04:11)
- Location:
- pompilop/pompilop
- Files:
-
- 3 edited
-
bin/pompicontrol.py (modified) (1 diff)
-
serial/__init__.py (modified) (3 diffs)
-
tests/test_serial.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pompilop/pompilop/bin/pompicontrol.py
r811533e r0280387 28 28 29 29 command, data = args 30 command_obj = Command.from_strings(command, options. input, options.channel,31 data, aux=options.aux)30 command_obj = Command.from_strings(command, options.channel, data, 31 aux=options.aux, input=options.input) 32 32 if options.debug: 33 33 print "Sending command to %s:" % options.dev -
pompilop/pompilop/serial/__init__.py
r811533e r0280387 89 89 AUX_MAX = 32 90 90 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): 92 92 self.command = command 93 93 if device < 0 or device >= self.DEVICES_MAX: … … 121 121 ret.append(CHANNEL_HEADER) 122 122 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)) 123 127 # Data bytes 124 128 dumped_data = base96(self.data) … … 141 145 return "\x20" 142 146 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 148 153 return "".join(reversed(bytes)) 149 154 -
pompilop/pompilop/tests/test_serial.py
r9d933f3 r0280387 1 1 from nose.tools import assert_equal 2 from pompilop.serial import checksum, format_commands, Command 2 from pompilop.serial import checksum, format_commands, Command, base96 3 3 4 4 … … 17 17 def test_format(): 18 18 data = [ 19 (Command(Command.MUTE, False, 2, 1),19 (Command(Command.MUTE, 2, 1, input=False), 20 20 "\x01\x57\x7F\x03\x4D\x55\x54\x30\x08\x20\x09\x21\x0A" 21 21 "\x22\x10\x21\x1F\x2E\x02"), 22 (Command(Command.EQ_FREQUENCY, True, 3, aux=5),22 (Command(Command.EQ_FREQUENCY, 3, 1, aux=5, input=True), 23 23 "\x01\x57\x7F\x03\x45\x51\x46\x30\x08\x20\x09\x20\x0A" 24 24 "\x23\x0B\x25\x10\x21\x1F\x44\x02"), … … 26 26 for cmd, expected in data: 27 27 assert_equal(format_commands([cmd]), expected) 28 29 30 def test_base96(): 31 assert_equal(base96(0), "\x20") 32 assert_equal(base96(1), "\x21") 33 assert_equal(base96(0x60), "\x7f") 34 assert_equal(base96(0x61), "\x21\x7f") 35
Note: See TracChangeset
for help on using the changeset viewer.
