Skip to content

QuickPRS 1.1.0: follow the MFC archive format, fix #1, Bluetooth groundwork - #2

Merged
TheAbider merged 14 commits into
masterfrom
v1.1-overhaul
Oct 28, 2026
Merged

TheAbider merged 14 commits into
masterfrom
v1.1-overhaul

Conversation

@TheAbider

Copy link
Copy Markdown
Owner

Summary

QuickPRS 1.1.0: edits now keep the file structure RPM reads, issue #1 is fixed, a long list of broken commands and GUI paths is fixed, and quickprs radio adds groundwork for reading the radio over Bluetooth.

The file format

A .PRS file is an MFC CArchive: every class and object takes the next index in one map, later objects of a class are written as the tag 0x8000 | class_index, and every list starts with its count. The "separators" and "set markers" QuickPRS copied from the source file are those tags, so any edit that added or removed an object left every later tag stale. MFC's loader rejects tags that name the wrong class.

  • quickprs/archive.py reads a personality into a tree that keeps every byte and writes it back with tags, counts and schemas recomputed. All 36 RPM-saved test files read and re-serialize byte for byte.
  • Set, system, WAN and ECC edits go through the tree; create builds a real document.
  • Saving refuses an edit that breaks a readable file; validate reports stale tags and counts; repair fixes files saved by 1.0.x.
  • Write-up with diagrams: docs/prs-format.md.

Issue #1

Conventional sets after a padded gap are parsed and written back. P25 conventional sets export to P25_CONV_SET.csv and import from it, and the new quickprs import-csv detects each CSV's type so export-csv output imports directly.

Other fixes (details in CHANGELOG.md)

  • 800 MHz IDEN tables never landed on an 800 MHz channel; they now start at 851.0125 MHz
  • Trunk TX/RX were reversed in the README, example INIs and CSV templates; import-paste paired each frequency with itself
  • import-rr / auto-setup sent the API key as the password, so they could not log in
  • 2 m repeater offsets were reversed; the interop template now follows the NIFOG (800 MHz channels wide per 47 CFR 90.209)
  • System database IDs were unverified; PSERN corrected to 939; unverified entries warn
  • create and import-json silently overwrote files; cleanup, backup, fleet, clone-personality, search and list fixed
  • build [options] is checked like set-option, and export-config output builds back without losing programmable buttons, microphones or the short menu; the wizard's time zone reaches the radio
  • GUI: crash on start, Import Wizard and System Wizard failures, undo history carried across files, shortcuts firing while typing, multi-select edits

Bluetooth

The XG-100P's Bluetooth is Bluetooth Classic (serial port profile), and RPM's help documents programming over that COM port. quickprs radio scan/probe/relay/analyze find the radio, listen to it, and log RPM's sessions with it through a virtual null-modem pair. None of them sends bytes of its own to the radio. docs/bluetooth.md has the workflow.

Packaging

build.py collects every quickprs module instead of a hand-kept list, bundles pyserial, and leaves out bleak and httpx (they brought the WinRT runtime, numpy and Pillow into the EXE: 49 MB down to 31 MB in a test build).

Testing

  • Full suite locally, with the RPM-saved test files: 5,504 passed, 5 skipped. CI does not have those files, so it skips the tests that need them.
  • Each test added or changed on this branch was run against the code from before its fix and fails there. The exceptions are not regression tests: docstring-only edits, test-data consistency checks and a start-up smoke test. This check found two tests that passed for the wrong reason and two commits without tests; both are fixed here.
  • Test EXE built with PyInstaller: create writes a file that validates clean, radio scan lists the paired radio, and pyserial loads.
  • Not tested: opening an edited file in RPM, and any radio command against a powered-on radio.

Not yet confirmed

  • Which IDEN element field is the channel spacing and which the bandwidth (they may be the other way round)
  • What the four numbers in an ECC entry are

Fixes #1

Section replacement helpers now raise instead of writing at index -1
when an expected section is missing, empty set lists are rejected,
NOAA weather channels are receive-only, and make_conv_channel /
make_conv_set accept tx and scan flags. README gains a RadioReference
section.
A .PRS file is an MFC CArchive.  Every class and object takes the next
map index, later objects of a class are written as the tag
0x8000 | class_index, and every list is preceded by its WORD count.  The
"separators" and "set markers" QuickPRS copied from the source file are
those tags, so any edit that added or removed an object left every later
tag pointing at the wrong index, and list counts were not updated.  RPM's
loader rejects both.  `quickprs create` also produced a file whose
system count, list counts and empty WAN object did not match its
contents.

- archive.py reads a personality into an object tree that keeps every
  byte, and writes it back with headers, tags, counts and schemas
  regenerated.  All 36 RPM-saved test files read and re-serialize byte
  for byte; the PAWSOVERMAWS tags match the computed indices exactly
  (CTrunkSet 104 ... CDefaultIdenElem 907).
- The injector's set, system, WAN and ECC edits go through the tree;
  first-of-kind sets, emptied lists and new systems of every type now
  produce consistent files.
- create_blank_prs builds a real document.
- write_prs rewrites stale tags and counts before saving and refuses to
  save an edit that broke a readable file.
- validate reports stale tags and counts as errors; repair fixes them.
- Parsers no longer compare against PAWSOVERMAWS tag values; systems are
  listed by the type byte in front of each config, so tagged systems
  after another class's header are no longer mislabelled.
- FF FF inside talkgroup, channel and IDEN data no longer splits the
  list that holds it (a talkgroup ID of 65535 used to truncate it).
- The GUI no longer crashes on start (get_recent_files argument).
Some RPM files carry a few bytes between a conventional set's 60-byte
block and the next set's marker (13 and 12 bytes in the reported file).
The parser stopped at the first set, so later sets were missing from the
GUI, from CONV_SET.csv and from any rebuild.

- The conventional set parser looks past such bytes for the next set
  (matching the channels' class tag) and keeps them as ConvSet.padding;
  rebuilds take each set's extra bytes from the archive walk, so they
  are written back unchanged.
- P25 conventional sets export to P25_CONV_SET.csv (NACs in hex, TX/RX/
  Scan, long name) and import from it; the NAC columns are checked
  before the analog conventional columns, which a P25 file also has.
- injector.add_p25_conv_set / make_p25_conv_set / get_p25_conv_sets
  create P25 conventional sets, including the first one; new channels
  use the flag and trailer bytes RPM writes.
- New `quickprs import-csv FILE.PRS CSV...` detects each file's type,
  so export-csv output imports directly.  The GUI CSV import handles
  P25 conventional files, works on a blank personality and rolls back
  on failure.
- CLI writes now back up an existing output file, not only the input.
- Two watcher tests no longer depend on the clock's mtime granularity.

Fixes #1
GUI:
- Import Wizard built ConvSystemConfig/P25TrkSystemConfig with fields
  that do not exist (short_name, sys_id, flags) and passed an IDEN
  template object as entries, so every non-talkgroup import failed;
  clipboard channels were read with dict access on objects.
- System Wizard: log_action was called with a positional message after
  the system was added, so "Finish" reported failure and a retry added
  the system twice.  Talkgroup IDs are checked (1-65535) before anything
  is changed, and a failed add is rolled back.
- Opening another file kept the undo history, so Undo could put the
  previous file's bytes into the new one; opening from Recent Files did
  not ask about unsaved changes; a failed "save first" still went on to
  close or replace the document.  One _confirm_discard/_set_document
  path now serves open, drop, new, build, import JSON and close.
- Delete, Insert, F2, Ctrl+Z/Y no longer act on the tree while a text
  field has focus.
- Multi-select edits act on the exact (set, talkgroup) pairs selected,
  not on every selected ID in every selected set.
- Add-set dialogs work on a blank personality; Health Check no longer
  raises (current_path); keyboard-shortcut window unbinds its mouse
  wheel handler; dropped file paths are read as Unicode; the packaged
  exe launches the wizard; run.py routes any non-file argument to the
  CLI instead of keeping a list of commands.

Radio options (platformConfig):
- set_platform_option refuses misspelt attributes and values a field
  does not allow, and addresses nested elements such as
  audioConfig/microphone[micType=INTERNAL] instead of writing on the
  parent.
- The fallback XML is now RPM's own new-radio options (the old one had
  invented attributes and an invalid batteryType), and it is placed
  where RPM keeps it instead of shifting the fields after it.
- Presets and profiles no longer set attributes the XG-100P XML does
  not have (misc.ledEnabled, gps.reportInterval).
- import-rr and auto-setup passed the API key as the account password
  (RadioReferenceAPI(username, apikey, apikey)), so the documented
  commands could not log in.  They take --password (or
  QUICKPRS_RR_USER / _PASSWORD / _APIKEY, and ask for the password when
  a terminal is attached, keeping it out of shell history).
- 2 m repeater offsets were reversed: per the ARRL band plan 146.61-
  146.97 MHz outputs take -600 kHz and 147.00-147.39 MHz take +600 kHz
  (freq-tools offset 146.94 printed input 147.54; it is 146.34).
- RPM stores a trunk channel's TX on the site uplink (806 MHz) and RX on
  the downlink (851 MHz), but the README, example INIs and CSV templates
  showed 851,806 under a tx,rx header, which builds a radio listening on
  the uplink.  Examples are corrected, the README INI block now parses
  (key = value lines), and validation warns when a trunk set's TX and RX
  look swapped.
- import-paste paired every pasted frequency with itself; it now pairs
  each listed downlink with its band's uplink, as the GUI already did.
The 800 MHz tables used base 851.00625 MHz with 12.5 kHz steps, which
lands on 851.01875, 851.03125 ... and never on an 800 MHz channel centre
(851.0125 is half a step away), so channel numbers mapped to the wrong
frequencies and ECC channel references rounded to the wrong channel.
Phase II tables used 6.25 kHz spacing and bandwidth, unlike every TDMA
entry in the RPM-saved test personality.

- 800 MHz tables (FDMA and TDMA) start at 851.0125 MHz with 12500 in
  both the spacing and bandwidth fields: the entries RPM-saved files
  hold, and whole steps to every channel whichever field is the
  spacing.  A frequency list on a 6.25 kHz offset still gets 6.25 kHz
  steps from 851.00625.
- TDMA templates use 12.5 kHz like the real TDMA entries; the Mixed
  template no longer claims to copy a table it did not match.
quickprs radio (new):
- The XG-100P's Bluetooth is Bluetooth Classic, and RPM's own help
  ("Setting Up A Bluetooth Connection") documents programming it over
  the serial port profile, i.e. the Bluetooth COM port.  The protocol is
  not published, so these commands help learn it from RPM without
  sending anything of their own to the radio:
  - radio scan: paired Bluetooth serial ports with the device names
    (outgoing vs incoming port), optional BLE scan.
  - radio probe: connect and listen, never transmit; hex dump, guess at
    what arrives (NMEA, PPP, AT, text), optional capture file.
  - radio relay: sit between RPM (on a virtual null-modem pair) and the
    radio, forward both ways, log every byte and modem-line change.
  - radio analyze: per-direction statistics, chunk openers, text, and
    any .PRS archive in the radio's replies (--extract writes it).
- Capture files are JSON Lines, written line by line so a crash keeps
  what was read.

System database:
- The built-in list's System IDs and WACNs were never verified (the
  header claimed the FCC publishes them; it does not), and several are
  wrong.  PSERN is corrected to 939 from an RPM-saved personality and
  marked verified; every other entry is marked unverified and the CLI
  and GUI warn before one is added to a personality.
The interop template had VTAC11-14 at 155.7675-156.0375 MHz (they are
151.1375, 154.4525, 158.7375 and 159.4725), a UTAC44 that does not
exist, the 800 MHz channels at their pre-rebanding 866-868 MHz, the
UHF and 800 MHz channels as simplex on the output only, and the P25
700 MHz channels as analog FM.

Values now follow the NIFOG as RadioReference's National
Interoperability page lists it: VCALL10/VTAC11-14 simplex; UCALL40 and
UTAC41-43 as repeater pairs (+5 MHz) plus direct channels; 8CALL90 and
8TAC91-94 at 851.0125-853.0125 MHz as repeater pairs (-45 MHz) plus
direct channels; narrowband where the plan says FMN.  The 700 MHz
channels are left to a P25 conventional set.  The health check's
interop list uses the same frequencies, and make_conv_channel /
make_conv_set accept a narrowband flag.
- create refused nothing: `quickprs create radio.PRS` on an existing
  personality wiped it.  It now stops unless --force (which keeps a
  .bak).  import-json's default output is the .PRS the JSON was
  exported from, so it now stops instead of overwriting it.  Both write
  through write_prs.
