Skip to content

Commit

Permalink
remove unnecessary bitbangs, allow dmrlib-dsd-fme to process all -Q o…
Browse files Browse the repository at this point in the history
…utputs, codeformatting
  • Loading branch information
smarek committed May 14, 2024
1 parent 067daae commit 786ef9c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
1 change: 0 additions & 1 deletion okdmr/dmrlib/etsi/crc/crc.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion okdmr/dmrlib/etsi/fec/trellis.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
from array import array
from typing import Union, List, Dict, Tuple

Expand Down
4 changes: 3 additions & 1 deletion okdmr/dmrlib/etsi/layer2/pdu/data_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]})"
)
21 changes: 17 additions & 4 deletions okdmr/dmrlib/tools/dmrlib_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -49,18 +50,24 @@ 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])
burst_type = int(parts[1])
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=(
Expand All @@ -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
5 changes: 0 additions & 5 deletions okdmr/dmrlib/tools/pcap_tool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
import logging
import sys
import traceback
Expand Down Expand Up @@ -503,7 +502,3 @@ def main(

if return_stats:
return stats


if __name__ == "__main__":
PcapTool.main()

0 comments on commit 786ef9c

Please sign in to comment.