52 fprintf(stderr,
"Failed to initialise queue\n");
59 fprintf(stdout,
"Empty queue initialised: %d messages in queue\n", count);
62 fprintf(stderr,
"Incorrect item count for empty queue (expected 0, got %d)\n",
69 fprintf(stdout,
"Push initial message...\n");
72 fprintf(stderr,
"Unable to push item to queue\n");
81 fprintf(stderr,
"Incorrect item count (expected 1, got %d)\n", count);
87 if (out == NULL || out->
data.
value != 13.0) {
89 fprintf(stderr,
"Failed to retrieve initial test message\n.");
101 fprintf(stderr,
"Incorrect item count for empty queue (expected 0, got %d)\n",
108 fprintf(stdout,
"Push sequence of messages...\n");
111 fprintf(stderr,
"Unable to push item to queue\n");
112 perror(
"queue_push");
118 fprintf(stderr,
"Unable to push item to queue\n");
119 perror(
"queue_push");
125 fprintf(stderr,
"Unable to push item to queue\n");
126 perror(
"queue_push");
132 fprintf(stderr,
"Unable to push item to queue\n");
133 perror(
"queue_push");
139 fprintf(stderr,
"Unable to push item to queue\n");
140 perror(
"queue_push");
148 fprintf(stderr,
"Incorrect item count (expected 5, got %d)\n", count);
157 fprintf(stderr,
"Messages out of order? (Expected value %d, got %.0f)\n",
170 fprintf(stderr,
"Incorrect item count (expected 0, got %d)\n", count);
177 fprintf(stderr,
"Unable to push string message to queue");
193 fprintf(stderr,
"Failed to initialise queue\n");
194 perror(
"queue_init");
201 fprintf(stderr,
"Unable to push string message to queue");
208 fprintf(stderr,
"Unable to push string message to queue");
219 "Incorrect item count for destroyed queue (expected -1 [Error], "
229 fprintf(stderr,
"Gained an item from a destroyed queue!\n");
msg_t * msg_new_string(const uint8_t source, const uint8_t type, const size_t len, const char *str)
Create a new message with a single string embedded.
void msg_destroy(msg_t *msg)
Destroy a message.
msg_t * msg_new_float(const uint8_t source, const uint8_t type, const float val)
Create new message with a single numeric value.
int queue_count(const msgqueue *queue)
Iterate over queue and return current number of items.
bool queue_push(msgqueue *queue, msg_t *msg)
Add a message to the tail of the queue.
msg_t * queue_pop(msgqueue *queue)
Remove topmost item from the queue and return it, if queue is not empty.
void queue_destroy(msgqueue *queue)
Invalidate queue and destroy all contents.
bool queue_init(msgqueue *queue)
Ensure queue structure is set to known good values and marked valid.
msg_data_t data
Embedded data.
Represent a simple FIFO message queue.
char * data
Character array, should be null terminated.
string string
Single character array with length.
float value
Generic numerical data.