Fastest way to read serial data

I have a device connected via RS485 to my Arduino Uno. 54 bytes of data is sent three times a second, possibly faster. What is the fastest way I can read this data so that no data is lost?

Read it at a faster rate? Arduino will do 115200 as a standard rate, and I think 230,400 also, tho I've not tried it that fast.

162 bytes/second is only 1620 bits/second, even 9600 as a data rate should handle that.

Baud rate is fixed at 9600. What I'm talking about is remove data from the buffer fast enough to not miss next incoming data. Do I just use Serial.read() or is Serial.readBytes() faster? Thats what I'm looking for.

Do I just use Serial.read() or is Serial.readBytes() faster? Thats what I'm looking for.

You can only read one byte at a time, as Serial.read() does. The Serial.readBytes() method calls Serial.read(), so it doesn't speed things up.

I suppose that is my issue. I feel like I am losing data. Seems like the time it takes me to read a full buffer one byte at a time I am missing some of the next set of incoming data as its arriving before I completed reading the buffer. I guess the clock speed is my limiting factor.

Post your code. I bet you have some inefficiences that are slowing you down. As a comparison: I sample 8 12-bit ADCs, one every 5 mS, and send the 2 bytes data out with a sync byte, an 'address' byte, and another byte that is the level of 4 pins, at 115,200 to another arduino, which writes it into 8 12 bit DACs. So 5 bytes every 5mS. 1 byte every 5mS is 200 bytes/sec, 4 bytes is 1000 bytes/sec.

9600 bps is about 872 bytes per second (start bit, 8 data bits, stop bit, maybe 1 more bit of 'off' time, so 11 bits/byte). That's 1 byte every 1147microseconds. You should be able to send your 54 bytes 14 times per second and still not lose any info.

sabregreen: I suppose that is my issue. I feel like I am losing data. Seems like the time it takes me to read a full buffer one byte at a time I am missing some of the next set of incoming data as its arriving before I completed reading the buffer. I guess the clock speed is my limiting factor.

The serial port has a 128b buffer on the receive side code so your talking about 5/6th of a second worth of buffer at your 56b 3 times a second. You can change this in wiring_seria.c if really needed to make a bigger ring buffer. At 9600 baud your looking at a couple percent of the CPU time if the serial line was maxed out so the question becomes what are you doing with the other 98% that would cause the ring buffer to overflow? Are you messing around with interrupts?

The serial port has a 128b buffer on the receive side code

The serial buffer is 64 (in some cases even only 16) bytes, your information must be from an old IDE because the relevant code is in HardwareSerial.cpp, wiring_serial.c doesn’t exist (anymore).

But you’re right, that the processor is more than fast enough to get that bit of data from the serial buffer at 9600 baud. If the CPU is doing lots of processing with that little data it might get to a problem but this is usually solved by optimising the code.