Skip to content
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

Issue with queue in No-OS driver #1

Open
THQ-WIFA opened this issue Aug 15, 2023 · 0 comments
Open

Issue with queue in No-OS driver #1

THQ-WIFA opened this issue Aug 15, 2023 · 0 comments

Comments

@THQ-WIFA
Copy link

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;
      //(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant