Skip to content

Workspace does not compile: two incompatible baofeng RadioIdent types + non-exhaustive RadioVariant match in serial_hardware.rs #265

Description

@forkwright

Finding

cargo check --workspace --all-features fails on main (2 errors) in crates/akroasis/src/radio/serial_hardware.rs. This confirms akroasis#262's core claim ("main does not currently build, and nothing noticed") is still true today, independent of the snafu-0.9 migration #262 originally cited (that part is fixed — no snafu errors remain).

Evidence

cargo check --workspace --all-features @ main (8506c10), 2026-07-16, after installing the missing system deps (libudev-dev, protobuf-compiler — also absent from whatever environment last actually compiled this workspace):

error[E0308]: mismatched types
   --> crates/akroasis/src/radio/serial_hardware.rs:125:39
    |
125 |         let config = identify_variant(&ident).map_err(|_| RadioError::WrongBaudRate {
    |                      ---------------- ^^^^^^ expected `syntonia::baofeng::variant::RadioIdent`, found `syntonia::baofeng::ident::RadioIdent`

error[E0004]: non-exhaustive patterns: `_` not covered
   --> crates/akroasis/src/radio/serial_hardware.rs:143:11
    |
143 |     match config.variant {
    |           ^^^^^^^^^^^^^^ pattern `_` not covered

Root cause: crates/syntonia/src/baofeng/ has two different RadioIdent structs:

  • ident.rs::RadioIdent { raw_bytes: Vec<u8>, normalized: [u8; 8], firmware_prefix: String } — normalizes 8/12-byte responses and pre-extracts a clean 6-char firmware prefix in from_raw().
  • variant.rs::RadioIdent { raw: Vec<u8> } — a separate, simpler struct whose firmware_prefix() lossy-converts the entire raw buffer to a string (no normalization, no prefix extraction), consumed by variant::identify_variant().

serial_hardware.rs:110 builds an ident.rs-flavored RadioIdent (via protocol.identify()) and passes it to variant::identify_variant, which wants its own variant.rs-flavored type — these have not been reconciled since the two modules diverged (see also akroasis#237, duplicate/conflicting magic-byte constants between constants.rs and variant.rs — same module-split root cause).

Separately, variant_from_config at serial_hardware.rs:141-146 matches all 4 current RadioVariant variants but the enum is #[non_exhaustive] and matched from a different crate, so rustc requires a wildcard arm regardless.

Why this matters

This is the exact failure mode akroasis#262 warns about: no CI workflow compiles the workspace, so a break like this lands and stays silent. Because the two RadioIdent types extract the firmware prefix differently (clean 6-char substring vs. lossy-decoding the whole raw buffer), picking the wrong one over the other is not merely a type-plumbing fix — it changes which bytes get matched against UV5R_PREFIXES/BF_F8HP_PREFIXES, i.e. it can affect which physical radio variant gets identified. Radio misidentification corrupts EEPROM writes (already flagged as a live risk in akroasis#238/#225).

Desired correction

Reconcile ident.rs::RadioIdent and variant.rs::RadioIdent into one canonical type (likely ident.rs's, since it already does correct 8/12-byte normalization and prefix extraction) and update variant::identify_variant to consume it, verifying the firmware-prefix matching behavior is unchanged for both magic-byte-set orderings. Add a _ => None (or explicit) wildcard arm to variant_from_config's match per #[non_exhaustive]. This needs the same review as akroasis#237 since both stem from the constants.rs/variant.rs/ident.rs split never being fully unified — worth fixing together.

Done when: cargo check --workspace --all-features succeeds on main, and identify_variant is called with a single canonical RadioIdent type across syntonia and akroasis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions