Add float32 register decoding to read command#1
Conversation
There was a problem hiding this comment.
Pull request overview
Adds float32 decoding support to the read command so users can interpret pairs of Modbus 16-bit registers as IEEE-754 32-bit floating-point values (with configurable byte/word ordering), and updates the banner/artwork accordingly.
Changes:
- Add
--float,--byte-order, and--word-orderoptions tomodbus read, including a float32 decode output table. - Implement helper decoding logic for 2x16-bit registers → float32.
- Update the CLI banner artwork in both the app theme and README, and document float decode examples.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
modbus_cli/theme.py |
Updates the rendered Rich banner ASCII art. |
modbus_cli/cli.py |
Adds float32 decode path for read, plus new CLI flags and a decoding helper. |
README.md |
Updates banner ASCII art and adds usage examples for --float decoding and ordering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @click.option("--float", "decode_float", is_flag=True, | ||
| help="Decode register pairs as 32-bit IEEE 754 floats.") | ||
| @click.option("--byte-order", type=click.Choice(["BE", "LE"]), | ||
| default="BE", show_default=True, | ||
| help="Byte order within each 16-bit register for --float mode.") | ||
| @click.option("--word-order", type=click.Choice(["BE", "LE"]), |
There was a problem hiding this comment.
With --float enabled, the --format/-f option is still accepted but isn’t used (float output is always formatted via decoded:.6g). This can be confusing for users; consider rejecting --format when --float is set, or clarifying in help text that --format applies only to integer register output (or introducing a dedicated float formatting option).
Self-PR for immediate merge in owned repo.