- cleanup reported every trunk and talkgroup set as unused because it
  never read the set names systems refer to; it now uses them (13 sets
  wrongly reported on the PAWSOVERMAWS sample, 1 truly unused now).
- Backups of "radio_v2.PRS" were listed, restored and pruned as backups
  of "radio.PRS", and ordering by file time put a restored copy last;
  backups are now matched by exact name and ordered by their timestamp.
- fleet: unit names cannot place output files outside the output folder,
  duplicate names are reported instead of overwriting, short CSV rows no
  longer crash, and unit IDs must fit 24 bits.
- search reports files it cannot read (exit 1 when none were readable);
  list output prints 6.25 kHz channels with 5 decimals; the summary card
  escapes tone names like the full report.
- build ignored the [options] section (the README's example included)
  because a new personality has no platformConfig XML.  It now starts
  from RPM's new-radio options and applies the lines.
- clone-personality --name and --unit-id wrote invented attributes into
  the options XML and changed nothing the radio uses.  The name goes in
  the CPersonality header and the Home Unit ID into every P25 trunked
  system, the same way fleet sets it.
- The 800 MHz interop direct channels (8CALL90D, 8TAC91D-94D) were
  narrowband while their repeater pairs were wide.  806-809/851-854 MHz
  has a 20 kHz authorized bandwidth (47 CFR 90.209), direct channels
  included, so all ten are wide.  (RadioReference lists 8TAC91D-94D as
  FMN but 8CALL90D as FM.)  New test covers it.
- Help text and examples paired PSERN with System ID 892; the
  RPM-saved value is 939.
- The training preset claimed "low power" but only turns GPS on.
Since build started applying [options] to new personalities, it wrote
each line into a dict of the options XML: a friendly name such as
gps.gpsMode added an invented <gps> element beside the real gpsConfig,
misc.password never reached miscConfig, any value was accepted, and the
lists export-config writes for repeated elements (programmable buttons,
accessory buttons, short menu, microphones) replaced those elements
with an attribute holding the list text.

- apply_platform_options applies every line the way set-option does
  (section names mapped, attributes and values checked) on one parsed
  copy of the XML and writes once, so a bad line changes nothing.
  List values update the existing elements in order; the count must
  match and each value is checked.  The PAWSOVERMAWS options now come
  back identical through export-config and build.
- The wizard saved the time zone as display.timeZone, which the radio
  does not have; it sets TimeDateCfg zone and asks again for a zone RPM
  does not list (and for a GPS answer other than ON/OFF).
- The bad-option test passed on the old code for the wrong reason
  (every case failed earlier, on the missing options XML); each case
  now checks its own message.
…fixes

Commits 38694cf and 14b5c6f fixed these without tests.  Each new test
fails with its fix undone:

- import-json leaves the .PRS its JSON came from alone
- cleanup counts the sets RPM-saved systems name as used
- backups: exact file name, newest by the name's timestamp
- fleet: names stay in the output folder, duplicates reported, short
  rows read, unit IDs limited to 24 bits
- search reports unreadable files and fails when none can be read
- list prints 6.25 kHz channels with five decimals
- the summary card escapes tone names
- clone-personality puts the name in the header and the unit ID in
  every P25 trunked system
- README: Bluetooth groundwork, accurate feature list (no "100%
  decoded" claim; the system list is unverified), the RadioReference
  password, import-paste with its real flags, every CLI command, the
  corrected interop template.
- docs/prs-format.md (the MFC archive rules, with diagrams) and
  docs/bluetooth.md (finding the radio and recording RPM's sessions).
- CHANGELOG 1.1.0; the never-released 1.0.3 notes ship in it.
- Version 1.1.0; optional `radio` dependencies (pyserial, bleak);
  pyserial in requirements.txt.
- build.py collects every quickprs module instead of a hand-kept list,
  bundles pyserial, and leaves out bleak and httpx, which brought the
  WinRT runtime and rich, pygments, Pillow and numpy into the EXE.
- Missing-package messages name the package to install (QuickPRS is
  not on PyPI, so `pip install quickprs[radio]` could not work).
@TheAbider
TheAbider merged commit a8a7e7f into master Oct 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Conventional multiset parsing stops after first set; P25 conventional CSV export/import missing

1 participant