Skip to content

Issue with queue in No-OS driver #1

@THQ-WIFA

Description

@THQ-WIFA

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;
      //(...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions