Changeset 3d477f9e40ceaedf2ee58027d5e0a5c098150f62


Ignore:
Timestamp:
05/19/10 14:57:48 (2 years ago)
Author:
Luper Rouch <luper.rouch@…>
Children:
eb367573c9a8c777f3776814ffd2d795e688b2ef
Parents:
0280387b4a7b139df25cf2a418e85037ea3d7b1b, 0fb7200268603a3392982b000d3f692d60c73e8e
git-committer:
Luper Rouch <luper.rouch@…> (05/19/10 14:57:48)
Message:

Merge branch 'master' of luper.fr:/var/git/projects

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pyflu/pyflu/jsonalize.py

    r7bea8cb r0fb7200  
    220220            # Looks to be a serialized class 
    221221            cls = get_class(state["__class__"]) 
    222             ret = cls(*state["__args__"], **state["__kwargs__"]) 
     222            # Force kwargs keys to be of str type 
     223            kwargs = {} 
     224            for key, value in state["__kwargs__"].items(): 
     225                kwargs[str(key)] = value 
     226            ret = cls(*state["__args__"], **kwargs) 
    223227        else: 
    224228            # A normal dict 
  • pompilop/pompilop/bin/pompicontrol.py

    r811533e r0280387  
    2828 
    2929command, data = args 
    30 command_obj = Command.from_strings(command, options.input, options.channel,  
    31         data, aux=options.aux) 
     30command_obj = Command.from_strings(command, options.channel, data, 
     31        aux=options.aux, input=options.input) 
    3232if options.debug: 
    3333    print "Sending command to %s:" % options.dev 
  • 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 
  • pompilop/pompilop/tests/test_serial.py

    r9d933f3 r0280387  
    11from nose.tools import assert_equal 
    2 from pompilop.serial import checksum, format_commands, Command 
     2from pompilop.serial import checksum, format_commands, Command, base96 
    33 
    44 
     
    1717def test_format(): 
    1818    data = [ 
    19             (Command(Command.MUTE, False, 2, 1),  
     19            (Command(Command.MUTE, 2, 1, input=False),  
    2020                "\x01\x57\x7F\x03\x4D\x55\x54\x30\x08\x20\x09\x21\x0A" 
    2121                "\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), 
    2323                "\x01\x57\x7F\x03\x45\x51\x46\x30\x08\x20\x09\x20\x0A" 
    2424                "\x23\x0B\x25\x10\x21\x1F\x44\x02"), 
     
    2626    for cmd, expected in data: 
    2727        assert_equal(format_commands([cmd]), expected) 
     28 
     29 
     30def 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.