diff --git a/okdmr/dmrlib/etsi/crc/crc.py b/okdmr/dmrlib/etsi/crc/crc.py index 6059979..e7f1469 100644 --- a/okdmr/dmrlib/etsi/crc/crc.py +++ b/okdmr/dmrlib/etsi/crc/crc.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 # Strong-typed bitarray-based CRC # Based on Nicola Coretti work here: https://github.com/Nicoretti/crc/blob/eb27ca85cae760f7727fedcb3644209fa5386116/crc.py diff --git a/okdmr/dmrlib/etsi/fec/trellis.py b/okdmr/dmrlib/etsi/fec/trellis.py index aba65af..b867709 100644 --- a/okdmr/dmrlib/etsi/fec/trellis.py +++ b/okdmr/dmrlib/etsi/fec/trellis.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 from array import array from typing import Union, List, Dict, Tuple diff --git a/okdmr/dmrlib/etsi/layer2/pdu/data_header.py b/okdmr/dmrlib/etsi/layer2/pdu/data_header.py index 974ad9c..217194a 100644 --- a/okdmr/dmrlib/etsi/layer2/pdu/data_header.py +++ b/okdmr/dmrlib/etsi/layer2/pdu/data_header.py @@ -346,4 +346,6 @@ def from_bits(bits: bitarray) -> "DataHeader": udt_opcode=CsbkOpcodes.from_bits(bits[74:80]), ) else: - raise NotImplementedError(f"from_bits not implemented for {dpf}") + raise NotImplementedError( + f"from_bits not implemented for {dpf} (val {bits[4:8]})" + ) diff --git a/okdmr/dmrlib/tools/dmrlib_tool.py b/okdmr/dmrlib/tools/dmrlib_tool.py index f18b4de..34c4248 100644 --- a/okdmr/dmrlib/tools/dmrlib_tool.py +++ b/okdmr/dmrlib/tools/dmrlib_tool.py @@ -11,6 +11,7 @@ ) from okdmr.dmrlib.transmission.transmission_watcher import TransmissionWatcher from okdmr.dmrlib.utils.protocol_tool import ProtocolTool +from okdmr.dmrlib.tools.pcap_tool import EmbeddedExtractor class DmrlibTool(ProtocolTool): @@ -49,11 +50,14 @@ def dsdfme() -> None: _mapping = {99: "rc burst", 98: "cach burst", 10: "voice burst"} watcher: TransmissionWatcher = TransmissionWatcher() + emb_extractor: EmbeddedExtractor = EmbeddedExtractor() with open(args.file, "r") as file: - i = 0 - while i < 200: + while True: line = file.readline() + if not line: + break + parts = line.split(" ") if len(parts) == 3: timeslot = int(parts[0]) @@ -61,6 +65,9 @@ def dsdfme() -> None: burst_data = bytes.fromhex(parts[2]) if burst_type not in (99, 98): try: + from scapy.layers.inet import IP, UDP + from scapy.packet import Raw + b = Burst.from_bytes( data=burst_data, burst_type=( @@ -70,7 +77,13 @@ def dsdfme() -> None: ), ) b.timeslot = timeslot - watcher.process_burst(b) + + b = watcher.process_burst(b) + if b: + print(repr(b)) + emb_extractor.process_packet( + data=b.as_bytes(), + packet=IP() / UDP() / Raw(burst_data), + ) except Exception as e: print(e) - i += 1 diff --git a/okdmr/dmrlib/tools/pcap_tool.py b/okdmr/dmrlib/tools/pcap_tool.py index 7691542..6c3e7fc 100644 --- a/okdmr/dmrlib/tools/pcap_tool.py +++ b/okdmr/dmrlib/tools/pcap_tool.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 import logging import sys import traceback @@ -503,7 +502,3 @@ def main( if return_stats: return stats - - -if __name__ == "__main__": - PcapTool.main()