atomi-ai / canopen-rust

Apache License 2.0
6 stars 1 forks source link

Endianess issue. #8

Open kareled opened 2 weeks ago

kareled commented 2 weeks ago

Hello, as CANopen seems to be using Little-Endian encoding on the network, I would expect library to correctly decode u16/u32 values back from the network. It does not look like this is happening as I see LSB u16 on the transport and then got it in MSB (byte swapped) format. So the only possible way how to see correct values is to perform byte swap in the application. Is that expected or is it a bug? IMHO it looks like a bug to me... Thanks!

kareled commented 2 weeks ago

More info: from network I get frame: Data { len: 4, bytes: [11, 0, 84, 3, ff, ff, ff, ff] } }

the frame contains 2 unsigned16 values. Let's concentrate on the first one:

Value I see those data: vcmd data: [ 0, 11 ]

which of course when converted back u16 is: 0x1100/b1000100000000

but it should be: 0x11/b10001

so IMHO bug somewhere between transport and presentation layers.