Not polling PD [PlatformIO Arduino]
Describe the bug Using this library to build a Control Panel on the Arduino Uno R4 Renesas platform (using PlatformIO), the PD is never polled. I believe this applies to more platforms, likely including all embedded devices, but I'm not entirely sure of that.
Expected behavior The microcontroller would poll the reader every ~50ms
Observed behavior The microcontroller never polls the reader and thus never receives the message that a card was scanned, a keypad button was pressed, or any other event.
Additional context The cause of this issue is as follows:
osdp_cp.ccallsosdp_millis_since()to check whether it should pollosdp_millis_since()callsosdp_millis_now(), which callsmillis_now()which is defined ingoToMain/c-utilsmillis_now()callsusec_now(), which callsgettimeofday()- On (at least) this platform, the preprocessor condition
#elif defined(__BARE_METAL__)is met, meaninggettimeofday()is defined at line 167 as:
int gettimeofday(struct timeval * tp, struct timezone * tzp)
{
ARG_UNUSED(tzp);
tp->tv_sec = 0;
tp->tv_usec = 0;
return 0;
}
- As a result,
osdp_millis_since()is never aware that any time has passed, and thus the initial conditional never triggers aCMD_POLL.
@aaronjamt Thanks for the detailed issue description. There is a slight variation in call path when platformIO is used.
osdp_millis_now()is defined as a weak symbol.- For platformIO, there is a strong definition of that symbol which uses
mills(). - And we compile that file in platformIO so the weak symbol should be overridden.
So, we directly short circuit that path and should reach mills() earlier. I see your proposed solution in c-utils#34 also does something similar. Can you please try to look at why weak symbol resolution does not work for you?
I'm not very familiar with PlatformIO so I'm not entirely sure how to find the root cause, but I'll see if I can find anything.