Beispiel #1
0
 class BPDU(codec.Envelope):
     ''' Batched PDU part. '''
     STRUCT = (
         Header(ver=2, batched=True),
         MTS(),
         codec.Uint('rssi', mult=-1),
         codec.Int16BE('toa256'),
         codec.Int16BE('cir'),
         BurstBits('soft-bits'),
     )
Beispiel #2
0
class PDUv1Rx(codec.Envelope):
    STRUCT = (
        Header(ver=1),
        codec.Uint32BE('fn'),
        codec.Uint('rssi', mult=-1),
        codec.Int16BE('toa256'),
        MTS(),
        codec.Int16BE('cir'),
        BurstBits('soft-bits'),
    )
Beispiel #3
0
class PDUv2Rx(codec.Envelope):
    class BPDU(codec.Envelope):
        ''' Batched PDU part. '''
        STRUCT = (
            Header(ver=2, batched=True),
            MTS(),
            codec.Uint('rssi', mult=-1),
            codec.Int16BE('toa256'),
            codec.Int16BE('cir'),
            BurstBits('soft-bits'),
        )

    STRUCT = (
        Header(ver=2),
        MTS(),
        codec.Uint('rssi', mult=-1),
        codec.Int16BE('toa256'),
        codec.Int16BE('cir'),
        codec.Uint32BE('fn'),
        BurstBits('soft-bits'),
        codec.Sequence(item=BPDU()).f('bpdu'),
    )
Beispiel #4
0
class PDUv0Rx(codec.Envelope):
    STRUCT = (
        Header(ver=0),
        codec.Uint32BE('fn'),
        codec.Uint('rssi', mult=-1),
        codec.Int16BE('toa256'),
        codec.Buf('soft-bits'),
        codec.Buf('pad'),  # Optional
    )

    def __init__(self, *args, **kw):
        codec.Envelope.__init__(self, *args, **kw)

        # Field 'soft-bits' is either 148 (GMSK) or 444 (8-PSK) octets long
        self.STRUCT[-2].get_len = lambda _, data: 444 if len(data
                                                             ) > 148 else 148
Beispiel #5
0
 def test_int16(self):
     vals = (-32767, -16384, 0, 16384, 32767)
     self._test_uint(codec.Int16BE('foo'), '>h', vals)
     self._test_uint(codec.Int16LE('foo'), '<h', vals)