usart speedup

This commit is contained in:
Tristan Krause 2019-03-27 11:45:14 +01:00
parent 8bf9cfe00d
commit 3473057f98
4 changed files with 4 additions and 4 deletions

View file

@ -10,7 +10,7 @@ void B15F::init()
{
std::cout << PRE << "Stelle Verbindung mit Adapter her... " << std::flush;
int code = system(std::string("stty 38400 -F " + SERIAL_DEVICE).c_str());
int code = system(std::string("stty " + std::to_string(BAUDRATE) + " -F " + SERIAL_DEVICE).c_str());
if(code)
{
throw DriverException("Konnte serielle Verbindung nicht initialisieren. Ist der Adapter angeschlossen?");
@ -19,11 +19,11 @@ void B15F::init()
usart = open(SERIAL_DEVICE.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
struct termios options;
tcgetattr(usart, &options);
options.c_cflag = baudrate | CS8 | CLOCAL | CREAD;
options.c_iflag = IGNPAR;
options.c_oflag = 0;
options.c_lflag = 0;
options.c_cc[VTIME]=30;
options.c_cc[VTIME]=1; // timeout in Dezisekunden
cfsetspeed(&options, BAUDRATE);
tcsetattr(usart, TCSANOW, &options);
tcflush(usart, TCIFLUSH);

View file

@ -49,7 +49,6 @@ public:
private:
int usart = -1;
uint32_t baudrate = 38400;
uint16_t timeout = 1000;
static B15F* instance;
@ -61,6 +60,7 @@ private:
constexpr static uint8_t MSG_FAIL = 0xFE;
constexpr static uint16_t RECONNECT_TIMEOUT = 32; // ms
constexpr static uint8_t RECONNECT_TRIES = 3;
constexpr static uint32_t BAUDRATE = 115200;
// REQUESTS
constexpr static uint8_t RQ_DISC = 0;

Binary file not shown.

BIN
main

Binary file not shown.