Beispiel #1
0
def noaawaterlevel2aisMsg8Nmea(stationID,
                               mmsi,
                               datum,
                               wl,
                               verbose=False,
                               debug=False):
    '''
    Return one long NMEA string.  This will be oversized for the nmea spec.
    '''
    #print 'noaawaterlevel2aisMsg8Nmea\n  ',wl
    payloadBits = noaawaterlevel2aisBits(stationID,
                                         mmsi=mmsi,
                                         datum=datum,
                                         wl=wl,
                                         verbose=verbose,
                                         debug=debug)

    nmeaStr = buildNmea(payloadBits)

    ts = wl.timeStamp
    fields = ts.split()
    yr, mo, da = fields[0].split('-')
    hr, mi, sec = fields[1].split(':')
    sec = sec.split('.')[0]
    if sec[0] == '0': sec = sec[1:]
    timestamp = calendar.timegm(
        (int(yr), int(mo), int(da), int(hr), int(mi), int(sec)))
    nmeaStr += ',r' + str(mmsi) + ',' + str(timestamp)

    return nmeaStr
def noaawaterlevel2aisMsg8Nmea(stationID,mmsi,verbose=False,debug=False):
    '''
    Return one long NMEA string.  This will be oversized for the nmea spec.
    '''

    payloadBits = noaawaterlevel2aisBits(stationID,mmsi=mmsi,verbose=verbose,debug=debug)

    #params = {}
    #params['MessageID'] = 8
    #params['RepeatIndicator'] = 1
    #params['UserID'] = int(mmsi)
    #params['Spare'] = 0
    #params['BinaryData'] = payloadBits

    #msg8bits = msg8_ais.encode(params)
    #nmeaStr = buildNmea(msg8bits)

    nmeaStr = buildNmea(payloadBits)

    bbmPayloadBitsNoPad = payloadBits[40:]
    print 'lenpayload',len(bbmPayloadBitsNoPad)
#     padLen=6 - (len(bbmPayloadBitsNoPad)%6)
#     if 0!= padLen:
#         pad = BitVector( bitlist = [0,]*padLen )
#         bbmPayloadBits = bbmPayloadBitsNoPad + pad
#     else:
#         bbmPayloadBits = bbmPayloadBitsNoPad

    print bbmPayloadBitsNoPad
    bbmPayloadStr,padLen = ais.binary.bitvectoais6(bbmPayloadBitsNoPad)

    print bbmPayloadBitsNoPad
    print ais.binary.ais6


    print 'pad len',padLen

    bbmStr = ais.nmea.bbmEncode(1 # totSent=
                                ,1 # sentNum=
                                ,0 # seqId=
                                ,3 # aisChan=
                                ,8 # MsgId
                                , bbmPayloadStr #bbmPayloadBits # data=
                                ,padLen # numFillBits=
                                )


    s = bbmStr[1:-3]
    print bbmStr
    print s
    sum=0
    for c in s: sum = sum ^ ord(c)
    sumHex= "%x" % sum
    print 'checksum should be:', sumHex.upper()


    return nmeaStr,bbmStr
Beispiel #3
0
def noaawaterlevel2aisMsg8Nmea(stationID,mmsi,datum,wl,verbose=False,debug=False):
    '''
    Return one long NMEA string.  This will be oversized for the nmea spec.
    '''
    payloadBits = noaawaterlevel2aisBits(stationID,mmsi=mmsi,datum=datum,wl=wl,verbose=verbose,debug=debug)

    nmeaStr = buildNmea(payloadBits)

    ts=wl.timeStamp
    fields = ts.split()
    yr,mo,da=fields[0].split('-')
    hr,mi,sec = fields[1].split(':')
    sec=sec.split('.')[0]
    if sec[0]=='0': sec=sec[1:]
    timestamp = calendar.timegm((int(yr),int(mo),int(da),int(hr),int(mi),int(sec)))
    nmeaStr += ',r'+str(mmsi)+','+str(timestamp)

    return nmeaStr