TCP socket : parsing NMEA string
I'm trying out the server TCP example to connect to a MOXA Nport device which provides me a serial string (NMEA) over TCP.
Is there an easy way to parse these bytes which I receive now in the buffer (ASCII).
I did already a work around in Node-red which is working fine but I think it should be possible by using the REXLANG FB.
Any tips and or examples?
thx & grtz,
FYI : this is the string on one of the outputs of the REXLANG FB now.
This data I would like to parse inside the REXLANG FB and assign it to the outputs of the FB.
cechurat last edited by
there are no special function blocks to parse comma separated string. However I can imagine simple loop written in REXLANG FB which will do following:
- find position of "," - long strfind(str,substr)
- create substring from beginning to the position of "," and assign it to the i-th output - string strsub(str,idx,len)
- create substring of original string starting at position of "," - string strsub(str,idx,len)
- repeat until you reach the end of the original string
If you know exact data frame you can also convert the values.
If need any help, let me know.
Thanks for the info .... I'll give it a try one of these days. I'll post the solution... at least if I am able to solve it.....