GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Jun-2009, 02:57
tenkasian tenkasian is offline
New Member
 
Join Date: Mar 2009
Posts: 4
tenkasian is on a distinguished road

Data structure for storing serial port data in firmware


I am sending data from a linux application through serial port to an embedded device.

In the current implementation a byte circular buffer is used in the firmware. (Nothing but an array with a read and write pointer)
As the bytes come in, it is written to the circular bufffer.

Now the PC application appears to be sending the data too fast for the firmware to handle. Bytes are missed resulting in the firmware returning WRONG_INPUT too mant times.

I think baud rate (115200) is not the issue. A more efficient data structure at the firmware side might help. Any suggestions on choice of data structure?

Thanks
  #2  
Old 15-Jun-2009, 07:12
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 226
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough
Thumbs down

Re: Data structure for storing serial port data in firmware


Quote:
Originally Posted by tenkasian
In the current implementation a byte circular buffer is used in the firmware. (Nothing but an array with a read and write pointer)
As the bytes come in, it is written to the circular bufffer.

No code, not much help. How are reads and writes synchronized?

Quote:
Originally Posted by tenkasian
Now the PC application appears to be sending the data too fast for the firmware to handle. Bytes are missed resulting in the firmware returning WRONG_INPUT too mant times.

Missing or being overwritten? Again, no code, not much help.

Quote:
Originally Posted by tenkasian
I think baud rate (115200) is not the issue. A more efficient data structure at the firmware side might help. Any suggestions on choice of data structure?

Really, how can we make any suggestions without at least seeing what it is you're trying to accomplish and whether or not you have "issues" with how you're implementing it?

There could be dozens of reasons as to what is going wrong. Also, you say "firmware," but what does that mean exactly? Is there some target microcontroller or microprocessor running other than the PC test model or whatever it was you called it?

Choice of data structure? You're getting bytes from a serial port, right? How can we possibly know what "data structure" would be a better choice without some notion of the organization of the data and/or expectations of how the data is to be processed or used by consumers in the system?

Are you assembling the data from bytes in to ordered sets of bytes? Are we seeing a mixture of bytes out of sequence?

You say that your current "data structure" is an array with a read and write pointer. Does that mean that there is one pointer that performs two roles at various intervals? Does it mean there are two pointers, one who reads and one who writes?

What method are you using to synchronize reads and writes? How can we tell whether or not your data structure is adequate, but your interactions (algorithms) for processing the data is adequate? How can we tell if your data "structure" is inadequate for the algorithmic interactions you wish to perform using the data?

What do we know of the data? Is it character data as in a text message or something? Is it binary data and you're transfering JPGs around or something?

What do we know about the transmission protocol used to move the data?

Maybe we should blindly guess for several hours until we magically hit upon it?

My first thought when I read your post (other than, this sucks without code) was that a flat array and a pointer (shared role) or dual pointers (split roles) is very unlikely "the" correct structure. An array and a pointer(s) is hardly what I'd call a "data structure." But, it may as well be, so going with it, one can only assume that if you're having problems with it:

Your interactions with the structure are the problem (algorithms)

Your combined implementation of algorithms and data structure are inappropriate for your intended usage.

Also, what does firmware mean in this case? Is it something living at the end of the wire connected to a PC UART? Why not give us some background info on what it is?

Is there some reason for the ambiguity? Why not just spew forth with all of the relevant information so that we can be of help? Oftentimes the mere process of putting together the information into a concise statement of the problem including supporting information allows for an "AH HA!" moment and you don't even need to click Submit Reply.

And, if you don't have the time to put together a decent statement of the problem and at least some relevant example code that shows your method of attacking the problem, then why should we spend any time trying to help you with it?

We're here to help. We want to help you. As many have said in the past, help us help you. Give us at least a fighting chance to make a recommendation by showing us what you've found that DOES NOT WORK...we may be able to fix it. At the very least, the combined talent here should be able to offer some very probable solution paths.


MxB
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory leak when nothing is happening... How can I even debug this ? Algar MS Visual C++ / MFC Forum 10 19-Nov-2007 08:17
Hard drive/CPU Diagnoses Issues binarybug Computer Hardware Forum 1 22-Jan-2007 20:23
Receiving data over serial port slippygod C++ Forum 1 03-Aug-2006 09:32
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 14:12
[CONTEST?]Data Structure Test dsmith C Programming Language 2 06-Jun-2004 16:13

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:08.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.