diff --git a/serial_filer.cpp b/serial_filer.cpp index 4902719..8cca66e 100644 --- a/serial_filer.cpp +++ b/serial_filer.cpp @@ -6,12 +6,22 @@ #include "serial_filer.h" bool serial_filer::start(const char *) { -#if defined(TERM_SPEED) - Serial.begin(TERM_SPEED); return true; -#else - return false; -#endif +} + +const unsigned speeds[] = { + 115200, 57600, 19200, 9600, 4800, 2400 +}; +static unsigned currsp; + +const char *serial_filer::advance() { + static char buf[16]; + unsigned s = speeds[currsp]; + Serial.begin(s); + currsp++; + if (currsp == sizeof(speeds)/sizeof(speeds[0])) + currsp = 0; + return itoa(s, buf, 10); } void serial_filer::write(uint8_t b) { diff --git a/serial_filer.h b/serial_filer.h index 36a5e29..1db421a 100644 --- a/serial_filer.h +++ b/serial_filer.h @@ -1,9 +1,11 @@ #ifndef __SERIAL_FILER_H__ #define __SERIAL_FILER_H__ +// see https://playground.arduino.cc/Interfacing/LinuxTTY +// FIXME: do this in minicom config file class serial_filer: public filer { public: - const char *advance() { return "serial"; } + const char *advance(); const char *rewind() { return advance(); } const char *checkpoint();