Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ All notable changes to QuickPRS will be documented in this file.
### Added
- `quickprs radio sniff`: record RPM's session with the radio from a Bluetooth trace served by Microsoft's Bluetooth Virtual Sniffer (or a saved pcap/pcapng file), without a virtual COM port driver. It keeps only the serial bytes RPM and the radio exchange, in the capture format `analyze` reads, reads traces with or without direction headers, and ends with a report of what the trace held (and why, when it found no serial data). com0com, which the relay needs, cannot load while Windows 11's Memory Integrity is on
- `quickprs radio analyze --transcript`: the conversation in a capture, message by message (chunks going the same way within 50 ms are one message), and the common message sizes and first bytes in each direction
- `quickprs radio replay`: send RPM's requests from a captured read to the radio again and compare each answer with the one RPM got, the first test of reading a radio without RPM. It stops at the first answer that differs (`--keep-going` carries on) or when the radio does not answer, keeps RPM's pauses and modem lines, and refuses any capture that is not a read (the radio's answers must hold a personality and RPM's requests must not)
- `radio sniff` records each side's modem lines (RFCOMM modem status) as events
- `--skip-encrypted` for `import-rr`, `auto-setup` and `import-paste`: leave out talkgroups RadioReference lists as fully encrypted

### Fixed
Expand All @@ -19,6 +21,7 @@ All notable changes to QuickPRS will be documented in this file.
- GUI: Save always kept a backup whatever the auto backup setting said; sixteen settings nothing read (a default NAC, a scan limit, an export folder and thirteen P25 system options QuickPRS cannot write) are gone
- GUI: editors that change only the open personality say Apply, not Save; a failure writing the recent files list no longer fails a save
- Shell completions listed 33 of the 63 commands and stale flags; they are now read from the CLI's parser
- `radio probe`, `relay` and `sniff` wrote over an existing capture file (`sniff` and `relay` default to `session.jsonl`, so a second session replaced the first); a capture is now never written over, and the next free name is used

## [1.2.0] - 2026-10-28

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Generate and edit Harris XG-100P personality (.PRS) files without Harris RPM sof

> **STATUS: In Development.** This tool is under active development. While the binary format has been extensively reverse-engineered and tested against known-good RPM files, it has NOT been exhaustively tested on all XG-100P hardware revisions and firmware versions. Test on non-critical equipment first.

> **IMPORTANT: This tool does NOT load mission plans onto radios.** QuickPRS generates and edits .PRS personality files. To actually load a personality onto an XG-100P radio, you still need Harris RPM software (for now). The `quickprs radio` commands are groundwork for reading radios directly over Bluetooth: they find the radio and record RPM's sessions with it, and never send bytes of their own (see [docs/bluetooth.md](docs/bluetooth.md)).
> **IMPORTANT: This tool does NOT load mission plans onto radios.** QuickPRS generates and edits .PRS personality files. To actually load a personality onto an XG-100P radio, you still need Harris RPM software (for now). The `quickprs radio` commands are groundwork for reading radios directly over Bluetooth: they find the radio, record RPM's sessions with it and replay a recorded read to test reading without RPM, and never send bytes of their own (see [docs/bluetooth.md](docs/bluetooth.md)).

## RadioReference Integration

Expand Down Expand Up @@ -70,7 +70,7 @@ The GUI includes a dedicated RadioReference import wizard (File > Import Wizard)
- Full GUI with tree view, inline editing, drag-and-drop, and RadioReference import wizard
- Built-in channel templates (MURS, GMRS, FRS, Marine, NOAA, Interop, Public Safety)
- Built-in list of 28 US P25 systems as a starting point (IDs unverified except where marked: confirm them before programming)
- Bluetooth groundwork: find a paired radio and record RPM's sessions with it (`quickprs radio`)
- Bluetooth groundwork: find a paired radio, record RPM's sessions with it and replay a read (`quickprs radio`)
- JSON export/import for human-editable radio configs
- Export to CHIRP CSV, Uniden CSV, SDRTrunk, DSD+, Markdown, INI
- Merge, clone, and compare PRS files
Expand Down
46 changes: 40 additions & 6 deletions docs/bluetooth.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ what RPM and the radio say to each other, so the programming protocol can be
learned from real sessions instead of guessed.

**None of these commands sends a byte of its own to the radio.** The relay
forwards only what RPM sends.
forwards only what RPM sends, and `replay` sends only the requests RPM sent
in a captured read.

