change speed in serial filer

This commit is contained in:
Stephen Crane 2019-02-14 07:58:51 +00:00
parent 6a929aedbe
commit 1f64b85b17
2 changed files with 18 additions and 6 deletions

View File

@ -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) {

View File

@ -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();