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

Give SerialNINAPassthrough flash rate 10x speedup #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions examples/Tools/SerialNINAPassthrough/SerialNINAPassthrough.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ unsigned long baud = 119400;
unsigned long baud = 115200;
#endif

#define BUFFER_SIZE 512
static unsigned int buffer_length;
static char buffer[BUFFER_SIZE];

int rts = -1;
int dtr = -1;

Expand Down Expand Up @@ -82,12 +86,16 @@ void loop() {
}
#endif

if (Serial.available()) {
SerialNina.write(Serial.read());
if (Serial.available() > 0) {
buffer_length = min(Serial.available(), BUFFER_SIZE);
Serial.readBytes(buffer, buffer_length);
SerialNina.write(buffer, buffer_length);
}

if (SerialNina.available()) {
Serial.write(SerialNina.read());
if (SerialNina.available() > 0) {
buffer_length = min(SerialNina.available(), BUFFER_SIZE);
SerialNina.readBytes(buffer, buffer_length);
Serial.write(buffer, buffer_length);
}

#ifndef ARDUINO_AVR_UNO_WIFI_REV2
Expand Down