KimBP / AIS

An Arduino library able to decode AIS messages
Other
30 stars 9 forks source link

Problems with message types 19 & 24 #6

Closed RossP1956 closed 5 years ago

RossP1956 commented 5 years ago

I'm using the decode AIS library successfully on the Lolin & Wemos ESP8266-12 platform and works well to extract data values for message types 1, 5 & 18. However type 24 (valid payload starting with H...) causes the mcu to crash when trying to poll the mmsi, shipname ...etc, maybe because it handles it like a type 5 message and tries to read past the message end. When polling double message type 19 (valid payload first message starting with C...) it returns all zero values. Single message Type 18 (valid message starting with B...) has the same non extended format as type 19 and it returns all values well.

KimBP commented 5 years ago

Hi Ross Basically I think you refer two unrelated issues. The last one first: AIS message 19 is not supported at the moment, but it would be rather simple to do it: Add an enum to enum Nmea0183AisMessages in AIS.h. Add a struct like this (message 18): const struct AIS::AisParamPosPair AIS::AisMsgCsPosReportClassB and update AIS::AisMsgParams accordingly. I'd be happy to add a patch if you make a pull request. Alternatively I can try implementing it. Can you send me a 'raw' message 19 to test with?

Your first issue regarding message 24 crashing your platform I can't explain. I've just checked that both mmsi and shipname are correctly configured (regarding starting bits and length). Can you provide me with sample message and your code? Is it possible for you to single step through your code to see what's wrong?

RossP1956 commented 5 years ago

KimThanks for your quick reply.Note in the library suggests that message type 19 is supported.Here's a valid sample double message type 19 below from the Miratec website. The leading payload character is C when I changed it to B,  only then did your library respond well but as a type 18.Message 19 - Extended Class B equipment position report!AIVDM,2,1,0,B,C8u:8C@t7@TnGCKfm6Poe6N:Va0L2J;06HV50JV?SjBPL3,028 !AIVDM,2,2,0,B,11RP,017Parm#  Parameter  Value  Description  01Message ID1902Repeat indicator0No repeat (default)03User ID (MMSI)60100001304Spare1505SOG2.906Position accuracy0Low (> 10 m) (default)07Longitude3211.9718'E08Latitude2950.2488'S09COG8910True heading9011Time stamp1212Spare1513NameTEST NAME CLSB MSG1914Type of ship & cargo37Pleasure Craft15Ship dimensionsA=7,B=6,C=2,D=316Type of EPFD1GPS17RAIM-flag0RAIM not in use (default)18DTE (availability)1DTE not available (default)19Mode flag0Station operating in autonomous and continuous mode (default)20Spare0Also from the Miratec website, here's a couple of type 24 messagesStrange that I do not see shipname included.Message 24 - Class B/CS Static Data Report - Part A!AIVDO,1,1,,B,H1c2;qA@PU>0U>060<h5=>0:1Dp,27DParm#  Parameter  Value  Description  01Message ID2402Repeat indicator0No repeat (default)03User ID (MMSI)11223344504Message part number00 = Part A05NameTHIS IS A CLASS B UNMessage 24 - Class B/CS Static Data Report - Part B!AIVDO,1,1,,B,H1c2;qDTijklmno31<<C970`43<1,028Parm#  Parameter  Value  Description  01Message ID2402Repeat indicator0No repeat (default)03User ID (MMSI)11223344504Message part number11 = Part B05Type of ship & cargo36Sailing06Vendor ID123456707Call signCALLSIG08Ship dimensionsA=5,B=4,C=3,D=1209Spare1ThanksRossOn Mar 24, 2019 3:50 PM, KimBP notifications@github.com wrote:Hi Ross Basically I think you refer two unrelated issues. The last one first: AIS message 19 is not supported at the moment, but it would be rather simple to do it: Add an enum to enum Nmea0183AisMessages in AIS.h. Add a struct like this (message 18): const struct AIS::AisParamPosPair AIS::AisMsgCsPosReportClassB and update AIS::AisMsgParams accordingly. I'd be happy to add a patch if you make a pull request. Alternatively I can try implementing it. Can you send me a 'raw' message 19 to test with? Your first issue regarding message 24 crashing your platform I can't explain. I've just checked that both mmsi and shipname are correctly configured (regarding starting bits and length). Can you provide me with sample message and your code? Is it possible for you to single step through your code to see what's wrong?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

KimBP commented 5 years ago

Hi Ross I was wrong. kimphg send a commit with support for message 19 more than a year ago. Unfortunately my local repository wasn't updated. And unfortunately I've tested it. I've now realized it has a bug Hopefully I've fixed it now. I've also extended the support so all parameters in message 19 are now supported. The bug by the way would cause the system to parse a message 19 as a message 24, so most parameters you request wont exist or would be locatd in wrong positions and would then be wrong. Also the bug caused an index out of bound when handling type 24 messages, so it is very probably that your crash problem is now also fixed.

I've pushed my change to a branch called msg19_support. Will you please test and give feedback

RossP1956 commented 5 years ago

KimBP Many thanks for all your quick efforts in correcting the AIS library. Message types 24 and 19 now respond very well without any problems.

Please let me know if you would like further tests but so far I can confirm functionality for the following : Message Type 24 MMSI, Message Type, Ship Type, Dimensions, CallSign Message Type 19 MMSI, Message Type, Latitude, Longitude, SOG, COG 

Regards RossP

 

---------- Original Message ---------- From: KimBP notifications@github.com Date: March 26, 2019 at 4:45 PM

Hi Ross I was wrong. kimphg send a commit with support for message 19 more than a year ago. Unfortunately my local repository wasn't updated. And unfortunately I've tested it. I've now realized it has a bug Hopefully I've fixed it now. I've also extended the support so all parameters in message 19 are now supported. The bug by the way would cause the system to parse a message 19 as a message 24, so most parameters you request wont exist or would be locatd in wrong positions and would then be wrong. Also the bug caused an index out of bound when handling type 24 messages, so it is very probably that your crash problem is now also fixed. I've pushed my change to a branch called msg19_support. Will you please test and give feedback —You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

 

KimBP commented 5 years ago

It's fine for me. Thanks for highlighting the problem. I'll close this issue and merge the fix to master