A capture is never written over: when the file named with `--log` exists,
the command takes the next free name (`read-2.jsonl`, `read-3.jsonl` ...)
and says which.

## Bluetooth Classic, not BLE

Expand Down Expand Up @@ -92,8 +97,10 @@ After Ctrl+C the report should list RFCOMM frames (the channel opening and
closing) even though nothing was sent.

A full trace holds more than the serial data (Bluetooth link keys among
it); QuickPRS writes only the serial bytes, and only from the radio's link
once the trace has shown which link that is. `--pcap trace.pcapng` reads a
it); QuickPRS writes only the serial bytes and each side's modem lines (the
PC's DTR and RTS, the radio's DSR, CTS, RI and DCD, from RFCOMM's modem
status commands), and only from the radio's link once the trace has shown
which link that is. `--pcap trace.pcapng` reads a
trace saved from Wireshark instead. Traces with or without a direction
header (pcap link types 201 and 187) both work.

Expand Down Expand Up @@ -146,13 +153,40 @@ A capture is a JSON Lines file: a header line, then one line per chunk read
(`t` seconds since the start, `dir` `pc>radio` or `radio>pc`, `hex` bytes)
and modem-line events.

## Replay a read

```bash
quickprs radio replay read.jsonl --requests 3
quickprs radio replay read.jsonl
```

`replay` sends the requests RPM sent in a captured read to the radio again,
in order, and compares each answer with the one RPM got. It is the first
test of whether QuickPRS can read the radio by itself: when every answer is
the same, RPM's requests can become QuickPRS's own read command. At the
first answer that differs it stops and says where (`--keep-going` sends the
rest anyway): something in the session changes each time, a counter, a time
or a challenge, and those bytes need decoding first. It also stops when the
radio does not answer. `--requests N` sends only the first N requests.

Only reads are replayed. The capture must show the radio sending a
personality and RPM sending none, and RPM must have sent less than the
radio. A write, an activate or a remove changes the radio, so a capture of
one is refused before the port is opened.

Where RPM got no answer to a request, `replay` keeps RPM's pause before the
next one (up to 5 seconds), and it sets DTR and RTS as RPM did when the
capture recorded them. The replay is saved as a capture too
(`replay.jsonl` by default), so `analyze` and `--extract` work on it.

## Next steps

```mermaid
flowchart LR
A["capture RPM<br/>extracting"] --> B["decode the<br/>framing and commands"]
B --> C["read a radio<br/>with QuickPRS"]
C --> D["capture RPM<br/>writing"] --> E["write a radio<br/>with QuickPRS"]
A["capture RPM<br/>extracting"] --> B["replay the read"]
B -->|"same answers"| C["read a radio<br/>with QuickPRS"]
B -->|"answers differ"| D["decode the<br/>framing and commands"] --> C
C --> E["capture RPM<br/>writing"] --> F["write a radio<br/>with QuickPRS"]
```

