I was trying to schedule a work item when a struct k_poll_signal is raised by an interrupt, but was unable to get the work to happen. I could tell that the k_work_poll_submit function was completing without error (0), same for k_poll_signal_raise.
So I have the following relevant data, and initialized:
typedef struct { ... struct { struct k_poll_signal UTCDone; } PollSignals; ... struct k_work_poll UTCReadWork; } AppStatus_t; AppStatus_t AppStatus; struct k_poll_event UTCEvents[1]; void APP_Init(void) { ... k_work_poll_init(&AppStatus.UTCReadWork, SendUTCToLT); k_poll_signal_init(&AppStatus.PollSignals.UTCDone); k_poll_event_init(&UTCEvents[1], K_POLL_TYPE_SIGNAL,K_POLL_MODE_NOTIFY_ONLY, &AppStatus.PollSignals.UTCDone); ... }
The following functions modify these structures. App_ScheduleUTCResponse is called from I2C Slave interrupt if the I2C master has requested the UTC time before it is ready. APP_RegisterUTCData is called when a date time event occurs, and it is not of DATE_TIME_NOT_OBTAINED type.
void App_ScheduleUTCResponse(void) { int err = k_work_poll_submit(&AppStatus.UTCReadWork, UTCEvents, 1, K_FOREVER); printk("Poll Submit Error: %d\n", err); } void SendUTCToLT(struct k_work *work) { FillUTCBuffer(true); printk("BufferFilled\n"); //k_poll_signal_reset(&AppStatus.PollSignals.UTCDone); } void APP_RegisterUTCData(void) { int64_t utc; int err = k_poll_signal_raise(&AppStatus.PollSignals.UTCDone, 0); printk("Poll Signal Err: %d\n", err); AppStatus.StateFlags.UTCDataReady = true; date_time_now(&utc); utc /= 1000; CheckGeoDataStale(utc); time_t rawtime = utc; struct tm *timesplit; timesplit = localtime(&rawtime); printk("Datetime: %s", asctime(timesplit)); }
I see the "Poll Submit Error: 0" message on the UART, and the "Poll Raised Error: 0" message follows the DATE_TIME_OBTAINED_NTP event message. However the work callback function does not get called at all as far as I can tell.
I had a few different configurations before, but they caused system faults of some kind or another. This one doesn't result in any faults, but it doesn't finish the loop. I assume I'm just doing something wrong with the moderately opaque apis, but I have no idea what.
Any help is appreciated!