From 67b7c86755e16dc0d64ca5ba6b4151df0d87096a Mon Sep 17 00:00:00 2001 From: joevt Date: Mon, 22 Aug 2022 03:24:21 -0700 Subject: [PATCH] serial backend socket fixes - increase delay to 800 consecutive characters (reduces times when Open Firmware throws away pasted text) - don't log the first sock read error (when accept hasn't been called yet) but do log sock read error if accept was called successfully already. --- devices/serial/chario.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/devices/serial/chario.cpp b/devices/serial/chario.cpp index 74f0f2b..c927fe3 100644 --- a/devices/serial/chario.cpp +++ b/devices/serial/chario.cpp @@ -340,7 +340,7 @@ bool CharIoSocket::rcv_char_available() if (consecutivechars >= 15) { consecutivechars++; - if (consecutivechars >= 400) + if (consecutivechars >= 800) consecutivechars = 0; return 0; } @@ -378,14 +378,19 @@ bool CharIoSocket::rcv_char_available() if (FD_ISSET(sockfd, &readfds)) { uint8_t c; int received = recv(sockfd, &c, 1, 0); - if (received == -1 && acceptfd != -1) { - LOG_F(INFO, "socket sock read err: %s", strerror(errno)); + if (received == -1) { + if (acceptfd == -1) { + //LOG_F(INFO, "socket sock read (not accepted yet) err: %s", strerror(errno)); // this happens once before accept + } + else { + LOG_F(INFO, "socket sock read err: %s", strerror(errno)); // should never happen + } } else if (received == 1) { - LOG_F(INFO, "socket sock read '%c'", c); + LOG_F(INFO, "socket sock read '%c'", c); // should never happen } else { - LOG_F(INFO, "socket sock read %d", received); + LOG_F(INFO, "socket sock read %d", received); // should never happen } if (acceptfd == -1) {