How to use "BigEndian" byte order when using the pack and unpack functions in MATLAB R2023a?
12 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2023 年 8 月 16 日
回答済み: MathWorks Support Team
2023 年 8 月 17 日
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'
採用された回答
MathWorks Support Team
2023 年 8 月 16 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Windows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!