Example #1
0
def read_telemetry_buffer(raw):
    entries = []

    with progressbar.ProgressBar(max_value=len(raw)) as bar:
        while len(raw) >= 230:
            if raw[0] == 0xCD:
                raw = raw[1:]

            part = raw[0:230]
            raw = raw[230:]
            try:
                all_bits = bitarray(endian='little')
                all_bits.frombytes(''.join(map(lambda x: pack('B', x), part)))

                reader = BitReader(all_bits)
                store = BeaconStorage()

                parsers = FullBeaconParser().GetParsers(reader, store)
                parsers.reverse()

                while len(parsers) > 0:
                    parser = parsers.pop()
                    parser.parse()

                entries.append(store.storage)
            except:
                pass

            bar.update(bar.value + 230)

    return entries
Example #2
0
    def test_parse_beacon(self):
        beacon_path = path.join(config['REPORTS_DIR'], 'telemetry')
        with open(beacon_path, 'rb') as f:
            data = f.read()

            store = BeaconStorage()
            parser = BitArrayParser(FullBeaconParser(), data, store)
            parser.parse()
    def test_beacon_parsing(self):
        self._start()

        self.system.comm.put_frame(telecommand.SendBeacon())

        frame = self.system.comm.get_frame(20, filter_type=BeaconFrame)

        self.assertIsInstance(frame, BeaconFrame)
        store = BeaconStorage()
        parser = BitArrayParser(
            FullBeaconParser(),
            ''.join(map(lambda x: pack('B', x), frame._payload)), store)
        parser.parse()
Example #4
0
def read_telemetry_file(file_name):
    raw = system.obc.read_file(file_name)

    result = []

    for offset in xrange(0, len(raw), 230):
        single_entry = raw[offset:offset + 230]

        store = BeaconStorage()
        parser = BitArrayParser(FullBeaconParser(), single_entry, store)
        parser.parse()

        result.append(store.storage)

    return result
Example #5
0
    def __init__(self, payload):
        self._payload = payload
        try:
            all_bits = bitarray(endian='little')
            all_bits.frombytes(''.join(map(lambda x: pack('B', x), payload)))

            reader = BitReader(all_bits)
            store = BeaconStorage()

            parsers = FullBeaconParser().GetParsers(reader, store)
            parsers.reverse()

            while len(parsers) > 0:
                parser = parsers.pop()
                parser.parse()

            self._parsed = store.storage
        except:
            self._parsed = None
Example #6
0
    def parse(frame):
        if isinstance(frame, BeaconFrame):
            all_bits = bitarray(endian='little')
            all_bits.frombytes(''.join(
                map(lambda x: pack('B', x), frame.payload())))

            reader = BitReader(all_bits)
            store = BeaconStorage()

            parsers = FullBeaconParser().GetParsers(reader, store)
            parsers.reverse()

            while len(parsers) > 0:
                parser = parsers.pop()
                parser.parse()

            result = store.storage
        else:
            result = None

        return result
Example #7
0
with open(telemetry_file, 'rb') as f:
    raw = f.read()

raw = ensure_byte_list(raw)

entries = []

while len(raw) >= 230:
    print len(raw)
    part = raw[0:230]
    raw = raw[230:]
    all_bits = bitarray(endian='little')
    all_bits.frombytes(''.join(map(lambda x: pack('B', x), part)))

    reader = BitReader(all_bits)
    store = BeaconStorage()

    parsers = FullBeaconParser().GetParsers(reader, store)
    parsers.reverse()

    while len(parsers) > 0:
        parser = parsers.pop()
        parser.parse()

    entries.append(store.storage)


def convert_values(o):
    if isinstance(o, timedelta):
        return o.total_seconds()