def __init__(self): super().__init__() self.f.add(U1('PortId')) self.f.add(Padding(1, 'res1')) self.f.add(X2('txReady')) self.f.add(X4_Mode('mode')) self.f.add(U4('baudRate')) self.f.add(X2_Proto('inProtoMask')) self.f.add(X2_Proto('outProtoMask')) self.f.add(X2('flags')) self.f.add(Padding(2, 'res2'))
def __init__(self): super().__init__() self.f.add(U1('version')) self.f.add(U1('numConfigs')) self.f.add(Padding(2, 'res1')) self.f.add(U1_LeverArmType('leverArmType')) self.f.add(Padding(1, 'res2')) self.f.add(I2('leverArmX')) self.f.add(I2('leverArmY')) self.f.add(I2('leverArmZ')) self.f.version = 0 self.f.numConfigs = 1
def unpack(self): # Dynamically build fields based on message length self.f = Fields() self.f.add(U1('msgVer')) self.f.add(U1('numTrkChHw')) self.f.add(U1('numTrkChUse')) self.f.add(U1('numConfigBlocks')) # Extract upto this place to read number of config blocks super().unpack() # TODO: Check extra length against numConfigBlocks # TODO: raise on mismatch """ extra_length = len(self.data) - 40 extra_info = int(extra_length / 30) """ # TODO: check nested fields -> unit test for i in range(self.f.numConfigBlocks): self.f.add(U1(f'gnssId_{i}')) self.f.add(U1(f'resTrkCh_{i}')) self.f.add(U1(f'maxTrkCh_{i}')) self.f.add(Padding(1, f'res1_{i}')) self.f.add(X4(f'flags_{i}')) # Bit 0: enable super().unpack()
def __init__(self): super().__init__() self.f.add(U1('type')) self.f.add(U1('version')) self.f.add(X1('ref')) self.f.add(I1('leapSecs')) self.f.add(U2('year')) self.f.add(U1('month')) self.f.add(U1('day')) self.f.add(U1('hour')) self.f.add(U1('minute')) self.f.add(U1('second')) self.f.add(Padding(1, 'res1')) self.f.add(U4('ns')) self.f.add(U2('tAccS')) self.f.add(Padding(2, 'res2')) self.f.add(U4('tAccNs'))
def __init__(self): super().__init__() self.f = Fields() self.f.add(U4('iTow')) self.f.add(U1('version')) self.f.add(X1('bitfield0')) self.f.add(Padding(2, 'res1')) self.f.add(I4('yaw')) # 1e-1 -> more likely 1e-2 self.f.add(I2('pitch')) # 1e-1 self.f.add(I2('roll')) # 1e-1
def test_pack2(self): u = Fields() u.add(I4('test')) u.add(U1('val')) u.add(Padding(2, 'res1')) u.test = 0x76543210 u.val = 0xAF data = u.pack() assert data == bytearray.fromhex('10 32 54 76 AF 00 00')
def __init__(self): super().__init__() self.f = Fields() self.f.add(U4('iTow')) self.f.add(U1('version')) self.f.add(U1_Flags('flags')) self.f.add(U1('error')) self.f.add(Padding(1, 'res1')) self.f.add(U4('yaw')) # 1e-2, 0..+360 self.f.add(I2('pitch')) # 1e-2, -90..+90 self.f.add(I2('roll')) # 1e-2, -180..180
def unpack(self): # Dynamically build fields based on message length self.f = Fields() self.f.add(U1('version')) self.f.add(U1('numConfigs')) self.f.add(Padding(2, 'res1')) # Extract upto this place to read number of level arm configurations super().unpack() assert self.f.numConfigs <= 5 # Build final list for lever in range(self.f.numConfigs): self.f.add(U1_LeverArmType(f'leverArmType_{lever}')) self.f.add(Padding(1, f'res2_{lever}')) self.f.add(I2(f'leverArmX_{lever}')) self.f.add(I2(f'leverArmY_{lever}')) self.f.add(I2(f'leverArmZ_{lever}')) super().unpack()
def __init__(self): super().__init__() self.f.add(X1('filter')) self.f.add(U1('nmeaVersion')) self.f.add(U1('numSV')) self.f.add(X1('flags')) self.f.add(X4('gnssToFilter')) self.f.add(U1('svNumbering')) self.f.add(U1('mainTalkerId')) self.f.add(U1('gsvTalkerId')) self.f.add(U1('version')) self.f.add(CH(2, 'bdsTalkerId')) self.f.add(Padding(6, 'res1'))
def test_pack1(self): u = Fields() u.add(I4('test')) u.add(U1('val')) u.add(Padding(3, 'res1')) u.add(U4('test2')) u.test = 0x76543210 u.val = 0xAF u.test2 = 0xcafebabe data = u.pack() print(data) assert data == bytearray.fromhex('10 32 54 76 AF 00 00 00 be ba fe ca')
def unpack(self): # Dynamically build fields based on message length self.f = Fields() self.f.add(U4('iTow')) self.f.add(U1('version')) self.f.add(X1_InitStatus1('initStatus1')) self.f.add(X1_InitStatus2('initStatus2')) self.f.add(Padding(5, 'res1')) self.f.add(U1_FusionMode('fusionMode')) self.f.add(Padding(2, 'res2')) self.f.add(U1('numSens')) # Extract upto this place to read number of sensors super().unpack() # Build final list for sensor in range(self.f.numSens): self.f.add(X1_SensStatus1(f'sensStatus1_{sensor}')) self.f.add(X1_SensStatus2(f'sensStatus2_{sensor}')) self.f.add(U1(f'freq_{sensor}')) self.f.add(X1(f'faults_{sensor}')) super().unpack()
def __init__(self): super().__init__() self.f.add(U1('tpIdx')) self.f.add(U1('version')) self.f.add(Padding(2, 'res1')) self.f.add(I2('antCableDelay')) self.f.add(I2('rfGroupDelay')) self.f.add(I4('freqPeriod')) self.f.add(I4('freqPeriodLock')) self.f.add(I4('pulseLenRatio')) self.f.add(I4('pulseLenRatioLock')) self.f.add(I4('userConfigDelay')) self.f.add(X4('flags'))
def __init__(self): super().__init__() self.f.add(X2('mask')) self.f.add(U1('dynModel')) self.f.add(U1('fixMode')) self.f.add(I4('fixedAlt')) self.f.add(U4('fixedAltVar')) self.f.add(I1('minElev')) self.f.add(U1('drLimit')) # reserved self.f.add(U2('pDop')) self.f.add(U2('tDop')) self.f.add(U2('pAcc')) self.f.add(U2('tAcc')) self.f.add(U1('staticHoldThresh')) self.f.add(U1('dgpsTimeOut')) self.f.add(U1('cnoThreshNumSVs')) self.f.add(U1('cnoThresh')) self.f.add(U2('pAccAdr')) self.f.add(U2('staticHoldMaxDist')) self.f.add(U1('utcStandard')) self.f.add(Padding(5, 'res1'))
def __init__(self): super().__init__() self.f.add(X2('navBbrMask')) self.f.add(U1('resetMode')) self.f.add(Padding(1, 'res1'))
def __init__(self): super().__init__() self.f.add(U2('version')) self.f.add(X2('mask1')) self.f.add(X4('mask2')) self.f.add(Padding(2, 'res1')) self.f.add(U1('minSVs')) self.f.add(U1('maxSVs')) self.f.add(U1('minCN0')) self.f.add(Padding(1, 'res2')) self.f.add(U1('iniFix3D')) self.f.add(Padding(2, 'res3')) self.f.add(U1('ackAiding')) self.f.add(U2('wknRollover')) self.f.add(U1('sigAttenCompMode')) self.f.add(Padding(1, 'res4')) self.f.add(Padding(2, 'res5')) self.f.add(Padding(2, 'res6')) self.f.add(U1('usePPP')) self.f.add(U1('aopCfg')) self.f.add(Padding(2, 'res7')) self.f.add(U2('aopOrbMaxErr')) self.f.add(Padding(4, 'res8')) self.f.add(Padding(3, 'res9')) self.f.add(U1('useAdr')) self.f.add(Padding(2, 'res10')) self.f.add(Padding(2, 'res11'))