Writing comes last and only after reading works and the write session is
Expand Down
31 changes: 29 additions & 2 deletions quickprs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4411,13 +4411,16 @@ def build_parser():
# radio (Bluetooth / serial link to the radio itself)
p_radio = sub.add_parser(
"radio",
help="Find a paired radio, listen to it, or log RPM talking to it",
help="Find a paired radio, listen to it, log RPM talking to it "
"or replay a read",
formatter_class=fmt,
epilog="The XG-100P's Bluetooth is Classic (serial port profile), "
"which RPM\n"
"programs over just like the USB cable. These commands "
"never send\n"
"their own bytes to the radio.\n"
"their own bytes to the radio; replay sends only RPM's "
"requests from a\n"
"captured read.\n"
"Examples:\n"
" quickprs radio scan\n"
" quickprs radio probe --port COM6 --seconds 15 "
Expand All @@ -4426,6 +4429,7 @@ def build_parser():
" quickprs radio relay --pc-port COM21 --radio-port COM6 "
"--log read.jsonl\n"
" quickprs radio analyze read.jsonl --transcript 60\n"
" quickprs radio replay read.jsonl --requests 3\n"
" quickprs radio analyze read.jsonl --extract radio.PRS")
radio_sub = p_radio.add_subparsers(dest="radio_cmd")
p_rscan = radio_sub.add_parser(
Expand Down Expand Up @@ -4484,6 +4488,24 @@ def build_parser():
p_ranalyze.add_argument("--extract", default=None,
help="Write a personality archive found in the "
"radio's replies to this .PRS path")
p_rreplay = radio_sub.add_parser(
"replay",
help="Send RPM's requests from a captured read to the radio again "
"and compare the answers")
p_rreplay.add_argument("capture",
help="Capture (.jsonl) of RPM reading the radio")
p_rreplay.add_argument("--port", default=None,
help="COM port (default: the one paired radio)")
p_rreplay.add_argument("--log", default="replay.jsonl",
help="Capture file for the replay (default "
"replay.jsonl, or the next free name)")
p_rreplay.add_argument("--requests", type=int, default=None,
metavar="N", help="Send only the first N requests")
p_rreplay.add_argument("--timeout", type=float, default=3.0,
help="Seconds to wait for an answer (default 3)")
p_rreplay.add_argument("--keep-going", action="store_true",
help="Carry on past answers that are not the "
"ones RPM got")

p_icsv = sub.add_parser(
"import-csv",
Expand Down Expand Up @@ -5776,6 +5798,11 @@ def run_cli(args=None):
return radio_commands.cmd_radio_analyze(
parsed.capture, extract=parsed.extract,
transcript=parsed.transcript)
if parsed.radio_cmd == "replay":
return radio_commands.cmd_radio_replay(
parsed.capture, port=parsed.port, log=parsed.log,
requests=parsed.requests, timeout=parsed.timeout,
keep_going=parsed.keep_going)
subcommand_parsers["radio"].print_help()
return 1
elif parsed.command == "import-csv":
Expand Down
6 changes: 5 additions & 1 deletion quickprs/radio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* ``probe`` open the radio's port and listen; never transmits
* ``relay`` sit between RPM and the radio and log what they say
* ``analyze`` summarise a capture and pull out any personality in it
* ``hci`` the serial bytes in a Bluetooth HCI trace (``sniff``)
* ``replay`` send RPM's requests from a captured read to the radio
again, and compare the answers with RPM's

Nothing here sends a byte of its own to the radio.
Nothing here sends a byte of its own to the radio: ``replay`` sends only
what RPM sent, and only from a session that read a personality.
"""
28 changes: 23 additions & 5 deletions quickprs/radio/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
{"t": 0.0456, "dir": "radio>pc", "hex": "5a 01 ..."}
{"t": 0.0460, "event": "pc dtr=1 rts=0"}

``t`` is seconds since the session started. Directions are named from the
``t`` is seconds since the session started. A capture is never
written over: when the file exists, the writer takes the next free name
(``read-2.jsonl``, ``read-3.jsonl`` ...) and says so in ``path``. Directions are named from the
radio's side of the conversation: ``pc>radio`` is what RPM (or the PC)
sent, ``radio>pc`` what the radio answered.
"""

from dataclasses import dataclass, field
from datetime import datetime, timezone
import json
from pathlib import Path
import threading
import time

Expand Down Expand Up @@ -48,16 +51,29 @@ def total(self, direction=None):
if direction is None or c.direction == direction)


def _create(path):
"""A new file at ``path``, or at the next free numbered name when that
is taken, and the path used."""
first = Path(path)
p, n = first, 1
while True:
try:
return open(p, "x", encoding="utf-8", newline="\n"), p
except FileExistsError:
n += 1
p = first.with_name(f"{first.stem}-{n}{first.suffix}")


class CaptureWriter:
"""Append chunks to a capture file as they happen.
"""Append chunks to a new capture file as they happen.

Each line is flushed at once, so a crash or Ctrl+C keeps everything
read so far, and a lock keeps lines whole when two threads (the two
directions of a relay) write at the same time.
"""

def __init__(self, path, note=""):
self._f = open(path, "w", encoding="utf-8", newline="\n")
self._f, self.path = _create(path)
self._t0 = time.monotonic()
self._lock = threading.Lock()
header = {"capture": "quickprs", "version": 1,
Expand Down Expand Up @@ -85,8 +101,10 @@ def add(self, direction, data, t=None):
self._write({"t": self._now() if t is None else t,
"dir": direction, "hex": data.hex(" ")})

def event(self, text):
self._write({"t": self._now(), "event": str(text)})
def event(self, text, t=None):
"""Log an event, such as a modem-line change; ``t`` as for add."""
self._write({"t": self._now() if t is None else t,
"event": str(text)})

def close(self):
self._f.close()
Expand Down
71 changes: 64 additions & 7 deletions quickprs/radio/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def show(data):
if writer is not None:
writer.close()
print(f"Received {offset[0]} bytes: {classify(data)}.")
if log:
print(f"Capture saved to {log}")
if writer is not None:
print(f"Capture saved to {writer.path}")
return 0


Expand All @@ -128,11 +128,11 @@ def cmd_radio_relay(pc_port, radio_port=None, log="session.jsonl",
def tally(direction, data):
counts[direction] += len(data)

print(f"Relaying {pc_port} (RPM side) <-> {radio_port} (radio), "
f"logging to {log}. Point RPM at the other end of the virtual "
f"pair, run the operation, then press Ctrl+C here.")
with CaptureWriter(log, note=note or
f"relay {pc_port} <-> {radio_port}") as writer:
print(f"Relaying {pc_port} (RPM side) <-> {radio_port} (radio), "
f"logging to {writer.path}. Point RPM at the other end of the "
f"virtual pair, run the operation, then press Ctrl+C here.")
try:
errors = run_relay(pc, radio, writer=writer, on_chunk=tally)
finally:
Expand All @@ -142,7 +142,7 @@ def tally(direction, data):
f"RPM: {counts['radio>pc']:,} bytes.")
for direction, e in errors:
print(f" {direction} ended: {e}", file=sys.stderr)
print(f"Analyze with: quickprs radio analyze {log}")
print(f"Analyze with: quickprs radio analyze {writer.path}")
return 0


Expand Down Expand Up @@ -192,10 +192,14 @@ def cmd_radio_sniff(host="127.0.0.1", port=24352, log="session.jsonl",

stats = TraceStats()
with CaptureWriter(log, note=note) as writer:
print(f"Writing the serial data to {writer.path}")
try:
for t, direction, data in serial_chunks(read_packets(stream),
address=address,
stats=stats):
if isinstance(data, str): # a modem line change
writer.event(data, t=t)
continue
writer.add(direction, data, t=t)
counts[direction] += len(data)
except KeyboardInterrupt:
Expand All @@ -208,10 +212,63 @@ def cmd_radio_sniff(host="127.0.0.1", port=24352, log="session.jsonl",
print(line)
print(f"RPM to radio: {counts['pc>radio']:,} bytes; radio to RPM: "
f"{counts['radio>pc']:,} bytes.")
print(f"Analyze with: quickprs radio analyze {log}")
print(f"Analyze with: quickprs radio analyze {writer.path}")
return 0


def cmd_radio_replay(capture_path, port=None, log="replay.jsonl",
requests=None, timeout=3.0, keep_going=False,
quiet=0.3):
"""Send RPM's requests from a captured read to the radio again and
compare the answers with the ones RPM got."""
from .replay import capture_lines, replay, steps, why_refused
if requests is not None and requests < 1:
print("Error: --requests must be at least 1", file=sys.stderr)
return 1
try:
cap = read_capture(capture_path)
except (OSError, ValueError) as e:
print(f"Error: {e}", file=sys.stderr)
return 1
reason = why_refused(cap)
if reason:
print(f"Not replaying {capture_path}: {reason}.", file=sys.stderr)
return 1
plan = steps(cap)
if requests is not None:
plan = plan[:requests]
port = _pick_port(port)
if port is None:
return 1
lines = capture_lines(cap)
dtr, rts = lines or (False, False)
try:
link = open_serial(port, dtr=dtr, rts=rts)
except LinkError as e:
print(f"Error: {e}", file=sys.stderr)
return 1
with CaptureWriter(log, note=f"replay of {capture_path} on "
f"{port}") as writer:
print(f"Sending RPM's {len(plan)} requests "
f"({sum(len(s.request) for s in plan):,} bytes) to {port} "
f"and comparing each answer with the one RPM got; logging "
f"to {writer.path}.")
try:
result = replay(link, plan, writer=writer, timeout=timeout,
quiet=quiet, keep_going=keep_going)
finally:
link.close()
for d in result.differences:
print(f" request {d.step + 1}: {d.describe()}")
print(f"Sent {result.sent} of {len(plan)} requests; {result.same} "
f"answers were the ones RPM got.")
if result.stopped:
print(f"Stopped: {result.stopped}.")
print(f"Analyze with: quickprs radio analyze {writer.path} "
f"--extract radio.PRS")
return 0 if result.same == len(plan) else 1


def cmd_radio_analyze(capture_path, extract=None, transcript=None):
try:
cap = read_capture(capture_path)
Expand Down
Loading