Parser NMEA 2000 (CAN) on Simulink

Hello,
I would like to parse NMEA 2000 data (CAN) via Simulink in order to generate code via Simulink Coder for an embbed system. But I can't figure out how to convert the hex form into ASCII format then float. Here the issue :
1 : I receive my data via UDP sockets with a UDP receive block. The data look like 88 09 f1 0d 10 45 28 45 (8 bytes) in a string format
2 : Extraction of the interest bytes : example : 0d 10
3 : Then convert into ASCII format : 0d 10 => 13 16 (uint8)
I faced some issue converting the data input (string udp sockets) in a final double format. Strings aren't easy to manipulate via Simulink.
I made a parser on Matlab : NMEA_decode(Message) but the function uses string function (str2num, hex2str) which aren't supported by Simulink and Simulink Coder.
Is there a Simulink toolbox (block NMEA decode) or did someone find a solution to extract the data ?
Thank you by advance

댓글 수: 1

Kenny Nona
Kenny Nona 2023년 2월 9일
Hi,
I was reading NMEA2000 via CAN. The code uses the CAN read for realtime and then you need to make sure that you capture all messages (first byte contains the index). Then, each of the captured messages is send to a matlab function block where all these messages are pasted one after another, in the correct order.
Once you have the full message, then you just decode it (selecting desired bits & converting them into interpretable numbers using cast and typecast).
Regards,

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2022년 10월 11일

댓글:

2023년 2월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by