openiolink / io-link-master-shield-hat-sw

Software for the IO-Link Master Shield/Hat for Arduino and Raspberry Pi
Apache License 2.0
25 stars 6 forks source link

byte order #42

Open gammeter opened 3 years ago

gammeter commented 3 years ago

In the output of the test_board software (at least for Raspberry Pi) the "VendorID" and "DeviceID" are printed in some kind of reverse order. It is an endianness problem (big endian vs little endian).
Here is an example: The output says:

VendorID:             0x7803
deviceID:             0x70804

In this case, the real vendor id is 0x0378 and the real device id is 0x040807.

n.b. 0x0378 = 888 = Balluff AG
0x040807 is the device ID of the BUS0004P

gammeter commented 3 years ago

The problem is exactly the same on the Arduino platform too.

SecurityCheck commented 3 years ago

This also affects process data. The Max14819 chip sends all data in litte-endian format.

gammeter commented 3 years ago

OK...
The IO-Link Specification says on page 76:

All the multi-octet data types shall be transmitted as a big-endian sequence, i.e. the most significant octet (MSO) shall be sent first, followed by less significant octets in descending order, with the least significant octet (LSO) being sent last, as shown in Figure 2.

So we will have to take care of a conversion in the software!