필터 지우기
필터 지우기

Convert CAN Message data - array of uint8 to double:

조회 수: 11 (최근 30일)
mlaudu
mlaudu 2020년 12월 24일
댓글: mlaudu 2020년 12월 29일
Hi,
I have an IO611 CAN Read block in my Simulink model that reads messages from a single CAN channel. The CAN messages originate from several sources each message with a unique ID. I see that I can extract the message ID and data payload for each message directly from the CAN Read block by using the 'RAW' data message type. The data paylod is however in the form of a uint8(8) array. To get the equivalent double value is it enough to use a 'double' conversion block or do I have to do some other elaborate conversion? Thanks for any insight.

답변 (1개)

Madhav Thakker
Madhav Thakker 2020년 12월 29일
편집: Madhav Thakker 2020년 12월 29일
Hi Mlaudu,
You can use data conversion block that takes as input uint8 array and returns a double array with same dimension.
Hope this helps.
  댓글 수: 3
Walter Roberson
Walter Roberson 2020년 12월 29일
MATLAB function block that takes in the uint8 array and typecast() it to double.
Just watch out for the byte order. typecast() will assume the byte order is the same as the system being executed on, which would be "little endian" .
mlaudu
mlaudu 2020년 12월 29일
This idea works. Use a MATLAB function block and typecast the 8-byte array to double. Thank you.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 String에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by