Skip to content

Prepare to support other device models#41

Merged
cr merged 6 commits intocr:devfrom
johannessen:config-params
Mar 28, 2025
Merged

Prepare to support other device models#41
cr merged 6 commits intocr:devfrom
johannessen:config-params

Conversation

@johannessen
Copy link
Contributor

These changes make adding support for other devices easier by parameterizing config memory locations. Sets up #40.

Adding tests for the config module exposed a few issues, which this PR tries to address.

The GX1400 doesn’t store the selected region and the ATIS enabled flag in quite the same format as the HX870/HX890. 03a3685 moves the code parsing that data from the info CLI command into the config module. read_region() and read_atis_enabled() are modified to return a tuple instead of a scalar. These methods exist in the dev branch, but haven’t been merged into master yet, so this shouldn’t be a breaking change for users.

The fifth byte in a waypoint definition is 0xf0 for waypoints created on the device itself, but 0xff for waypoints created in Yaesu's PC software, YCE15.

The radio seems to ignore the fifth byte altogether, so I'm not sure whether that difference was intentionally introduced by Yeasu, or if it was a mistake. Either way, both formats should be accepted by unpack_waypoint(). This change accomplishes that by simply ignoring the fifth byte, starting unpacking with the sixth byte, which contains the most significant digits of the latitude value.
Since the canonical source of the flash ID is now FLASH_ID in the config classes, that's what check_flash_id() should use. With this change, the "fixme" flash_id values in the device classes can be removed.

Verifying the flash ID check using the simulator requires a way to let tests control the config memory. Automatically populating the simulator with the correct flash ID should only happen if no config data is provided to the constructor.
Many Standard Horizon radios share the same hardware platform, but the memory layout varies from model to model. This change makes it easier to add additional models to hxtool.
Config users should have an easy way to retrieve the ATIS enabled flag as boolean and the region as string. How these values are stored in the device differs by model, so the previous approach of referring to a dict in the memory module may not scale well when support for more devices is added.

To avoid the need for extra methods, this change lets the new (unreleased) read_* methods return both the Python-y boolean/string value as well as the actual data byte read from the device memory as a tuple. This approach is similar to that of other methods like read_mmsi().
@cr cr merged commit df3bba9 into cr:dev Mar 28, 2025
@cr
Copy link
Owner

cr commented Mar 28, 2025

Nice, this looks really good. And thanks for taking care of the tests!

@johannessen johannessen deleted the config-params branch March 30, 2025 20:37
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.

2 participants