-
Notifications
You must be signed in to change notification settings - Fork 839
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
Allow the message timeout value to be set at run-time. #294
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beside my comment about definition s hta will add readability looks good to me.
src/IRrecv.cpp
Outdated
irparams.recvpin = recvpin; | ||
irparams.bufsize = bufsize; | ||
// Ensure we are going to be able to store all possible values in the | ||
// capture buffer. | ||
irparams.timeout = std::min(timeout, (uint8_t) (RAWTICK * UINT16_MAX / 1000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to have a definition for the maximum allowed. I.e. MAX_TIMEOUT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MAX_TIMEOUT_MS for consistency
src/IRrecv.cpp
Outdated
DPRINTLN(")]"); | ||
// We really should never get a value of 0, except as the last value | ||
// in the buffer. If that is the case, then assume infinity and return true. | ||
if (measured == 0) return true; | ||
return measured >= ticksLow(std::min(desired, TIMEOUT_MS * 1000), | ||
return measured >= ticksLow(std::min(desired, | ||
(uint32_t) (irparams.timeout * 1000)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there MS_TO_USEC ? If not can add for readability and it doesn't cost
Great suggestions. Will do.
…On Fri., 4 Aug. 2017, 11:04 pm Roi Dayan, ***@***.***> wrote:
***@***.**** approved this pull request.
Beside my comment about definition s hta will add readability looks good
to me.
------------------------------
In src/IRrecv.cpp
<#294 (comment)>
:
> irparams.recvpin = recvpin;
irparams.bufsize = bufsize;
+ // Ensure we are going to be able to store all possible values in the
+ // capture buffer.
+ irparams.timeout = std::min(timeout, (uint8_t) (RAWTICK * UINT16_MAX / 1000));
I suggest to have a definition for the maximum allowed. I.e. MAX_TIMEOUT
------------------------------
In src/IRrecv.cpp
<#294 (comment)>
:
> irparams.recvpin = recvpin;
irparams.bufsize = bufsize;
+ // Ensure we are going to be able to store all possible values in the
+ // capture buffer.
+ irparams.timeout = std::min(timeout, (uint8_t) (RAWTICK * UINT16_MAX / 1000));
MAX_TIMEOUT_MS for consistency
------------------------------
In src/IRrecv.cpp
<#294 (comment)>
:
> DPRINTLN(")]");
// We really should never get a value of 0, except as the last value
// in the buffer. If that is the case, then assume infinity and return true.
if (measured == 0) return true;
- return measured >= ticksLow(std::min(desired, TIMEOUT_MS * 1000),
+ return measured >= ticksLow(std::min(desired,
+ (uint32_t) (irparams.timeout * 1000)),
Isn't there MS_TO_USEC ? If not can add for readability and it doesn't cost
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#294 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMInDM1Z-3wM1Fokvv6S_SqFnsamfF5Mks5sUxbAgaJpZM4OtYbT>
.
|
521ac2b
to
f7ce1f6
Compare
Changes done. |
src/IRrecv.h
Outdated
@@ -18,6 +18,7 @@ | |||
#define HEADER 2U // Usual nr. of header entries. | |||
#define FOOTER 2U // Usual nr. of footer (stop bits) entries. | |||
#define OFFSET_START 1U // Usual rawbuf entry to start processing from. | |||
#define MS_TO_USEC 1000U // Convert milli-Seconds to micro-Seconds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest here
#define MS_TO_USEC(x) (x *1000)
Then usage is
MS_TO_USEC(irparams.timeout)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even better ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (again).
f7ce1f6
to
050de44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good. Just asking if casting is redundant or causing warning if it's not there.
src/IRrecv.cpp
Outdated
@@ -427,17 +432,18 @@ bool IRrecv::matchAtLeast(uint32_t measured, uint32_t desired, | |||
DPRINT(". Matching: "); | |||
DPRINT(measured); | |||
DPRINT(" >= "); | |||
DPRINT(ticksLow(std::min(desired, TIMEOUT_MS * 1000), tolerance)); | |||
DPRINT(ticksLow(std::min(desired, (uint32_t) MS_TO_USEC(irparams.timeout)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't casting redundant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Lint and compiler error/warnings otherwise. The later parameter defaults to an int.
src/IRrecv.cpp
Outdated
return measured >= ticksLow(std::min(desired, TIMEOUT_MS * 1000), | ||
tolerance); | ||
return measured >= ticksLow( | ||
std::min(desired, (uint32_t) MS_TO_USEC(irparams.timeout)), tolerance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't casting redundant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Lint and compiler error/warnings otherwise. The later parameter defaults to an int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so all looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But now with the macro/function, it doesn't. So castings removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. 3rd time is the charm. I hope.
Ensure the timeout value won't allow a value larger than we can store.
050de44
to
48168c2
Compare
Ensure the timeout value won't allow a value larger than we can store.