AmendHub

Download:

jcs

/

subtext

/

amendments

/

565

serial: Nullify session on init, catch init string errors

This allows the init string to not have ATQ0, which we now do by
default so if the init string is later changed and produces an
ERROR response, we will log it.
 
Also nullify the serial node session on init, which will happen
after forced hangup. Otherwise we may have been keeping the
association of the serial node's session and disconnecting it
on forced hangup, even if that session was later reassigned to
another node.

jcs made amendment 565 5 months ago
--- db.c Thu Nov 9 09:07:14 2023 +++ db.c Mon Nov 27 20:44:33 2023 @@ -368,7 +368,7 @@ db_migrate(struct db *tdb, short is_new, Str255 fullpa sprintf(tdb->config.hostname, "bbs.example.com"); sprintf(tdb->config.timezone, "CT"); tdb->config.modem_speed = 9600; - sprintf(tdb->config.modem_init, "ATQ0V1S0=2&D2"); + sprintf(tdb->config.modem_init, "ATV1S0=2&D2"); sprintf(tdb->config.modem_parity, "8N1"); tdb->config.modem_rings = 1; tdb->config.max_idle_minutes = 5; --- serial.c Tue Nov 14 17:52:03 2023 +++ serial.c Mon Nov 27 19:43:22 2023 @@ -223,8 +223,13 @@ serial_init(void) /* initialize */ serial_printf("%s\r", db->config.modem_init); Delay(TICKS_PER_SEC, &m); + resp = serial_get_line(false); + if (!resp || (resp[0] != 'O' || resp[1] != 'K')) + logger_printf("[modem] Bad response to init: \"%s\"", + resp == NULL ? "" : resp); serial_flush(); + the_serial_node.session = NULL; the_serial_node.state = SERIAL_STATE_IDLE; the_serial_node.answered_at = 0; @@ -263,7 +268,7 @@ serial_hangup(void) Delay(TICKS_PER_SEC * 1, &m); /* assert DTR */ Control(serial_out_refnum, 17, NULL); - + if (the_serial_node.session != NULL) the_serial_node.session->ending = true; }