Added separate debugging ability to trace line connect/disconnect activities to better debug virtual null modem cable activities.

This commit is contained in:
Mark Pizzolato 2013-05-06 07:50:09 -07:00
parent f8da94e001
commit 9faef6ea89
5 changed files with 49 additions and 11 deletions

View file

@ -242,6 +242,7 @@ TMXR dz_desc = { DZ_MUXES * DZ_LINES, 0, 0, NULL }; /* mux descriptor */
#define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */ #define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */
#define DBG_RCV TMXR_DBG_RCV /* display Received Data */ #define DBG_RCV TMXR_DBG_RCV /* display Received Data */
#define DBG_MDM TMXR_DBG_MDM /* display Modem Signals */ #define DBG_MDM TMXR_DBG_MDM /* display Modem Signals */
#define DBG_CON TMXR_DBG_CON /* display connection activities */
#define DBG_TRC TMXR_DBG_TRC /* display trace routine calls */ #define DBG_TRC TMXR_DBG_TRC /* display trace routine calls */
#define DBG_ASY TMXR_DBG_ASY /* display Asynchronous Activities */ #define DBG_ASY TMXR_DBG_ASY /* display Asynchronous Activities */
@ -251,6 +252,7 @@ DEBTAB dz_debug[] = {
{"XMT", DBG_XMT}, {"XMT", DBG_XMT},
{"RCV", DBG_RCV}, {"RCV", DBG_RCV},
{"MDM", DBG_MDM}, {"MDM", DBG_MDM},
{"CON", DBG_CON},
{"TRC", DBG_TRC}, {"TRC", DBG_TRC},
{"ASY", DBG_ASY}, {"ASY", DBG_ASY},
{0} {0}

View file

@ -305,6 +305,8 @@ static TMLX vh_parm[VH_MUXES * VH_LINES_ALLOC] = { { 0 } };
#define DBG_TRC TMXR_DBG_TRC /* trace routine calls */ #define DBG_TRC TMXR_DBG_TRC /* trace routine calls */
#define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */ #define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */
#define DBG_RCV TMXR_DBG_RCV /* display Received Data */ #define DBG_RCV TMXR_DBG_RCV /* display Received Data */
#define DBG_MDM TMXR_DBG_MDM /* display Modem Signals */
#define DBG_CON TMXR_DBG_CON /* display connection activities */
#define DBG_TRC TMXR_DBG_TRC /* display trace routine calls */ #define DBG_TRC TMXR_DBG_TRC /* display trace routine calls */
#define DBG_ASY TMXR_DBG_ASY /* display Asynchronous Activities */ #define DBG_ASY TMXR_DBG_ASY /* display Asynchronous Activities */
@ -314,6 +316,8 @@ DEBTAB vh_debug[] = {
{"TRC", DBG_TRC}, {"TRC", DBG_TRC},
{"XMT", DBG_XMT}, {"XMT", DBG_XMT},
{"RCV", DBG_RCV}, {"RCV", DBG_RCV},
{"MDM", DBG_MDM},
{"CON", DBG_CON},
{"TRC", DBG_TRC}, {"TRC", DBG_TRC},
{"ASY", DBG_ASY}, {"ASY", DBG_ASY},
{0} {0}

View file

@ -939,6 +939,10 @@ if (rbytes == SOCKET_ERROR) {
err = WSAGetLastError (); err = WSAGetLastError ();
if (err == WSAEWOULDBLOCK) /* no data */ if (err == WSAEWOULDBLOCK) /* no data */
return 0; return 0;
#if defined(EAGAIN)
if (err == EAGAIN) /* no data */
return 0;
#endif
if ((err != WSAETIMEDOUT) && /* expected errors after a connect failure */ if ((err != WSAETIMEDOUT) && /* expected errors after a connect failure */
(err != WSAEHOSTUNREACH) && (err != WSAEHOSTUNREACH) &&
(err != WSAECONNREFUSED)) (err != WSAECONNREFUSED))

View file

@ -816,7 +816,7 @@ if (mp->master) {
if (newsock != INVALID_SOCKET) { /* got a live one? */ if (newsock != INVALID_SOCKET) { /* got a live one? */
sprintf (msg, "tmxr_poll_conn() - Connection from %s", address); sprintf (msg, "tmxr_poll_conn() - Connection from %s", address);
tmxr_debug_trace (mp, msg); tmxr_debug_connect (mp, msg);
op = mp->lnorder; /* get line connection order list pointer */ op = mp->lnorder; /* get line connection order list pointer */
i = mp->lines; /* play it safe in case lines == 0 */ i = mp->lines; /* play it safe in case lines == 0 */
++mp->sessions; /* count the new session */ ++mp->sessions; /* count the new session */
@ -836,7 +836,7 @@ if (mp->master) {
if (i >= mp->lines) { /* all busy? */ if (i >= mp->lines) { /* all busy? */
tmxr_msg (newsock, "All connections busy\r\n"); tmxr_msg (newsock, "All connections busy\r\n");
tmxr_debug_trace (mp, "tmxr_poll_conn() - All connections busy"); tmxr_debug_connect (mp, "tmxr_poll_conn() - All connections busy");
sim_close_sock (newsock, 0); sim_close_sock (newsock, 0);
free (address); free (address);
} }
@ -872,8 +872,12 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se
lp->ipad = realloc (lp->ipad, 1+strlen (lp->destination)); lp->ipad = realloc (lp->ipad, 1+strlen (lp->destination));
strcpy (lp->ipad, lp->destination); strcpy (lp->ipad, lp->destination);
lp->cnms = sim_os_msec (); lp->cnms = sim_os_msec ();
sprintf (msg, "tmxr_poll_conn() - Line Connection to %s established", lp->destination);
tmxr_debug_connect_line (lp, msg);
break; break;
case -1: /* failed connection */ case -1: /* failed connection */
sprintf (msg, "tmxr_poll_conn() - Line Connection to %s failed", lp->destination);
tmxr_debug_connect_line (lp, msg);
tmxr_reset_ln (lp); /* retry */ tmxr_reset_ln (lp); /* retry */
break; break;
} }
@ -887,7 +891,7 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se
if (newsock != INVALID_SOCKET) { /* got a live one? */ if (newsock != INVALID_SOCKET) { /* got a live one? */
sprintf (msg, "tmxr_poll_conn() - Line Connection from %s", address); sprintf (msg, "tmxr_poll_conn() - Line Connection from %s", address);
tmxr_debug_trace_line (lp, msg); tmxr_debug_connect_line (lp, msg);
++mp->sessions; /* count the new session */ ++mp->sessions; /* count the new session */
if (lp->destination) { /* Virtual Null Modem Cable? */ if (lp->destination) { /* Virtual Null Modem Cable? */
@ -896,12 +900,14 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se
if (sim_parse_addr (lp->destination, host, sizeof(host), NULL, NULL, 0, NULL, address)) { if (sim_parse_addr (lp->destination, host, sizeof(host), NULL, NULL, 0, NULL, address)) {
tmxr_msg (newsock, "Rejecting connection from unexpected source\r\n"); tmxr_msg (newsock, "Rejecting connection from unexpected source\r\n");
sprintf (msg, "tmxr_poll_conn() - Rejecting line connection from: %s, Expected: %s", address, host); sprintf (msg, "tmxr_poll_conn() - Rejecting line connection from: %s, Expected: %s", address, host);
tmxr_debug_trace_line (lp, msg); tmxr_debug_connect_line (lp, msg);
sim_close_sock (newsock, 0); sim_close_sock (newsock, 0);
free (address); free (address);
continue; /* Move on to next line */ continue; /* Move on to next line */
} }
if (lp->connecting) { if (lp->connecting) {
sprintf (msg, "tmxr_poll_conn() - aborting outgoing line connection attempt to: %s", lp->destination);
tmxr_debug_connect_line (lp, msg);
sim_close_sock (lp->connecting, 0); /* abort our as yet unconnnected socket */ sim_close_sock (lp->connecting, 0); /* abort our as yet unconnnected socket */
lp->connecting = 0; lp->connecting = 0;
} }
@ -921,7 +927,7 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se
} }
else { else {
tmxr_msg (newsock, "Line connection busy\r\n"); tmxr_msg (newsock, "Line connection busy\r\n");
tmxr_debug_trace_line (lp, "tmxr_poll_conn() - Line connection busy"); tmxr_debug_connect_line (lp, "tmxr_poll_conn() - Line connection busy");
sim_close_sock (newsock, 0); sim_close_sock (newsock, 0);
free (address); free (address);
} }
@ -939,8 +945,11 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se
/* Check for needed outgoing connection initiation */ /* Check for needed outgoing connection initiation */
if (lp->destination && (!lp->sock) && (!lp->connecting) && (!lp->serport) && if (lp->destination && (!lp->sock) && (!lp->connecting) && (!lp->serport) &&
(!mp->modem_control || (lp->modembits & TMXR_MDM_DTR))) (!mp->modem_control || (lp->modembits & TMXR_MDM_DTR))) {
sprintf (msg, "tmxr_poll_conn() - establishing outgoing connection to: %s", lp->destination);
tmxr_debug_connect_line (lp, msg);
lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL); lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL);
}
} }
@ -958,6 +967,8 @@ return -1; /* no new connections ma
static t_stat tmxr_reset_ln_ex (TMLN *lp, t_bool closeserial) static t_stat tmxr_reset_ln_ex (TMLN *lp, t_bool closeserial)
{ {
char msg[512];
tmxr_debug_trace_line (lp, "tmxr_reset_ln_ex)"); tmxr_debug_trace_line (lp, "tmxr_reset_ln_ex)");
if (lp->txlog) if (lp->txlog)
@ -965,6 +976,9 @@ if (lp->txlog)
tmxr_send_buffered_data (lp); /* send any buffered data */ tmxr_send_buffered_data (lp); /* send any buffered data */
sprintf (msg, "tmxr_reset_ln_ex(%s)", closeserial ? "TRUE" : "FALSE");
tmxr_debug_connect_line (lp, msg);
if (lp->serport) { if (lp->serport) {
if (closeserial) { if (closeserial) {
sim_close_serial (lp->serport); sim_close_serial (lp->serport);
@ -995,11 +1009,16 @@ else /* Telnet connection */
free(lp->ipad); free(lp->ipad);
lp->ipad = NULL; lp->ipad = NULL;
if ((lp->destination) && (!lp->serport)) { if ((lp->destination) && (!lp->serport)) {
if (lp->connecting) if (lp->connecting) {
sim_close_sock (lp->connecting, 0); sim_close_sock (lp->connecting, 0);
if ((!lp->mp->modem_control) || (lp->modembits & TMXR_MDM_DTR)) lp->connecting = 0;
}
if ((!lp->mp->modem_control) || (lp->modembits & TMXR_MDM_DTR)) {
sprintf (msg, "tmxr_reset_ln_ex() - connecting to %s", lp->destination);
tmxr_debug_connect_line (lp, msg);
lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL); lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL);
} }
}
tmxr_init_line (lp); /* initialize line state */ tmxr_init_line (lp); /* initialize line state */
/* Revise the unit's connect string to reflect the current attachments */ /* Revise the unit's connect string to reflect the current attachments */
lp->mp->uptr->filename = _mux_attach_string (lp->mp->uptr->filename, lp->mp); lp->mp->uptr->filename = _mux_attach_string (lp->mp->uptr->filename, lp->mp);
@ -1012,6 +1031,7 @@ return SCPE_OK;
t_stat tmxr_close_ln (TMLN *lp) t_stat tmxr_close_ln (TMLN *lp)
{ {
tmxr_debug_trace_line (lp, "tmxr_close_ln()"); tmxr_debug_trace_line (lp, "tmxr_close_ln()");
tmxr_debug_connect_line (lp, "tmxr_close_ln()");
return tmxr_reset_ln_ex (lp, TRUE); return tmxr_reset_ln_ex (lp, TRUE);
} }
@ -1144,10 +1164,15 @@ if (lp->mp && lp->mp->modem_control) { /* This API ONLY works on mo
else { else {
if ((lp->destination) && /* Virtual Null Modem Cable */ if ((lp->destination) && /* Virtual Null Modem Cable */
((bits_to_set ^ before_modem_bits) & /* and DTR being Raised */ ((bits_to_set ^ before_modem_bits) & /* and DTR being Raised */
TMXR_MDM_DTR)) TMXR_MDM_DTR)) {
char msg[512];
sprintf (msg, "tmxr_set_get_modem_bits() - establishing outgoing connection to: %s", lp->destination);
tmxr_debug_connect_line (lp, msg);
lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL); lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL);
} }
} }
}
return SCPE_OK; return SCPE_OK;
} }
if (lp->serport) if (lp->serport)

