473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

FIFO Queue questions

1
Hi all,

I'm using the PICC CCS C compiler and am having issues with starting an enque/deque for my program. What I need it to do is to hold about 9 data packets, each packet is an array of 4 HEX integers. Each array is a different command for the program.

example of array commands:
Expand|Select|Wrap|Line Numbers
  1.    int ph[4] = {0x18, 0x2B, 0x00, 0x00}; 
  2.    int zt[4] = {0x28, 0x35, 0x00, 0x00};   
  3.    int zw[4] = {0x28, 0x37, 0x00, 0x00};   
  4.    int af[4] = {0x28, 0x41, 0x00, 0x00};     
  5.    int off[4] = {0x18, 0x5E, 0x00, 0x00};     

From what I understand, I need an enque() function that will store up to 9 packets (or more depending on how large the program gets) and then a deque() function that will spill them out in a FIFO style. Is that correct? Below is what I've started, but I'm not sure if I'm headed in the right direction:


Expand|Select|Wrap|Line Numbers
  1. typedef struct
  2. {
  3.   int front;         //location of front of queue
  4.   int rear;         //location of rear of queue
  5.   int max_size;    //queue can hold 9 packets
  6.   int packet[9][10];    //make sure queue is large enough
  7. } queue;
  8.  
  9. typedef struct
  10. {
  11.   int packet[9][10];            //make sure queue is large enough
  12. } packet;
  13.  
  14. //add to front of queue, stack on top
  15. int1 enqueue (queue *working_queue ,packet *packets[]) //bring in que & packet to load
  16. {
  17.   working_queue.front++;                         //increas front by one
  18.   if (working_queue.front > working_queue.max_size) //if at end, loop around and write over old packets
  19.   {
  20.     working_queue.front = 0;
  21.   }
  22.   memcpy(working_queue.packet[working_queue.front], packets.packet[0], sizeof(working_queue.packet)); //copies packet to struct
  23.   return 0;
  24. }
Please help, if any more info is needed, I'd be happy to supply it.



K
Dec 5 '07 #1
0 1728

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Luca | last post by:
I have the need of a container of integers showing both the characteristics of an associative container (all integer elements different from each other) and the FIFO behaviour. Do you know if...
2
by: worli | last post by:
Hi All, I have a strange requirement. I have a dynamic input numeric data stream e.g. 2, 2, 4, 5 etc.... ( each input number range from 1 to 10 ). lets take a simple case where all inputs will...
2
by: Michele Moccia | last post by:
How can I implement a "time critical" fifo in c++ ? I just have to manage sequences of raw bytes, no user defined types. An std::queue<unsigned char> or std::deque<unsigned char> seems to be slow....
8
by: Jack | last post by:
I want to implement a fixed-size FIFO queue for characters. I only want to use array not linked list. For example, const int N = 10; char c_array; The question is when the queue is full,...
5
by: Dinsdale | last post by:
I have an application that recieves text data via external input (i.e. serial) and displays it on the screen (we use carraige return as a delimiter). At this point I use a regular old text box and...
4
by: David Bear | last post by:
I'm looking to see if there are any examples or prewritting fifo queue classes. I know this is a broad topic. I'm looking to implement a simple application where a web server enqueue and pickle...
4
by: drochom | last post by:
hi, how would u improve this code? class queue: def __init__(self, size=8): self.space = size self.data = *self.space self.head = 0 self.tail = 0
2
by: Spoon | last post by:
Hello, I'm wondering whether the STL defines a data structure with the following features: o provides push_front() and pop_back() (like std::list) to implement a FIFO buffer. o allows fast...
5
by: akenato | last post by:
Hi for me this is th first time that I use c++. I have to do this exercise. Somebody can help me? Thanx. Implement a FIFO-queue ( first in, first out ) as a ring buffer. Use a static array as the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.