AmendHub

Download:

jcs

/

subtext

/

amendments

/

242

serial: Cope with not getting the beginning of the CONNECT line


jcs made amendment 242 about 1 year ago
--- serial.c Mon Jul 18 17:28:20 2022 +++ serial.c Sat Aug 13 13:15:00 2022 @@ -285,8 +285,7 @@ maybe_read: if (serial_input_buf_len < sizeof(serial_input_buf)) { SerGetBuf(serial_in_refnum, &len); if (len) { - len = MIN(len, - sizeof(serial_input_buf) - serial_input_buf_len); + len = MIN(len, sizeof(serial_input_buf) - serial_input_buf_len); FSRead(serial_in_refnum, &len, serial_input_buf + serial_input_buf_len); serial_input_buf[serial_input_buf_len + len] = '\0'; @@ -415,6 +414,7 @@ serial_idle(void) break; } case SERIAL_STATE_ANSWERED: { + char *connect; long baud; /* optimistic :) */ short count; @@ -429,12 +429,13 @@ serial_idle(void) if ((line = serial_get_line(false)) == NULL) break; - if (strstr(line, "CONNECT ") != NULL) { + /* sometimes we don't get the beginning of CONNECT */ + if ((connect = strstr(line, "NECT ")) != NULL) { the_serial_node.state = SERIAL_STATE_CONNECTED; - if (sscanf(line, "CONNECT %ld/%n", &baud, &count) == 1 && + if (sscanf(connect, "NECT %ld/%n", &baud, &count) == 1 && count > 0) - the_serial_node.session->tspeed = baud; + the_serial_node.session->tspeed = baud; } break;