Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider increasing serial receive buffer size #14

Open
kierdavis opened this issue Mar 1, 2018 · 4 comments
Open

Consider increasing serial receive buffer size #14

kierdavis opened this issue Mar 1, 2018 · 4 comments

Comments

@kierdavis
Copy link
Member

If this buffer gets full then incoming bytes are discarded until space is free in the buffer again, which may account for some of our serial communication issues. The default size is a mere 16 bytes.

This can be implemented by adding a compiler flag. For example, to set the buffer size to 256 bytes, you can pass -DSERIAL_RX_BUFFER_SIZE=256.

The reason why I'm holding off making the change right now is that we're currently very memory-hungry already and I get the impression that we're pushing the limits of the microcontroller's SRAM capacity. Increasing the amount of SRAM dedicated to the serial buffer will almost certainly worsen the situation, so we should fix those issues first (I'm slowly working out a good way to approach this).

@mxbi
Copy link

mxbi commented Mar 15, 2018

@kierdavis Where can I try putting this compile flag when building the arduino sketch? I think we have enough SRAM available.

Right now about 75% of our team's time has probably been spent wrestling with the arduino (using it for GPIO) - it almost always falls over within a few minutes (BlockingIOError, connection never happens, CommandError showing commands which we never sent, various others) and we have to restart everything and try again. Any suggestions on how to improve the stability would be much appreciated.

@RealOrangeOne
Copy link
Member

With my limited knowledge of C++, you should just be able to add #define SERIAL_RX_BUFFER_SIZE 256 underneath the arduino header imports.

@kierdavis
Copy link
Member Author

Unfortunately it's not quite as simple as that. This constant needs to be defined when the arduino standard library is compiled, so you can't just put it in your own source file.

The easiest way is to add -DSERIAL_RX_BUFFER_SIZE=xxx to the global compiler flags; how this is done is dependent on what software you're using to compile the sketch. I don't know how one would do this using the Arduino IDE (assuming that's what you're using), or even if it's possible at all.

@trickeydan
Copy link
Contributor

We can do this in the board definition: http://www.hobbytronics.co.uk/arduino-serial-buffer-size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants