xPC target ASCII conversion
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi!
I am trying to do some NMEA 0813 parsing in Simulink using a real time target xPC device. I am communicating with a Trimble GPS module using serial connection and receiving NMEA coded information. Now i need to decode the information using ASCII decode blocks from the xPC target library, but i cant get this to work.
The NMEA coded information comes as a ASCII coded uint8 array, lets say that i was to receive the $GPGGA information from the gps with the following content
172814.0,3723.46587704,N,12202.26957864,W,2,6,1.2,18.893,M,-25.669,M,2.0,0031*
in the ASCII decode block i specify the following format string
%f,%f,%C,%f,%C,%d,%d,%f,%f,%C,%f,%C,%f,%d*
the output is then ok until i reach the second letter "W", then everything starts to behave strange. The number 2 which is decoded with format %d is interpreted as "W" as well. And the bytes following are now completely misinterpreted. I have encountered similar behavior almost every time i use %c or %C format string. Does anybody have any suggestions of what to do?
댓글 수: 0
답변 (3개)
Gordon Weast
2012년 10월 31일
There are two different ASCII decode blocks available for you.
The original one does it's own parsing of the format string. That one has some trouble with the %c format element.
The newer one, 'V2 Ascii Decode' uses TLC to construct a call to the built in sscanf function. That one handles %c much better. However, you can't use it in simulation on the host to test it out. You can use accelerator mode or GRT on the host to test before you go to the target since they both do code generation.
Gordon Weast xPC Target Development
댓글 수: 0
Gianpiero Buzzo
2013년 6월 11일
Hi everyone.
Gordon I'm using your .mdl file, NMEADecode, you sent it to me some days ago, for reading an NMEA string on serial port.
It works fine with an nmea coded information like that's one used by Carl-Johan Elm.
Now I'm trying to customize the code for decoding a different received string, using Hyperterminal as sender.
For example:
TEST,1,2,3.5,A,*45.
So I've changed only the header in the FIFO blocks, in this case it output just one port, and finally setted up the ASCII Decode V2, in this way:
'TEST,%d,%d,%f,%c,*%2d'
Unlikely, it doesn't work fine. It looks like nothing received on the serial port, because after running the simulation on the target and sending data by hyperterminal, no one data change on the target scope.
How can I do? Why is the count data, first data output from the ascii v2 block, always -1?
Thanks a lot.
댓글 수: 0
rago
2014년 7월 12일
hi everyone i am facing same problem can you help me in parsing this nmea message ..
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Target Computer Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!