Skip to content
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

how can i decode TYPE AIVDO Message? #27

Closed
xiluzi opened this issue May 7, 2021 · 4 comments
Closed

how can i decode TYPE AIVDO Message? #27

xiluzi opened this issue May 7, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@xiluzi
Copy link

xiluzi commented May 7, 2021

from pyais import NMEAMessage
a = NMEAMessage.from_string('!AIVDO,1,1,,,B>qc:003wk?8mP=18D3Q3wgTiT;T,0*13')

l try to decode it but failed. But I can decode in https://www.aggsoft.com/ais-decoder.htm
did i make something wrong?

@M0r13n M0r13n added the bug Something isn't working label May 8, 2021
@M0r13n
Copy link
Owner

M0r13n commented May 8, 2021

Hey,

it seems that there is a bug in the library. Currently it raises an error if no Channel is given. Which is actually correct for AIVDM messages. But it is not correct for AIVDO messages.

I fill fix it.

Kind regards,
Leon

@M0r13n
Copy link
Owner

M0r13n commented May 8, 2021

The bug is fixed in the newest version of pyais (1.6.1).

Update with:

pip install -U pyais

@tangchenggang
Copy link

the print message just like this:MessageType1(msg_type=1, repeat=0, mmsi='247061100', status=<NavigationStatus.UnderWayUsingEngine: 0>, turn=0, speed=1.2, accuracy=0, lon=23.268065, lat=37.900988, course=273.0, heading=258, second=48, maneuver=<ManeuverIndicator.NotAvailable: 0>, spare=0, raim=False, radio=34527)
how could i output the message in csv format?

@M0r13n
Copy link
Owner

M0r13n commented Apr 2, 2022

Hey @tangchenggang

I added an example for you:

"""
The following example shows how you could write the decoded data to CSV.
You first need to decode the data into a dictionary and then write the
dictionary to a CSV file using a `DictWriter`.
"""
import csv

from pyais import decode

ais_msg = "!AIVDO,1,1,,,B>qc:003wk?8mP=18D3Q3wgTiT;T,0*13"
data_dict = decode(ais_msg).asdict()

with open('decoded_message.csv', 'w') as f:
    w = csv.DictWriter(f, data_dict.keys())
    w.writeheader()
    w.writerow(data_dict)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants