Skip to content

Commit

Permalink
set read timeout for serial reads
Browse files Browse the repository at this point in the history
more debugging

serial can't really do nonblock it seems / not implemented
  • Loading branch information
wiedehopf committed Sep 16, 2024
1 parent e6c2edb commit 17fac8d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 4 additions & 0 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -4438,6 +4438,10 @@ static int readClient(struct client *c, int64_t now) {
nread = recv(c->fd, c->buf + c->buflen, left, 0);
} else {
// read instead of recv for modesbeast / gns-hulc ....
if (Modes.debug_serial) {
fprintTimePrecise(stderr, now);
fprintf(stderr, " serial read ... fd: %d maxbytes: %d\n", c->fd, left);
}
nread = read(c->fd, c->buf + c->buflen, left);
if (Modes.debug_serial) {
fprintTimePrecise(stderr, now);
Expand Down
7 changes: 2 additions & 5 deletions sdr_beast.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ bool beastOpen(void) {
speed_t baud = B3000000;

int flags = O_RDWR | O_NOCTTY;
if (Modes.debug_serial) {
flags |= O_NONBLOCK;
}
Modes.beast_fd = open(Modes.beast_serial, flags);
if (Modes.beast_fd < 0) {
fprintf(stderr, "Failed to open serial device %s: %s\n",
Expand All @@ -157,8 +154,8 @@ bool beastOpen(void) {
tios.c_oflag = 0;
tios.c_lflag = 0;
tios.c_cflag = CS8 | CRTSCTS;
tios.c_cc[VMIN] = 11;
tios.c_cc[VTIME] = 0;
tios.c_cc[VMIN] = 11; // read returns when a minimum of 11 characters are available
tios.c_cc[VTIME] = 1; // 100 ms timeout for reads

if (Modes.sdr_type == SDR_GNS) {
baud = B921600;
Expand Down

0 comments on commit 17fac8d

Please sign in to comment.