PDA

View Full Version : ReadSerialPortx Questions


Nathan
01-26-2008, 02:01 PM
When the function ReadSerialPortx is called does it actually read from the serial port, or does it read a byte from the input circular buffer?

If the ReadSerialPortx function does read from the buffer, I'm assuming the data from the serial ports is automatically stuffed into these buffers? As in, I don't need to write a routine to fill the buffers with data?

And finally, how large are the input and output ring buffers? I need to know how fast I need to retrieve data from them so overwrites don't occur.

TIA,
Nathan

mluckham
01-27-2008, 09:19 PM
The WPILIB manual states that it reads from the ring buffer. We use this function (in EasyC) - you don't need to do anything, other than to read the port ... no need to initialize it, just read it. If there is nothing in the buffer when you read it, you get 0 (null) character as a return value.

You will need to message Brad Miller for your detailed question about buffer sizes and the time required for incoming data to over-fill the buffer. You shouldn't have a problem with fast incoming data rates if you continually read the serial port in your While(1) loop - which can execute as many as 60,000 times per second in our experience.

Nathan
01-29-2008, 08:25 PM
Thanks for the explanation mluckham.

Nathan