[Python] Bug in message decoding
I have been testing CSCP between Python (master branch) and C++ and there are some mismatches. To test it yourself, you can compile the C++ version and then run
./build/cxx/tools/dummy_controller tcp://localhost:23999
(if you need further help to build @joel.ekstroem @hanno.perrey please ping me on mattermost)
Then, send a command like get_name
. The decoding fails since the Python code using msgpack.unpackb
. Unfortunately, this is not the correct command, since it assumes that the data is stored in a msgpack list. Note also since no error message is returned, the ZeroMQ state of the controller is broken.
I think the correct way according to protocol is the unpacker, see e.g. here for MessageHeader.decode
:
unpacker = msgpack.Unpacker()
unpacker.feed(header)
protocol = unpacker.unpack()
host = unpacker.unpack()
timestamp = unpacker.unpack()
meta = unpacker.unpack()
Doing this change, I still get an error. Namely self.protocol.value
is CDTP
, even though it should be CSCP
. You can further see this by adding print(self.msghead.protocol)
in CommandTransmitter.get_message
. It is however a simple typo in protocol.py
.
Fixing those and the message verb decoding (using the unpacker as above), I managed to receive the message with the Python satellite.
After similar adjustments to encode the return message I managed to cause transitions in the Python Satellite and query the state correctly, which I think is really nice