use configurable length for buffer

This commit is contained in:
Nicu Hodos 2023-01-20 10:11:35 +01:00
parent 803f94fe63
commit 55d02cd4d0
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "SerialReader",
"version": "1.0.1",
"version": "1.0.0",
"description": "Helper class for reading Serial input, without blocking",
"repository":
{

View File

@ -2,8 +2,8 @@
#include <Arduino.h>
template <size_t bufferLength>
class SerialReader {
static const int bufferLength = 50;
char buffer[bufferLength];
public:
@ -12,8 +12,8 @@ public:
}
int readLine(HardwareSerial &serial) {
static int pos = 0;
int rpos;
static size_t pos = 0;
size_t rpos;
int readCh;
for (int i = 0, avail = serial.available(); i < avail && (readCh = serial.read()) > 0; i++) {