CAN Queue mechanism permitting creation and management of CAN messages through a queueing
CANQueue Class Reference
This is a simple queue mechanism for CANmsg messages. More...
#include <CANQueue.h>
Public Member Functions | |
CANQueue (int Size=3) | |
CANQueue constructor, which sets the queue size. | |
~CANQueue () | |
CANQueue destructor. | |
bool | Enqueue (CANmsg msg) |
Enqueue a new message into the queue. | |
bool | Enqueue (CANmsg *msg) |
Enqueue a new message into the queue. | |
bool | Dequeue (CANmsg *msg) |
Dequeue a message from the queue. | |
int | QueueCount () |
Gets the count of the number of items in the queue. | |
int | QueueMax () |
Get the maximum number of items that were ever in the queue. | |
int | QueueSize () |
Get the defined queue size. |
Detailed Description
This is a simple queue mechanism for CANmsg messages.
CANQueue is a circular queue that is designed for CAN messages. It can be used, for example, between a CAN receive interrupt and a background process to offload those received messages. In this way, the receive interrupt is light weight.
Definition at line 38 of file CANQueue.h.
Constructor & Destructor Documentation
CANQueue | ( | int | Size = 3 ) |
CANQueue constructor, which sets the queue size.
This sets the queue size and initializes the data elements
- Parameters:
-
Size is the size in entries for this queue
Definition at line 25 of file CANQueue.cpp.
~CANQueue | ( | ) |
Member Function Documentation
bool Dequeue | ( | CANmsg * | msg ) |
Dequeue a message from the queue.
If there is a message we'll copy it out to the callers message to which they provided the handle.
- Parameters:
-
msg is a pointer to the callers memory to copy the message into
- Returns:
- true if a message was dequeued
- false if the queue was empty
Definition at line 87 of file CANQueue.cpp.
bool Enqueue | ( | CANmsg * | msg ) |
Enqueue a new message into the queue.
If we enqueue until we overwrite the dequeue location, then we have lost the oldest message and must force the dequeue forward by one position.
- Parameters:
-
msg is the message to be enqueued
- Returns:
- true if no overwrite of the oldest message
- false if the oldest message was overwritten
Definition at line 64 of file CANQueue.cpp.
bool Enqueue | ( | CANmsg | msg ) |
Enqueue a new message into the queue.
If we enqueue until we overwrite the dequeue location, then we have lost the oldest message and must force the dequeue forward by one position.
- Parameters:
-
msg is the message to be enqueued
- Returns:
- true if no overwrite of the oldest message
- false if the oldest message was overwritten
Definition at line 42 of file CANQueue.cpp.
int QueueCount | ( | ) |
Gets the count of the number of items in the queue.
- Returns:
- number of queue entries
Definition at line 94 of file CANQueue.h.
int QueueMax | ( | ) |
Get the maximum number of items that were ever in the queue.
- Returns:
- maximum as the high water mark
Definition at line 100 of file CANQueue.h.
int QueueSize | ( | ) |
Get the defined queue size.
- Returns:
- size of the queue as defined
Definition at line 106 of file CANQueue.h.
Generated on Wed Jul 13 2022 01:23:29 by 1.7.2