How to use "BigEndian" byte order when using the pack and unpack functions in MATLAB R2023a?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 16 Aug. 2023
Beantwortet: MathWorks Support Team
am 17 Aug. 2023
I am trying to pack and unpack a CAN message using MATLAB R2023a while interfacing with one of my products. However, when I try to pack/ unpack my CAN frames that are in Big Endian format, I get the error shown below:
Invalid combination of start bit, signal size, and byte order.
This issue can be reproduced by the code given below:
message = canMessage(500,false,8);
pack(message,int16(1000),0,16,'BigEndian')
value = unpack(message,0,16,'BigEndian','int16'
Akzeptierte Antwort
MathWorks Support Team
am 16 Aug. 2023
The start bit and the byte order are not independent. In this example, the start bit should be 16 when Big Endian is used. Big Endian byte order is counted from the Least Significant Bit to the Lowest Address. So for Big Endian, an example code snippet for packing and unpacking data is as follows:
message = canMessage(500,false,8);
pack(message,int16(1000),16,16,'BigEndian')
value = unpack(message,16,16,'BigEndian','int16')
For more information on how "startbit" and "byteorder" are related to each other, please check the "Signals" section in the link below:
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Windows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!