overflowing the array serial buffer

Hi,
I am putting together a project that will send the following data

c1:255,c2:123,c3:123,c4:123,c5:123,c6:213,c7:255,c8:123,c9:123,c10:123,c11:123,c12:213,c13:255,c14:123,c15:123,c16:123,c17:123,c18:213,c19:255,c20:123,c21:123,c22:123,c23:123,c24:213

i am doing this over serial and i am currently working out the parsing, but something has just struck me. Will i be overflowing the buffer??? If so how can i send these values to the arduino from a pi using python? Is there a work around?

Thanks
Josh

but something has just struck me.

Probably a good idea. Don't let it get away.

Will i be overflowing the buffer???

I've got a boat with a leak (serial data coming in). I've got a bucket to bail with (Serial.read()). Will my boat sink?

As you might imagine, the size of the leak and the size of the bucket and the time between scooping and dumping the bailing bucket is going to have a huge impact on whether my boat sinks (my buffer overflows).

If so how can i send these values to the arduino from a pi using python? Is there a work around?

Bail faster.

If you're using the Uno, you have a 64 byte buffer. So you need to ensure that your arduino code consumes the data quickly enough to ovoid overflow. Since serial data transfer is glacially slow in arduino terms, that shouldn't be a problem unless you're using a lot of delay() in your code.

If you have other time consuming things going on, make sure that your serial parsing routine gets frequent chances to service the buffer.

Brilliant thanks, when you say service the buffer do you mean using the serial.flush()?

No. Serial.Read(). You just need to ensure that you're reading, parsing and using the data faster than it's coming in, per PaulS' bailing analogy.

If you have a problem with speed, you can always make adjustments to the sending program to slow it down. At this point though, just be mindful of the fact that you need to be careful about delays. Worry about the overflow issue if it actually arises.

Brilliant thanks, when you say service the buffer do you mean using the serial.flush()?

Serial.flush() blocks until the outgoing serial buffer is empty. I'm not sure how calling ANY blocking function is going to help you bail faster. That's a bit like throwing to bucket overboard and having to row after it each time.

Apparently, you need a new boat, and are willing to let this one sink.

If the incoming data stream is always a constant number of bytes, you could go to:

C:\ArduinoHome\hardware\arduino\cores\arduino\HardwareSerial.cpp

where ArduinoHome is your install directory for the IDE and change the size of the serial buffer from 64 to whatever you need. Look for:

  #define SERIAL_BUFFER_SIZE 64

in the code, around line 59. Messing around with the core files is a little risky, but, like they say, if your only tool is a hammer, every problem looks like a nail.

PaulS:
That's a bit like throwing to bucket overboard and having to row after it each time.

]:smiley: