linux-automation / lxa-iobus

Linux Automation IOBus server
https://lxa-iobus.readthedocs.io/en/latest/
Apache License 2.0
3 stars 4 forks source link

lxa_iobus: server: fix string/integer type confusion in set_pin() #43

Closed hnez closed 4 months ago

hnez commented 4 months ago

The form encoded parameter value sent via POST request is parsed by aiohttp so it can be used in set_pin(). It is however passed in as string ("0", "1" or "toggle") so it will always be considered true-ish, resulting in the current implementation always turning the output on, even if "0" was requested.

Treat the value as integer instead (as long as it is not "toggle") and check that for true-ish-ness.

Fixes: 9236c1d introduced in #38.

TODO before merging:

hnez commented 4 months ago

I've checked the other endpoints and think they are not affected by this.

I've also found the change in 9236c1d that removed the string to integer type conversion, which is a bit hidden in the diff: https://github.com/linux-automation/lxa-iobus/commit/9236c1d58edccb0a54e3911b52026c73fc5989db#r140859939, because the control flow changed.