KimBP / AIS

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

Incorrect Longitude #1

Closed mscory closed 7 years ago

mscory commented 7 years ago

Hello,

I'm trying to use your library on a Arduino Uno Wifi. In your example, longitude is always zero. Integrating the code in the loop routine of my program: the first time longitude is zero, then it seems that part of the memory is corrupted.

Could you help me ? (ms.adve@gmail.com) Thanks

KimBP commented 7 years ago

I can try. I've had a short look at it a few days ago. I observe the same as you with my Arduino Uno.

I tried replacing the Get of COG, Latitude and Longitude with multiple get of SOG. This eventually also generates wrong data. The problem is that msgType (in class AIS) gets corrupted.

I've also tried changing order of the different gets. Still it is around get number 4 (or actually when exiting from get number 3) msgType is lost.

My best idea right now is that we experience a stack overflow. I'll try to move the different gets into separate functions to see if that'll make it better.

I've now my self moved away from Arduino and into STM32. At this platform I haven't experienced any problems yet. But still in development so I might just not have seen it yet.

I'll see if I can get a few more hours to look into your problem.

KimBP commented 7 years ago

Just a short wrap up. Just found proof for an error in my code. Probably in getdata(). Still have to solve it

mscory commented 7 years ago

Thanks so much. In the meantime I wrote myself a routine to decypher AIS messages(see in the attachment). Simpler, smaller but probably less efficient than yours. That part is finished, the remaining isn't and I need to be on my boat to test it.

Kind regards Michel

Le 23 févr. 2017 8:01 PM, "KimBP" notifications@github.com a écrit :

I can try. I've had a short look at it a few days ago. I observe the same as you with my Arduino Uno.

I tried replacing the Get of COG, Latitude and Longitude with multiple get of SOG. This eventually also generates wrong data. The problem is that msgType (in class AIS) gets corrupted.

I've also tried changing order of the different gets. Still it is around get number 4 (or actually when exiting from get number 3) msgType is lost.

My best idea right now is that we experience a stack overflow. I'll try to move the different gets into separate functions to see if that'll make it better.

I've now my self moved away from Arduino and into STM32. At this platform I haven't experienced any problems yet. But still in development so I might just not have seen it yet.

I'll see if I can get a few more hours to look into your problem.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/KimBP/AIS/issues/1#issuecomment-282087122, or mute the thread https://github.com/notifications/unsubscribe-auth/ALMh7HMffYPJLog4pdrrLs_CXuZvKT6Cks5rfdeBgaJpZM4MC9OJ .

KimBP commented 7 years ago

Hi Michel. I've just pushed a fix for my AIS library. I cleared one byte too much. Thanks for revealing the problem. Eventually it will hit me also at the STM32 platform I'm now using. Where do I find your attachment? My next test will also be at my boat. Waiting for warmer weather

mscory commented 7 years ago

Hello Kim,

Sorry I'm not used with Github. Please be indulgent with my code, I rarely used C in my career. Just for info: arguments 3 and 4 are the location of the LSB (word nr and bit nr). I would be happy to feed the application from the USB. I suppose it is possible to do that using a FDTI but would it be possible using the USB plug on the board ? and then how to reload an application ?

Thanks Kind regards

Michel michel.scory@gmail.com

AIS_V4.txt

KimBP commented 7 years ago

I somehow like your approach for picking out the data directly from the 6bits characters. I found it a bit difficult to understand exactly the meaning of arg 3 and 4 even though you mentioned them. You could have calculated them from start bit and bit length: nbWord6 = (startbit + len - 1)/6; nbBit6 = (6 - ((startbit + len)%6) %6); (I think) Your current implementations isn't really generic - you can't e.g. extract e.g. vesselname (len=120bits) but if it just for providing data for your alarm function it really doesn't matter. I don't know the UniWifi so can't really help you with your power issues

Good luck with your live testing.

mscory commented 7 years ago

Thank you Kim: I was too lazy for the formula ;-))

It's not a power issue, my AIS device is able to send GPS and AIS messages using its USB plug. So I'd like to connect the AIS USB directly to the Arduino USB but it's probably not possible.

vesselname: I'm surprised. Currently I'm just processing AIS stream coded in a single NMEA message, that's the only limitation. To be more generic it would be necessary to merge all the AIS streams. I will do that on my boat. It will be far more easy working with a real input.

Michel

2017-02-25 18:20 GMT+01:00 KimBP notifications@github.com:

I somehow like your approach for picking out the data directly from the 6bits characters. I found it a bit difficult to understand exactly the meaning of arg 3 and 4 even though you mentioned them. You could have calculated them from start bit and bit length: nbWord6 = (startbit + len - 1)/6; nbBit6 = (6 - ((startbit + len)%6) %6); (I think) Your current implementations isn't really generic - you can't e.g. extract e.g. vesselname (len=120bits) but if it just for providing data for your alarm function it really doesn't matter. I don't know the UniWifi so can't really help you with your power issues

Good luck with your live testing.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/KimBP/AIS/issues/1#issuecomment-282498064, or mute the thread https://github.com/notifications/unsubscribe-auth/ALMh7AnJ8fkaPP4P9FEjfUNNr6kA_Ti1ks5rgGLrgaJpZM4MC9OJ .