Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose flow_control paramater from zigpy #52

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

oliv3r
Copy link

@oliv3r oliv3r commented Aug 10, 2024

Certain boards (such as the Sonoff Zigbee 3.0 USB Dongle Plus P) have a hardware switch that allows for turning on hardware flow control (given the correct firmware is flashed). This requires of course that zigpy-cli also allows for setting this flag to be able to communicate with the dongle.

Zigpy and zigpy-znp already support hardware flow control fully. No wit is time that zigpy-cli also offers this option.

@oliv3r
Copy link
Author

oliv3r commented Aug 10, 2024

I have not yet tested this myself, as I first wanted to know if anything else is needed here.

I am in process of building the z-stack library with hardware flow control, but need something to test with, chicken and egg. I think this exposes everything correctly to zigpy, but I wasn't 100% sure. So this is also a 'verification step' to check if this patch is correct at all.

I will report later if this works or not, where the second bit will be hardware. Is my Z-Stack patch broken, did I forget to flip the switch, or is zigpy-cli not doing it for me.

Copy link
Contributor

@puddly puddly left a comment

Choose a reason for hiding this comment

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

I left a few comments. I think this is a good addition, thanks!

zigpy_cli/radio.py Outdated Show resolved Hide resolved
zigpy_cli/radio.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@puddly
Copy link
Contributor

puddly commented Aug 10, 2024

Is my Z-Stack patch broken, did I forget to flip the switch, or is zigpy-cli not doing it for me.

If you run zigpy-cli in verbose mode (zigpy -vvv), you will be able to see the radio connection parameters: "Opening a serial connection to %r (baudrate=%s, xonxoff=%s, rtscts=%s)"

@oliv3r
Copy link
Author

oliv3r commented Aug 16, 2024

So first test shows the option to be working as expected.

voluptuous.error.MultipleInvalid: value must be one of [None, 'hardware', 'software'] for dictionary value @ data['device']['flow_control']
/ # zigpy -vvv radio --baudrate=115200  --flow-control None znp /dev/ttyUSB0 form

(yes, I am aware that None wasn't a valid string to begin with, but I wanted to trigger the error/see what happens :p)

/ # zigpy -vvv radio --baudrate=115200 --flow-control=hardware znp /dev/ttyUSB0 info
2024-08-16 07:35:19.955 fb5f17fa8e36 zigpy.serial DEBUG Opening a serial connection to '/dev/ttyUSB0' (baudrate=115200, xonxoff=False, rtscts=True)

/ # zigpy -vvv radio --baudrate=115200 --flow-control=software znp /dev/ttyUSB0 info
2024-08-16 07:36:22.957 fb5f17fa8e36 zigpy.serial DEBUG Opening a serial connection to '/dev/ttyUSB0' (baudrate=115200, xonxoff=True, rtscts=False)


It doesn't work yet for me (other then none, the default) as my firmware does not yet handle hardware flow control; and doesn't support software flow control at all anyway (so it just hangs, which is expected).

The commands get forwarded and interpreted properly however.

Not sure if it helps much waiting for the hardware flow control firmware, as any problems would be in znp or the firmware, not zigpy-cli. But feel free to wait for it.

@oliv3r oliv3r requested a review from puddly August 16, 2024 19:44
zigpy_cli/radio.py Outdated Show resolved Hide resolved
@oliv3r oliv3r force-pushed the flowcontrol branch 3 times, most recently from 0c2c22d to 872e6b3 Compare August 16, 2024 20:40
zigpy_cli/radio.py Show resolved Hide resolved
@oliv3r
Copy link
Author

oliv3r commented Aug 17, 2024

I think this is more explicit. There's various option, but the only accepted flag is passed. No room for ambiguity. Upstream does something similar as well anyway.

@oliv3r oliv3r requested a review from puddly August 17, 2024 13:57
@puddly
Copy link
Contributor

puddly commented Aug 17, 2024

rtscts and xonxoff are only really used by the serial port library. Zigpy only uses hardware and software (and none).

@oliv3r
Copy link
Author

oliv3r commented Aug 18, 2024 via email

@puddly
Copy link
Contributor

puddly commented Aug 18, 2024

They can always run --help, the options are all listed there. I'm not a fan of aliases like this, especially for development tools.

@oliv3r
Copy link
Author

oliv3r commented Aug 19, 2024

They can always run --help, the options are all listed there. I'm not a fan of aliases like this, especially for development tools.

While I generally agree with you; I think here it does make sense to alias the values, to go with the common namings. Which is what zigpy itself even does; rename hardware to rtscs.

However, you are the boss; so I'll drop the aliases.

Certain boards (such as the Sonoff Zigbee 3.0 USB Dongle Plus P) have a
hardware switch that allows for turning on hardware flow control (given
the correct firmware is flashed). This requires of course that zigpy-cli
also allows for setting this flag to be able to communicate with the
dongle.

Zigpy and zigpy-znp already support hardware flow control fully. No wit
is time that zigpy-cli also offers this option.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
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