def decode(bv, validate=False):
	'''Unpack a bsreport message

	Fields in params:
	  - MessageID(uint): AIS message number.  Must be 4 (field automatically set to "4")
	  - RepeatIndicator(uint): Indicated how many times a message has been repeated
	  - UserID(uint): Unique ship identification number (MMSI)
	  - Time_year(uint): Current time stamp  year 1-9999
	  - Time_month(uint): Current time stamp  month 1..12
	  - Time_day(uint): Current time stamp  day of the month 1..31
	  - Time_hour(uint): Current time stamp  UTC hours 0..23
	  - Time_min(uint): Current time stamp  minutes
	  - Time_sec(uint): Current time stamp  seconds
	  - PositionAccuracy(uint): Accuracy of positioning fixes
	  - Position_longitude(decimal): Location of base station  East West location
	  - Position_latitude(decimal): Location of base station  North South location
	  - fixtype(uint): Method used for positioning
	  - Spare(uint): Not used.  Should be set to zero. (field automatically set to "0")
	  - RAIM(bool): Receiver autonomous integrity monitoring flag
	  - state_syncstate(uint): Communications State - SOTDMA  Sycronization state
	  - state_slottimeout(uint): Communications State - SOTDMA  Frames remaining until a new slot is selected
	  - state_slotoffset(uint): Communications State - SOTDMA  In what slot will the next transmission occur. BROKEN
	@type bv: BitVector
	@param bv: Bits defining a message
	@param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
	@rtype: dict
	@return: params
	'''

	#Would be nice to check the bit count here..
	#if validate:
	#	assert (len(bv)==FIX: SOME NUMBER)
	r = {}
	r['MessageID']=4
	r['RepeatIndicator']=int(bv[6:8])
	r['UserID']=int(bv[8:38])
	r['Time_year']=int(bv[38:52])
	r['Time_month']=int(bv[52:56])
	r['Time_day']=int(bv[56:61])
	r['Time_hour']=int(bv[61:66])
	r['Time_min']=int(bv[66:72])
	r['Time_sec']=int(bv[72:78])
	r['PositionAccuracy']=int(bv[78:79])
	r['Position_longitude']=Decimal(binary.signedIntFromBV(bv[79:107]))/Decimal('600000')
	r['Position_latitude']=Decimal(binary.signedIntFromBV(bv[107:134]))/Decimal('600000')
	r['fixtype']=int(bv[134:138])
	r['Spare']=0
	r['RAIM']=bool(int(bv[148:149]))
        r.update(commstate.sotdma_parse_bits(bv[-19:]))
        #r['commstate'] = commstate.sotdma_parse_bits(bv[-19:])
	#r['state_syncstate']=int(bv[149:151])
	#r['state_slottimeout']=int(bv[151:154])
	#r['state_slotoffset']=int(bv[154:168])
	return r
Example #2
0
def decode(bv, validate=False):
    """Unpack a bsreport message.

    Fields in params:
      - MessageID(uint): AIS message number.  Must be 4 (field automatically set to "4")
      - RepeatIndicator(uint): Indicated how many times a message has been repeated
      - UserID(uint): Unique ship identification number (MMSI)
      - Time_year(uint): Current time stamp  year 1-9999
      - Time_month(uint): Current time stamp  month 1..12
      - Time_day(uint): Current time stamp  day of the month 1..31
      - Time_hour(uint): Current time stamp  UTC hours 0..23
      - Time_min(uint): Current time stamp  minutes
      - Time_sec(uint): Current time stamp  seconds
      - PositionAccuracy(uint): Accuracy of positioning fixes
      - Position_longitude(decimal): Location of base station  East West location
      - Position_latitude(decimal): Location of base station  North South location
      - fixtype(uint): Method used for positioning
      - Spare(uint): Not used.  Should be set to zero. (field automatically set to "0")
      - RAIM(bool): Receiver autonomous integrity monitoring flag
      - state_syncstate(uint): Communications State - SOTDMA  Sycronization state
      - state_slottimeout(uint): Communications State - SOTDMA  Frames remaining until a new slot is selected
      - state_slotoffset(uint): Communications State - SOTDMA  In what slot will the next transmission occur. BROKEN
    @type bv: BitVector
    @param bv: Bits defining a message
    @param validate: Set to true to cause checking to occur.  Runs slower.  FIX: not implemented.
    @rtype: dict
    @return: params
    """

    r = {}
    r['MessageID'] = 4
    r['RepeatIndicator'] = int(bv[6:8])
    r['UserID'] = int(bv[8:38])
    r['Time_year'] = int(bv[38:52])
    r['Time_month'] = int(bv[52:56])
    r['Time_day'] = int(bv[56:61])
    r['Time_hour'] = int(bv[61:66])
    r['Time_min'] = int(bv[66:72])
    r['Time_sec'] = int(bv[72:78])
    r['PositionAccuracy'] = int(bv[78:79])
    r['Position_longitude'] = Decimal(binary.signedIntFromBV(
        bv[79:107])) / Decimal('600000')
    r['Position_latitude'] = Decimal(binary.signedIntFromBV(
        bv[107:134])) / Decimal('600000')
    r['fixtype'] = int(bv[134:138])
    r['Spare'] = 0
    r['RAIM'] = bool(int(bv[148:149]))
    r.update(commstate.sotdma_parse_bits(bv[-19:]))
    return r
Example #3
0
def decode(bv, validate=False):
    r = {}
    r['MessageID']=int(bv[:6])
    r['RepeatIndicator']=int(bv[6:8])
    r['UserID']=int(bv[8:38])
    r['NavigationStatus']=int(bv[38:42])
    r['ROT']=binary.signedIntFromBV(bv[42:50])
    r['SOG']=Decimal(int(bv[50:60]))/Decimal('10')
    r['PositionAccuracy']=int(bv[60:61])
    r['longitude']=Decimal(binary.signedIntFromBV(bv[61:89]))/Decimal('600000')
    r['latitude']=Decimal(binary.signedIntFromBV(bv[89:116]))/Decimal('600000')
    r['COG']=Decimal(int(bv[116:128]))/Decimal('10')
    r['TrueHeading']=int(bv[128:137])
    r['TimeStamp']=int(bv[137:143])
    r['RegionalReserved']=0
    r['Spare']=0
    r['RAIM']=bool(int(bv[148:149]))
    r.update(commstate.sotdma_parse_bits(bv[-19:]))
    return r
Example #4
0
def decode(bv, validate=False):
    r = {}
    r['MessageID']=int(bv[:6])
    r['RepeatIndicator']=int(bv[6:8])
    r['UserID']=int(bv[8:38])
    r['NavigationStatus']=int(bv[38:42])
    r['ROT']=binary.signedIntFromBV(bv[42:50])
    r['SOG']=Decimal(int(bv[50:60]))/Decimal('10')
    r['PositionAccuracy']=int(bv[60:61])
    r['longitude']=Decimal(binary.signedIntFromBV(bv[61:89]))/Decimal('600000')
    r['latitude']=Decimal(binary.signedIntFromBV(bv[89:116]))/Decimal('600000')
    r['COG']=Decimal(int(bv[116:128]))/Decimal('10')
    r['TrueHeading']=int(bv[128:137])
    r['TimeStamp']=int(bv[137:143])
    r['RegionalReserved']=0
    r['Spare']=0
    r['RAIM']=bool(int(bv[148:149]))
    r.update(commstate.sotdma_parse_bits(bv[-19:]))
    return r