hardware: surface modem CRC counter on TCP and USB radios#74
Merged
Conversation
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR exposes modem CRC errors through the
TCPLoRaRadioandUSBLoRaRadiointerfaces in the waypyMC_Repeateralready expects.The modem firmware already includes
crc_errorsinCMD_STATUS_RESP, but the host-side radio wrappers were not copying that value onto the radio object ascrc_error_count.This change:
crc_errorsin both transport driverscrc_error_counton the radio objectsProblem
pyMC_Repeaterrecords CRC errors using:This already works for local SX1262 radios, but not for
pymc_usbmodem transports unless the wrapper exposes the same attribute.Before this PR:
Modem firmware sent
crc_errorsinCMD_STATUS_RESPget_modem_status()parsed the field correctlyTCPLoRaRadioandUSBLoRaRadiodid not expose:radio.crc_error_countAs a result, repeater-side CRC tracking remained at
0even when the modem itself was reporting CRC errors.What Changed
1. Added Cached CRC State to Both Radio Wrappers
Updated:
src/pymc_core/hardware/tcp_radio.pysrc/pymc_core/hardware/usb_radio.pyNew attributes:
self._crc_errors = 0self.crc_error_count = 02. Synced Modem CRC Errors Into the Radio Object
After unpacking
CMD_STATUS_RESP, both wrappers now:status["crc_errors"]inself._crc_errorsstatus["crc_errors"]inself.crc_error_countThis is the core compatibility fix for repeater integration.
3. Surfaced CRC Counters in
get_status()Both wrappers now expose:
"crc_errors""crc_error_count"This keeps the returned status dictionary aligned with the live cached values.
4. Refreshed Status During Normal Health Polling
Previously, health polling only refreshed the noise floor.
Now, the periodic health check refreshes:
This keeps
crc_error_countcurrent during normal operation without requiring special polling paths.Why This Is the Right Fix
The existing repeater logic already expects a radio-level attribute:
That means the compatibility boundary belongs inside
pyMC_coretransport wrappers rather than in repeater itself.This keeps:
Files Changed
src/pymc_core/hardware/tcp_radio.pysrc/pymc_core/hardware/usb_radio.pyBehavior After This PR
When a
pymc_usbmodem reports CRC errors inCMD_STATUS_RESP:TCPLoRaRadio.crc_error_countupdatesUSBLoRaRadio.crc_error_countupdatesTesting
Validated by:
py_compilepyMC_coreagainst a live repeater installcrc_error_countObserved on a live system:
Scope
This PR is intentionally narrow:
pyMC_coretransport wrapper behavior changesThis is a compatibility fix so
pymc_usbmodem transports behave like other radios from the repeater’s perspective.