-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling of variable length strings, especially in JSON and XML descriptions #92
Comments
Can you upload some raw PGN strings, in a format that analyzer understands? There are (at least) four ways of representing strings in N2K, so with the 'have never seen' definitions I had to guess, and I guess I guessed wrong here :-) |
Have you ever checked my NMEA Simulator (http://www.kave.fi/Apps/NMEA-Simulator/NMEA-Simulator.7z - unfortunately only Windows version available). It sends all data to selected port and also configuration information (126998) in Actisense format. I normally test and play with simulator either by null modem cable (com0com driver or physical) or through real N2k bus by using my NMEA 2000 library sample ActisenseSender. |
I have actually wondered how many designer they have needed to create mesh like N2k. But could you point me other ways for strings. I know only these two with fixed field like on product information (126996) and variable field on some others like 126998 and 129802. |
The CANBoat analyzer has:
The RES_STRINGLZ variation is used by Fusion for the old company specific entertainment (mainly audio) PGNs. The RES_STRINGLAU variation is used by the new N2K PGNs since 2015 for DSC and entertainment. My CANBoat analyzer doesn't yet properly handle the UTF16 content variation. (Why in the world you would choose UTF16 instead of UTF8 when coming up with this in 2014-2015 is really beyond me, but okay.) |
Maybe 126998 and 129802 uses RES_STRINGLAU, since it has length byte and then 0x01, which meaning I have not understood. So could 0x01 mean ASCII. What would be the value for UNICODE 0x02? You seem to have length for RES_STRINGLAU field often 2 ( BYTES(2) ). Do you still handle length of whole message right by checking string length from first byte? In 129041 it seem to have length 34, why? |
Yes, when the length is up to 255 bytes I generally coded the minimal (no value = 2 bytes). The analyzer will consume the correct # of bytes from the PGN, the field length for these fields is only really used for 'description' use. In 12041 the source is not N2K directly but the radio format for AIS, so the length will be less, and I coded the maximum length. I agree that this is confusing. Maybe I should set the length data to 255 for the others. |
Note that for RES_STRINGLAU the length field contains the length including the length and type fields, so an empty string is |
That is how it is on PGN 126998 and 129802. So definition for PGN 126998 should be: |
Could length be 0 ( BYTES(0) ) to inform that it is unknown? |
I'd rather encode the maximum length, but I don't know what the maximum is. |
It is limited to 70 as far as I know. But if you use max. length, then handler has to allways also check the type, when calculating the length. Also the size on the pgn struct should be fixed somehow. As shortest it can be 6 and longest 216. |
PGN 129802 covers AIS message 14, "Safety Related Broadcast Message". This message can have 1 - 161 characters of text. I.e. as mentioned it is of variable length, at least in the ais message. But PGN 129801 is marked as complete. This pgn covers AIS message 12, "AIS Addressed Safety Related Message". This message also has a variable length text field, but in this case 1-156 characters. The pgn has a bit length of 2040. Now, the reason for 156 in stead of 161 characters in message 12 is to keep it within 5 slots, the same as message 14, both having a maximum length of 1008 bits (a char occupies 6 bits in ais messages, not 8). To the best of my understanding the safety related text fields are identical in message 12 and 14, except for maximum length. It seems plausible that the same should hold for PGN 129801 and PGN 129802. |
From the looks of this trace for PGN 126998 the sequence 2021-01-30-20:43:21.684,6,126998,1,255,8,00,50,02,00,02,00,4c,00 The above decodes to:
With this detail, are you able to update the handling of PGN 126998 and remove the unhanded UNICODE error generation message? |
Thanks, this is exactly the detail I needed. |
Fixed in master as merged #57 |
Definition for 126998 is wrong. It has only fields:
1 Installation Description, Field 1
2 Installation Description, Field 2
3 Manufacturer Information, Field 3
All fields are variable length strings so that there is:
<0x01>, where len is length()+2. So this PGN message can be:
<0x02><0x01><0x03><0x01><"C"><0x05><0x01><"CAT">
Also on PGN 129802 field 7 "Safety Related Text" is constructed as above - not fixed length field. And possibly on other PGNs containing text data.
The text was updated successfully, but these errors were encountered: