Parser NMEA 2000 (CAN) on Simulink
Afficher commentaires plus anciens
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 commentaire
Kenny Nona
le 9 Fév 2023
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,
Réponses (0)
Catégories
En savoir plus sur Simulink Coder dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!