Problem with union tag size between libuavcan and pyuavcan

18 views
Skip to first unread message

Juha Kuikka

unread,
May 18, 2018, 9:45:01 PM5/18/18
to UAVCAN
Hello,

I am sending messages between an embedded platform using libuavcan and a PC running pyuavcan.

More specifically I have a request/response that looks (paraphrasing) like this:

@union
int16 a
int16 b
int16 c
int16 d
--
@union
int16 a
int16 b
int16 c
int16 d

If I send a response of "a", with value of -1, it comes out as:

b0001 1111
b1111 1111
b1110 0000

The tag is 3 bits long, followed by 16 bits of ones for the -1, followed by padding (I have disregarded the link layer footer byte).

Looking at the generated message definition:

        typedef ::uavcan::IntegerSpec< ::uavcan::IntegerBitLen< 4 >::Result,

                                       ::uavcan::SignednessUnsigned, ::uavcan::CastModeTruncate > TagType;


The :::uavcan::IntegerBitLen< 4 >::Result comes to 3, which makes the IntegerSpec to be 3 bits long. This seems wrong as for four union members I would expect 2 bits to be sufficient. And it looks like the python side implementation agrees with that since it gets the data mangled.

Manually changing the 4 into 3 does work around the issue but that's not really a fix.

The data_type_template.tmpl could be changed have a -1 but that would break @union with only one member.

Thoughts?

 - Juha


Pavel Kirienko

unread,
May 19, 2018, 10:59:01 AM5/19/18
to Juha Kuikka, UAVCAN
Thank you for the report! Indeed, it is a bug; fix submitted, please review: https://github.com/UAVCAN/libuavcan/pull/128

Pavel.

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+unsubscribe@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/uavcan/4df274d9-1822-41e1-bd95-03f1ba30d007%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages