itemir / rpi_boat_utils

Utilities for Raspberry Pi, mostly for usage on a boat. Includes UART control scripts, traffic measurement tools for Mikrotik (RouterOS) and OpenWrt, AIS wireless daemon, AIS decoder and an extensible boat & IoT sensor daemon for Signal K.
MIT License
88 stars 24 forks source link

Fails with "not an AIVDM" message #1

Closed splobsterman closed 7 years ago

splobsterman commented 7 years ago

I'm not good enough at Python to know why this fails. My AIS source works with OpenCPN on the Pi and other plotter programs on the mac but aisplay fails like this:

Traceback (most recent call last): File "./aisplay.py", line 304, in httpd.handle_request() Error decoding message: Not an AIVDM message File "/usr/lib/python2.7/SocketServer.py", line 276, in handle_request fd_sets = _eintr_retry(select.select, [self], [], [], timeout)

Error decoding message: Not an AIVDM message File "/usr/lib/python2.7/SocketServer.py", line 155, in _eintr_retry

return func(*args)

Error decoding message: Not an AIVDM message

Can someone give me a pointer here?

itemir commented 7 years ago

This means, what comes in doesn't look like an expected message.

What is the input (USB, serial etc.)? What do you see when you cat it directly?

And BTW, does aisplay work on Pi but not on Mac or doesn't it work regardless?

splobsterman commented 7 years ago

Serial, via USB, from a device called a Daisy 2+

Reading from the serial port sees this: (this is using a serial port reader script I hacked in Mac Applescript)

