Beispiel #1
0
def buildNmea(aisBits,
              prefix='!',
              serviceType='AI',
              msgType='VDM',
              channelSeq=None,
              channel='A'):
    '''
    Create one long oversized nmea string for the bits
    @param aisBits: message payload
    @type aisBits: BitVector
    @param prefix: '!' or '$'  what is the difference?
    @param serviceType: 'can this be anything other than AI?
    @param msgType: VDM.  Should not be VDO (own ship)
    @param channelSeq: 1-9 or None
    @param channel: AIS channel A or B
    @todo: sync names of prefix and serviceType to NMEA spec.
    @see: reference the appropriate spec documents for all this stuff.
    '''

    rList = [prefix, serviceType, msgType, ',1,1,']
    if None != channelSeq: rList.append(str(channelSeq))
    rList.append(',')
    rList.append(channel)
    rList.append(',')

    payloadStr, pad = binary.bitvectoais6(aisBits)  #[0]
    rList.append(payloadStr)
    rList.append(',' + str(pad))
    rStr = ''.join(rList)
    rStr += '*' + checksumStr(rStr)

    return rStr
Beispiel #2
0
def buildNmea(aisBits,prefix='!',serviceType='AI',msgType='VDM',channelSeq=None,channel='A'):
    '''
    Create one long oversized nmea string for the bits
    @param aisBits: message payload
    @type aisBits: BitVector
    @param prefix: '!' or '$'  what is the difference?
    @param serviceType: 'can this be anything other than AI?
    @param msgType: VDM.  Should not be VDO (own ship)
    @param channelSeq: 1-9 or None
    @param channel: AIS channel A or B
    @todo: sync names of prefix and serviceType to NMEA spec.
    @see: reference the appropriate spec documents for all this stuff.
    '''

    rList = [prefix,serviceType,msgType,',1,1,']
    if None != channelSeq: rList.append(str(channelSeq))
    rList.append(',')
    rList.append(channel)
    rList.append(',')

    payloadStr,pad = binary.bitvectoais6(aisBits) #[0]
    rList.append(payloadStr)
    rList.append(','+str(pad))
    rStr = ''.join(rList)
    rStr += '*'+checksumStr(rStr)

    return rStr
Beispiel #3
0
            'SeqID3': options.SeqID3Field,
            'DestID4': options.DestID4Field,
            'SeqID4': options.SeqID4Field,
        }

        bits = encode(msgDict)
        if 'binary' == options.ioType: print str(bits)
        elif 'nmeapayload' == options.ioType:
            # FIX: figure out if this might be necessary at compile time
            #print "bitLen",len(bits)
            bitLen = len(bits)
            if bitLen % 6 != 0:
                bits = bits + BitVector(
                    size=(6 - (bitLen % 6)))  # Pad out to multiple of 6
            #print "result:",binary.bitvectoais6(bits)[0]
            print binary.bitvectoais6(bits)[0]

        # FIX: Do not emit this option for the binary message payloads.  Does not make sense.
        elif 'nmea' == options.ioType:
            nmea = uscg.create_nmea(bits)
            print nmea
        else:
            sys.exit('ERROR: unknown ioType.  Help!')

    if options.sqlCreate:
        sqlCreateStr(outfile, options.fieldList, dbType=options.dbType)

    if options.latexDefinitionTable:
        latexDefinitionTable(outfile)

    # For conversion to word tables
Beispiel #4
0
			'RAIM': options.RAIMField,
			'state_syncstate': options.state_syncstateField,
			'state_slottimeout': options.state_slottimeoutField,
			'state_slotoffset': options.state_slotoffsetField,
		}

		bits = encode(msgDict)
		if 'binary'==options.ioType: print str(bits)
		elif 'nmeapayload'==options.ioType:
		    # FIX: figure out if this might be necessary at compile time
		    #print "bitLen",len(bits)
		    bitLen=len(bits)
		    if bitLen%6!=0:
			bits = bits + BitVector(size=(6 - (bitLen%6)))  # Pad out to multiple of 6
		    #print "result:",binary.bitvectoais6(bits)[0]
		    print binary.bitvectoais6(bits)[0]


		# FIX: Do not emit this option for the binary message payloads.  Does not make sense.
		elif 'nmea'==options.ioType: 
		    #bitLen=len(bits)
                    #if bitLen%6!=0:
		    #	bits = bits + BitVector(size=(6 - (bitLen%6)))  # Pad out to multiple of 6
                    import aisutils.uscg as uscg
                    nmea = uscg.create_nmea(bits)
                    print nmea
                    #
                    #


                    #sys.exit("FIX: need to implement creating nmea capability")