FTSerial
Custom Arduino library for non-blocking serial reading. Use this on Rigby instead of Serial.readString() (which blocks your control loop).
Source: FT-Hardware/Code/Libraries/FTSerial/
Installation
- Copy
FTSerial/fromFT-Hardware/Code/Libraries/FTSerial/into~/Arduino/libraries/ - Restart the Arduino IDE
#include <FTSerial.h>
Quick Start
#include <FTSerial.h>
FTSerial ftSerial(Serial, 24); // serial port, buffer size in bytes
void setup() {
Serial.begin(115200);
}
void loop() {
float value;
if (ftSerial.readFloat(value)) {
// got a value
}
// control loop continues unblocked
}
Function
FTSerial(Stream &serial, byte bufferSize = 32)
bufferSize should fit your longest expected message.
String readUntilNewline()
\n-terminated line, or "" if not ready yet. Handles \r\n.
String readWithMarkers(char startMarker = '<', char endMarker = '>')
<steer,45.0>), or "" if not ready yet.
bool readFloat(float &result)
true and sets result on success. Note: invalid strings parse as 0.0.