-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Can't send a data value of 0 via IR module. #2751
Comments
crankyoldgit
changed the title
Can't send a data value of 0 via IR modue.
Can't send a data value of 0 via IR module.
May 17, 2018
I agree. I went for your simple fix and PR Another solution would be to test for any string length before using strtoul |
curzon01
pushed a commit
to curzon01/Tasmota
that referenced
this issue
Sep 7, 2018
Ref: Issue arendst#2751 Incorrect assumption that if the result of `strtoul()` is zero (0) it is a parse failure. That's incorrect as the "data" payload could actually be 0. Ref: crankyoldgit/IRremoteESP8266#447 (comment)
curzon01
pushed a commit
to curzon01/Tasmota
that referenced
this issue
Sep 7, 2018
5.14.0a * Add KNX energy data (arendst#2750) * Fix display selection of un-available GPIO options in Module Configuration webpage (arendst#2718) * Fix IRSend not accepting data value of 0 (arendst#2751)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can't send a data value of 0 via the IR module.
The IR subsystem fails to send a message when the data payload is 0 (zero).
To Reproduce
Send a MQTT message to the irsend module.
e.g.
topic: "cmnd/SONOFF_DEVICE/irsend"
payload: '{"Protocol": "SAMSUNG","Bits":32,"data":0}'
Expected behavior
A Samsung 32bit message with a value of
0
should be transmitted.e.g. A call of
irsend->sendSAMSUNG(0, 32);
should be made. It doesn't.Screenshots
N/A
Additional context
I think the bug is here:
https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/xdrv_02_irremote.ino#L301
When
data
is0
, it evaluates asFalse
in the aboveif
statement.Most simple fix is to change:
to:
Technically a more correct fix is to check if you had a parsing error (you can't do that with strtoul()) and to NOT assume a return value of
0
fromstrtoul()
is a parse error, a str of "0" is valid and a potential value, and a real result ofstrtoul()
.TL;DR: When
strtoul()
returns zero, it isn't always a failure to convert.Workarounds:
Specify a value that has the lower bits as zero. e.g. 2^32 which has the lower 32 bits as 0, but the entire value is != 0. e.g. 0b100000000000000000000000000000000
MQTT example of the workaround:
Ref:
crankyoldgit/IRremoteESP8266#447 (comment)
The text was updated successfully, but these errors were encountered: