- assert str(Packet(1, 7, 7)) == '\xFF'
- assert str(Packet(0, 0, 0)) == '\x00'
- assert str(Packet(1, 1, 1)) == '\x93'
- assert str(Packet(TYPE_SET, VAR_MATRIX, 2)) == '\x84'
- assert str(Packet(TYPE_GET, 4, 0)) == 'A'
- assert str(Packet(TYPE_GET, 4, 0, 'hola')) == 'Ahola'
- p = Packet(TYPE_GET, 4, 0, 'hola')
+ # GET
+ assert str(Packet(TYPE_GET, VAR_OFF, 0)) == chr(0x00)
+ assert str(Packet(TYPE_GET, VAR_OFF, 7)) == chr(0x07)
+ assert str(Packet(TYPE_GET, VAR_MATRIX, 1)) == chr(0x09)
+ assert str(Packet(TYPE_GET, VAR_MATRIX, 6)) == chr(0x0E)
+ assert str(Packet(TYPE_GET, VAR_PAUSE, 2)) == chr(0x12)
+ assert str(Packet(TYPE_GET, VAR_PAUSE, 5)) == chr(0x15)
+ assert str(Packet(TYPE_GET, VAR_DELAY, 3)) == chr(0x1B)
+ assert str(Packet(TYPE_GET, VAR_DELAY, 4)) == chr(0x1C)
+ assert str(Packet(TYPE_GET, VAR_DELAY, 7, 'hola')) == chr(0x1F) + 'hola'
+ p = Packet(TYPE_GET, VAR_MATRIX, 0, 'hola')
+ assert Packet(str(p)) == p
+ # SET
+ assert str(Packet(TYPE_SET, VAR_OFF, 0)) == chr(0x80)
+ assert str(Packet(TYPE_SET, VAR_OFF, 7)) == chr(0x87)
+ assert str(Packet(TYPE_SET, VAR_MATRIX, 1)) == chr(0x89)
+ assert str(Packet(TYPE_SET, VAR_MATRIX, 6)) == chr(0x8E)
+ assert str(Packet(TYPE_SET, VAR_PAUSE, 2)) == chr(0x92)
+ assert str(Packet(TYPE_SET, VAR_PAUSE, 5)) == chr(0x95)
+ assert str(Packet(TYPE_SET, VAR_DELAY, 3)) == chr(0x9B)
+ assert str(Packet(TYPE_SET, VAR_DELAY, 4)) == chr(0x9C)
+ assert str(Packet(TYPE_SET, VAR_DELAY, 7, 'hola')) == chr(0x9F) + 'hola'
+ p = Packet(TYPE_SET, VAR_MATRIX, 0, 'hola')