Package ais :: Module nmea
[hide private]
[frames] | no frames]

Module nmea

source code

Handle creation and extraction of NMEA strings. Maybe need a separate VDM class like ais-py?


Requires:

Author: John Doe FIX: put in the authors name

Version: 4799

Copyright: 2006

Since: 2006-Sep-26 FIX: replace with the file creation date

Status: under development

Organization: CCOM - FIX: if not CCOM change the name and link

License: GPL v2

Functions [hide private]

str

Checksum is calculated by xor'ing everything between ? or ! and the *
>>> checksumStr("!AIVDM,1,1,,B,35MsUdPOh8JwI:0HUwquiIFH21>i,0*09")
'09'
>>> checksumStr("AIVDM,1,1,,B,35MsUdPOh8JwI:0HUwquiIFH21>i,0")
'09'
checksumStr(data)
Take a NMEA 0183 string and compute the checksum.
bool
>>> isChecksumValid("!AIVDM,1,1,,B,35MsUdPOh8JwI:0HUwquiIFH21>i,0*09")
True
Corrupted:
>>> isChecksumValid("!AIVDM,11,1,,B,35MsUdPOh8JwI:0HUwquiIFH21>i,0*09")
False
isChecksumValid(nmeaStr, allowTailData=True)
Return True if the string checks out with the checksum
  buildNmea(aisBits, prefix='!', serviceType='AI', msgType='VDM', channelSeq=None, channel='A')
Create one long oversized nmea string for the bits

Variables [hide private]
  __date__ = '2006-09-25'
Date of last svn commit
  nmeaChecksumRegExStr = '\\,[0-9]\\*[0-9A-F][0-9A-F]'
  nmeaChecksumRE = <_sre.SRE_Pattern object at 0x2463548>

Function Details [hide private]

checksumStr(data)

source code 
Take a NMEA 0183 string and compute the checksum.
Parameters:
  • data (str) - NMEA message. Leading ?/! and training checksum are optional
Returns:

str

Checksum is calculated by xor'ing everything between ? or ! and the *
>>> checksumStr("!AIVDM,1,1,,B,35MsUdPOh8JwI:0HUwquiIFH21>i,0*09")
'09'
>>> checksumStr("AIVDM,1,1,,B,35MsUdPOh8JwI:0HUwquiIFH21>i,0")
'09'
hexidecimal value

isChecksumValid(nmeaStr, allowTailData=True)

source code 
Return True if the string checks out with the checksum
Parameters:
  • allowTailData - Permit handing of Coast Guard format with data after the checksum
  • data (str) - NMEA message. Leading ?/! are optional
Returns: bool
>>> isChecksumValid("!AIVDM,1,1,,B,35MsUdPOh8JwI:0HUwquiIFH21>i,0*09")
True
Corrupted:
>>> isChecksumValid("!AIVDM,11,1,,B,35MsUdPOh8JwI:0HUwquiIFH21>i,0*09")
False
True if the checksum matches

buildNmea(aisBits, prefix='!', serviceType='AI', msgType='VDM', channelSeq=None, channel='A')

source code 
Create one long oversized nmea string for the bits
Parameters:
  • aisBits (BitVector) - message payload
  • prefix - '!' or '$' what is the difference?
  • serviceType - 'can this be anything other than AI?
  • msgType - VDM. Should not be VDO (own ship)
  • channelSeq - 1-9 or None
  • channel - AIS channel A or B

To Do: sync names of prefix and serviceType to NMEA spec.

See Also: reference the appropriate spec documents for all this stuff.


Variables Details [hide private]

__date__

Date of last svn commit
Value:
'2006-09-25'                                                           
      

nmeaChecksumRegExStr

None
Value:
'\\,[0-9]\\*[0-9A-F][0-9A-F]'                                          
      

nmeaChecksumRE

None
Value:
,[0-9]\*[0-9A-F][0-9A-F]