OpenCyphal / pycyphal

Python implementation of the Cyphal protocol stack.
https://pycyphal.readthedocs.io/
MIT License
119 stars 106 forks source link

Incorrect decoding of non-tao array[<=128]? #28

Closed NerdyProjects closed 6 years ago

NerdyProjects commented 6 years ago

I am developing a small application based on libcanard and am using the GuiTool for configuration.

As I wanted to implement param.GetSet for string parameters, I noticed that Value does not get decoded properly for string_value although I implemented it to my understanding.

Debugging showed that in transport.py, around line 410, only 7 bits were used for the array size. I fixed locally by calculating count_width as: count_width = int(math.ceil(math.log(self._type.max_size + 1, 2))) or 1

To my understanding, even the DSDL for value describes this prefix length field as 8 bits.

As I am getting GetSet requests with garbage data when trying to set string parameters using GuiTool, I am now questioning the stability of this library/toolkit and thought about opening this issue before submitting a pull request for this bug. Did I just trigger a codepath that has never been used before !? Nobody using string parameters? :D

NerdyProjects commented 6 years ago

Sorry, this was already fixed in bcd73a63864a7c58934fd48441daa8d243cfdfa9. I wonder why I did not get the most recent version through pip...