* A general FIFO queue component, whose queue has a bounded size.
*
* @author Philip Levis
+ * @author Geoffrey Mainland
* @date $Date$
*/
implementation {
- queue_t queue[QUEUE_SIZE];
+ queue_t ONE_NOK queue[QUEUE_SIZE];
uint8_t head = 0;
uint8_t tail = 0;
uint8_t size = 0;
dbg("QueueC", "%s: size is %hhu\n", __FUNCTION__, size);
if (!call Queue.empty()) {
head++;
- head %= QUEUE_SIZE;
+ if (head == QUEUE_SIZE) head = 0;
size--;
printQueue();
}
dbg("QueueC", "%s: size is %hhu\n", __FUNCTION__, size);
queue[tail] = newVal;
tail++;
- tail %= QUEUE_SIZE;
+ if (tail == QUEUE_SIZE) tail = 0;
size++;
printQueue();
return SUCCESS;
command queue_t Queue.element(uint8_t idx) {
idx += head;
- idx %= QUEUE_SIZE;
+ if (idx >= QUEUE_SIZE) {
+ idx -= QUEUE_SIZE;
+ }
return queue[idx];
}