I am using SerialBufferRK on monitor one to read in serial data from Serial1. After random amounts of time (sometimes a couple of hours, sometimes 20 minutes the available() function returns 0 despite serial data still being transmitted to it. It seems like maybe the thread is being cancelled but I am unsure how to tell if that is the case, here is my code:
#include "Particle.h"
#include "edge.h"
#include "SerialBufferRK.h"
#include <set>
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
SerialBuffer<12288> serBuf(Serial1);
STARTUP(
Edge::startup();
);
void setup() {
Serial1.begin(115200, SERIAL_8N1);
serBuf.setup();
serBuf.readClear();
Edge::instance().init();
}
void loop() {
if (serBuf.available() >= 24) {
std::string data;
while (serBuf.available() > 0) {
char c = serBuf.read();
if (c == '\n') break;
data+= c;
}
Edge::instance().loop();
}
The data is then published to particle in a set