View file

@ -69,8 +69,9 @@ typedef int SERHANDLE;
#define TMXR_DBG_XMT 0x010000 /* Debug Transmit Data */ #define TMXR_DBG_XMT 0x010000 /* Debug Transmit Data */
#define TMXR_DBG_RCV 0x020000 /* Debug Received Data */ #define TMXR_DBG_RCV 0x020000 /* Debug Received Data */
#define TMXR_DBG_MDM 0x040000 /* Debug Modem Signals */ #define TMXR_DBG_MDM 0x040000 /* Debug Modem Signals */
#define TMXR_DBG_ASY 0x080000 /* Debug Asynchronous Activities */ #define TMXR_DBG_CON 0x080000 /* Debug Connection Activities */
#define TMXR_DBG_TRC 0x100000 /* Debug trace routine calls */ #define TMXR_DBG_ASY 0x100000 /* Debug Asynchronous Activities */
#define TMXR_DBG_TRC 0x200000 /* Debug trace routine calls */
/* Modem Control Bits */ /* Modem Control Bits */
@ -202,6 +203,8 @@ extern FILE *sim_deb; /* debug file */
#define tmxr_debug(dbits, lp, msg, buf, bufsize) if (sim_deb && (lp)->mp->dptr && ((dbits) & (lp)->mp->dptr->dctrl)) _tmxr_debug (dbits, lp, msg, buf, bufsize); else (void)0 #define tmxr_debug(dbits, lp, msg, buf, bufsize) if (sim_deb && (lp)->mp->dptr && ((dbits) & (lp)->mp->dptr->dctrl)) _tmxr_debug (dbits, lp, msg, buf, bufsize); else (void)0
#define tmxr_debug_trace(mp, msg) if (sim_deb && (mp)->dptr && (TMXR_DBG_TRC & (mp)->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, mp->dptr, "%s\n", (msg)); else (void)0 #define tmxr_debug_trace(mp, msg) if (sim_deb && (mp)->dptr && (TMXR_DBG_TRC & (mp)->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, mp->dptr, "%s\n", (msg)); else (void)0
#define tmxr_debug_trace_line(lp, msg) if (sim_deb && (lp)->mp && (lp)->mp->dptr && (TMXR_DBG_TRC & (lp)->mp->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, (lp)->mp->dptr, "%s\n", (msg)); else (void)0 #define tmxr_debug_trace_line(lp, msg) if (sim_deb && (lp)->mp && (lp)->mp->dptr && (TMXR_DBG_TRC & (lp)->mp->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, (lp)->mp->dptr, "%s\n", (msg)); else (void)0
#define tmxr_debug_connect(mp, msg) if (sim_deb && (mp)->dptr && (TMXR_DBG_CON & (mp)->dptr->dctrl)) sim_debug (TMXR_DBG_CON, mp->dptr, "%s\n", (msg)); else (void)0
#define tmxr_debug_connect_line(lp, msg) if (sim_deb && (lp)->mp && (lp)->mp->dptr && (TMXR_DBG_CON & (lp)->mp->dptr->dctrl)) sim_debug (TMXR_DBG_CON, (lp)->mp->dptr, "%s\n", (msg)); else (void)0
#if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX) #if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX)
#define tmxr_attach(mp, uptr, cptr) tmxr_attach_ex(mp, uptr, cptr, TRUE) #define tmxr_attach(mp, uptr, cptr) tmxr_attach_ex(mp, uptr, cptr, TRUE)