-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
I found that the queue implementation in [uC-Modbus 2.14.00: OS/None/mb_os.c](https://github.com/weston-embedded/uC-Modbus/blob/develop/OS/None/mb_os.c commit fdd1218) is broken. It will point to the wrong entry in the storage table.
I could fix it within the initialization function MB_OS_Q_Create(...):
p_q->OS_Q_LastEntry = max_entries-1;
instead of
p_q->OS_Q_LastEntry = 0;
This is because OS_Q_LastEntry will be incremented (with rollover) in MB_OS_Q_Post(...) before using it as index within the storage table:
//(...)
p_q->OS_Q_Entries++;
if (p_q->OS_Q_LastEntry == (p_q->OS_Q_MaxEntries - 1)) {
p_q->OS_Q_LastEntry = 0;
} else {
p_q->OS_Q_LastEntry++;
}
p_sto[p_q->OS_Q_LastEntry] = p_msg;
//(...)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels