M0r13n / pyais

AIS message decoding and encoding in Python (AIVDM/AIVDO)
MIT License
176 stars 61 forks source link

fix: increase sub message hour field length #135

Closed prefixFelix closed 4 months ago

prefixFelix commented 4 months ago

The length of the UTC hour and minute field of the sub message must be increased from 4 bits to 5 bits, otherwise an incorrect time will be output. This is always the case if the hour of a message is greater than 15. An example:

decoded = pyais.decode('!AIVDM,1,1,,B,133ga6PP0lPPE>4M3G@DpOwTR61p,0*33')
com = decoded.get_communication_state()
print(f"Time: {com['utc_hour']}:{com['utc_minute']}")
# Outputs: Time: 0:30

The actual output should be 16:30. This can also be cross-checked with online AIS decoders such as the Maritec one.

M0r13n commented 4 months ago

@prefixFelix That looks correct. Good catch!

prefixFelix commented 4 months ago

No problem. Thanks for the great project! It saved me a lot of time and hassle on my own project.

M0r13n commented 4 months ago

@prefixFelix That is nice to hear. Thank you!