View Single Post
  #2   Spotlight this post!  
Unread 09-02-2008, 00:05
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Serial Port Interrupts

You need to treat the data from/to the serial port as a stream. Construct your code to process it one byte at a time, empty or not. Then you must make sure you read often enough that it is not possible to miss data. If you can't read it fast enough, slow the port down.

So look at the incoming stream, find the SOM char, buffer everything through the EOM char and finally pass the buffer to a function to handle the data. Check for overflows/underflows and invalid sequences while processing the stream. If you get any errors, toss the data and look for the next SOM char.

Check out Kevin's camera code for a good example.


HTH