libosdp icon indicating copy to clipboard operation
libosdp copied to clipboard

Not polling PD [PlatformIO Arduino]

Open aaronjamt opened this issue 1 month ago • 2 comments

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:

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 a CMD_POLL.

aaronjamt avatar Nov 14 '25 03:11 aaronjamt

@aaronjamt Thanks for the detailed issue description. There is a slight variation in call path when platformIO is used.

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?

sidcha avatar Nov 26 '25 16:11 sidcha

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.

aaronjamt avatar Dec 07 '25 06:12 aaronjamt