Skip to content

Add float32 register decoding to read command#1

Merged
zakiscoding merged 2 commits into
mainfrom
feat/issue-4-float-decoding
Mar 12, 2026
Merged

Add float32 register decoding to read command#1
zakiscoding merged 2 commits into
mainfrom
feat/issue-4-float-decoding

Conversation

@zakiscoding
Copy link
Copy Markdown
Owner

Self-PR for immediate merge in owned repo.

Copilot AI review requested due to automatic review settings March 12, 2026 16:48
@zakiscoding zakiscoding merged commit ebdd325 into main Mar 12, 2026
@zakiscoding zakiscoding deleted the feat/issue-4-float-decoding branch March 12, 2026 16:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-order options to modbus 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.

Comment thread modbus_cli/cli.py
Comment on lines +155 to +160
@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"]),
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
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.

3 participants