!AIVDM,1,1,,A,ENk`sl987a:60W2@8@@@@@@@@@@=OTgJ<LwrP00003vP000,2*46

and it the Daisy 2+ output works with my Mac plotting software and with OpenCPN on the RPi 3 (fully updated, with libais installed)

I read your note about not planning to pursue this bit of kit any further so I don’t want to take more of your time than I should! ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ Dan Hinckley ⎈ dbh@suiattle.org

On 19 Jul 2017, at 15:08, Ilker Temir notifications@github.com wrote:

This means, what comes in doesn't look like an expected message.

What is the input (USB, serial etc.)? What do you see when you cat it directly?

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

itemir commented 7 years ago

Hey Don,

This is odd. It should at least proceed to the next step or silently ignore the message.

Error is coming from here:

    if not re.match(r'\!AIVDM,', data):
         return (None, True, 'Not an AIVDM message')

So for some reason, '!IAIVDM' was not seen in the data it read.

And then this triggers this:

            if error is not None:
                if cli_options.verbose:
                    print 'Error decoding message: %s' % error
                    print data

So it should simply continue, silently or not depending on -v flag. It will require further troubleshooting but at a minimum verbose mode running aisplay with -v flag (ie. aisplay -v) should display the data that is malformed. I suspect you already ran it in verbose mode? If so, data itself is missing, which is very strange. Can you paste the whole section, showing the full command, error and what is displayed afterwards?

And yes, aisplay was more an experiment and is not meant to be long term. But if we can quickly figure out what the issue is, it'd be cool. If not, I will let it go.

splobsterman commented 7 years ago

Here is the command line:

./aisplay.py --device '/dev/ttyAMA0' -v

When I hit Enter, the following scrolls VERY fast and I hit Ctrl-C immediately:

Error decoding message: Not an AIVDM message Error decoding message: Not an AIVDM message

<(Deleted at least 50 lines of this error msg)>

Error decoding message: Not an AIVDM message Error decoding message: Not an AIVDM message Error decoding message: Not an AIVDM message Error decoding message: Not an AIVDM message

Erro^C

Traceback (most recent call last): File "./aisplay.py", line 304, in httpd.handle_request() File "/usr/lib/python2.7/SocketServer.py", line 276, in handle_request fd_sets = _eintr_retry(select.select, [self], [], [], timeout) File "/usr/lib/python2.7/SocketServer.py", line 155, in _eintr_retry return func(*args) KeyboardInterrupt Segmentation fault ———————————————————————————————————————————

If you can tell me how to read the port output directly using a script on the Pi I’ll be happy to run it; I’m pretty much of a Linux newbie and a total Python noob I’m afraid.

¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ Dan Hinckley ⎈ dbh@suiattle.org

On 19 Jul 2017, at 16:08, Ilker Temir notifications@github.com wrote:

Hey Don,

This is odd. It should at least proceed to the next step or silently ignore the message.

Error is coming from here:

if not re.match(r'\!AIVDM,', data):
     return (None, True, 'Not an AIVDM message')

So for some reason, '!IAIVDM' was not seen in the data it read.

And then this triggers this:

        if error is not None:
            if cli_options.verbose:
                print 'Error decoding message: %s' % error
                print data

So it should simply continue, silently or not depending on -v flag. It will require further troubleshooting but at a minimum verbose mode running aisplay with -v flag (ie. aisplay -v) should display the data that is malformed. I suspect you already ran it in verbose mode? If so, data itself is missing, which is very strange. Can you paste the whole section, showing the full command, error and what is displayed afterwards?

And yes, aisplay was more an experiment and is not meant to be long term. But if we can quickly figure out what the issue is, it'd be cool. If not, I will let it go.

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

itemir commented 7 years ago

This is really odd. There should be be some data before that error message but clearly not there. There should at least an empty line between error messages, which would indicate data being an empty line but that not being there is very odd.

So is this on a Linux/Raspberry Pi or on Mac? Please make sure you try on the same device, either Linux or Mac to be consistent. Do a "cat /dev/ttyAMA0" and see what it displays.

splobsterman commented 7 years ago

1) RPi: There are spaces between the lines; I had removed them for the sake of keeping the message shorter. RPI: This is the command line I used: ./aisplay.py --device '/dev/ttyAMA0' -v

2) RPi: cat /dev/ttyAMA0 returns no output; using sudo doesn’t change that.

3)RPi: OpenCPN sees all the targets within range of my antenna

4) This is all on an RPi 3 fully updated. (I used the Mac just to write a small serial port script so I could see if the sentences were arriving from the Daisy 2+)

Error decoding message: Not an AIVDM message

Error decoding message: Not an AIVDM message

Error decoding message: Not an AIVDM message

Error decoding message: Not an AIVDM message

Error decoding message: Not an AIVDM message

Error decodin^C

Traceback (most recent call last): File "./aisplay.py", line 304, in httpd.handle_request() Error decoding message: Not an AIVDM message File "/usr/lib/python2.7/SocketServer.py", line 276, in handle_request

fd_sets = _eintr_retry(select.select, [self], [], [], timeout)

Error decoding message: Not an AIVDM message File "/usr/lib/python2.7/SocketServer.py", line 155, in _eintr_retry

return func(*args)

Error decoding message: Not an AIVDM message KeyboardInterrupt

Segmentation fault

¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ Dan Hinckley ⎈ dbh@suiattle.org

On 20 Jul 2017, at 3:08, Ilker Temir notifications@github.com wrote:

This is really odd. There should be be some data before that error message but clearly not there. There should at least an empty line between error messages, which would indicate data being an empty line but that not being there is very odd.

So is this on a Linux/Raspberry Pi or on Mac? Please make sure you try on the same device, either Linux or Mac to be consistent. Do a "cat /dev/ttyAMA0" and see what it displays.

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

itemir commented 7 years ago

There doesn't appear to be any input on /dev/ttyAMA0. As long as you don't see anything on /dev/ttyAMA0, aisplay won't work.

What device do you use on OpenCPN?

splobsterman commented 7 years ago

/dev/ttyAMA0

I’ve googled this and also tried /dev/ttyS0 and Python just freezes when I do.

¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ Dan Hinckley ⎈ dbh@suiattle.org

On 20 Jul 2017, at 18:08, Ilker Temir notifications@github.com wrote:

There doesn't appear to be any input on /dev/ttyAMA0. As long as you don't see anything on /dev/ttyAMA0, aisplay won't work.

What device do you use on OpenCPN?

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

itemir commented 7 years ago

Sorry, I am out of options here. It might be the baud rate but not sure. Is this Daisy from Adrian Studer? If so, may be worth to loop him in. As long as /dev/ttyAMA0 works, aisplay will work.

splobsterman commented 7 years ago

Yes, that’s the device I am using. I’ll ask him.

I REALLY want to figure out a way to display the targets on a gmaps page, as your program does and I have a couple of other leads for this.

Thanks for making the effort. Very much appreciated.

¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ Dan Hinckley ⎈ dbh@suiattle.org

On 20 Jul 2017, at 19:08, Ilker Temir notifications@github.com wrote:

Sorry, I am out of options here. It might be the baud rate but not sure. Is this Daisy from Adrian Studer? If so, may be worth to bring loop him in. As long /dev/ttyAMA0 works, aisplay will work.

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

itemir commented 7 years ago

Closing this issue. Please reopen if there is any more information.

splobsterman commented 7 years ago

No progress so far. Thanks for your help to date. Regards,

¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ Dan Hinckley ⎈ dbh@suiattle.org

On 2 Sep 2017, at 15:08, Ilker Temir notifications@github.com wrote:

Closing this issue. Please reopen if there is any more information.

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