Add baud rate setting and some minor changes

This commit is contained in:
Steffen Lange 2019-04-19 14:39:18 +02:00
parent 7e8ba61b04
commit 13ffe0c2c7
10 changed files with 52 additions and 18 deletions

View file

@ -1,6 +1,6 @@
#include "diygeiger.h"
int diy_open(const char *device) {
int diy_open(const char *device, speed_t baud) {
int fd = -1;
struct termios tio;
@ -10,7 +10,7 @@ int diy_open(const char *device) {
tio.c_cc[VTIME] = 5;
if ((fd = open(device, O_RDWR)) != -1) {
if (cfsetspeed(&tio, B9600) == 0) // 9600 baud
if (cfsetspeed(&tio, baud) == 0) // usually 9600 baud
if (tcsetattr(fd, TCSANOW, &tio) == 0)
// Return file descriptor,
return fd;