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

Serial store & forward #448

Merged
merged 2 commits into from
Apr 8, 2020

Conversation

jnsbyr
Copy link
Contributor

@jnsbyr jnsbyr commented Apr 5, 2020

Activating a host stream write buffer (see #447) may result in unexpected behaviour: when receiving serial data with e.g. 9600 baud it may happen that without write buffers several received serial bytes where sent to the host in the same TCP frame but with write buffers each byte gets sent separately again, so nothing is gained.

The reason for this is quite simple: the host stream write buffer increases the Firmata performance and now the serial port can be polled faster than bytes are received. Even without a host stream write buffer this will happen anyway at lower baud rates.

This kind of fragmentation can be avoided by implementing a store & forward buffer for the incoming serial data. It can be globally activated and configured by defining an acceptable forwarding delay with

#define FIRMATA_SERIAL_RX_DELAY 50

in SerialFirmata.h.

- delay single byte reads to avoid single byte transfers
- explitly define Arduino constant SERIAL_RX_BUFFER_SIZE equivalent for ESP8266 platform
@jnsbyr jnsbyr changed the title Serial store &forward Serial store & forward Apr 5, 2020
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

Successfully merging this pull request may close these issues.

2 participants