From daf8382cf2bf82b800eae389f8ab7fff2aef9aea Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 30 Oct 2017 18:24:19 -0700 Subject: [PATCH] TMXR: Properly announce attach connection on serial lines when -V option is set --- sim_serial.c | 3 ++- sim_serial.h | 4 +++- sim_tmxr.c | 18 +++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sim_serial.c b/sim_serial.c index 2d1dc95a..5b76713c 100644 --- a/sim_serial.c +++ b/sim_serial.c @@ -1,6 +1,6 @@ /* sim_serial.c: OS-dependent serial port routines - Copyright (c) 2008, J. David Bryan + Copyright (c) 2008, J. David Bryan, Mark Pizzolato Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -27,6 +27,7 @@ UNIX-specific code and testing. 07-Oct-08 JDB [serial] Created file + 22-Apr-12 MP Adapted from code originally written by J. David Bryan This module provides OS-dependent routines to access serial ports on the host diff --git a/sim_serial.h b/sim_serial.h index caa6acf6..560d5da0 100644 --- a/sim_serial.h +++ b/sim_serial.h @@ -1,6 +1,6 @@ /* sim_serial.h: OS-dependent serial port routines header file - Copyright (c) 2008, J. David Bryan + Copyright (c) 2008, J. David Bryan, Mark Pizzolato Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -24,6 +24,8 @@ in this Software without prior written authorization from the author. 07-Oct-08 JDB [serial] Created file + 22-Apr-12 MP Adapted from code originally written by J. David Bryan + */ diff --git a/sim_tmxr.c b/sim_tmxr.c index 820763ff..25d9931a 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -697,10 +697,10 @@ if (lp->loopback) return loop_write (lp, &(lp->txb[i]), length); if (lp->serport) { /* serial port connection? */ - if (sim_gtime () < lp->txnexttime) + if ((sim_gtime () < lp->txnexttime) && (sim_is_running)) return 0; written = sim_write_serial (lp->serport, &(lp->txb[i]), length); - if (written > 0) + if ((written > 0) && (sim_is_running)) lp->txnexttime = floor (sim_gtime () + (written * lp->txdelta * sim_timer_inst_per_sec ())); return written; } @@ -2724,7 +2724,9 @@ while (*tptr) { sim_control_serial (lp->serport, TMXR_MDM_DTR|TMXR_MDM_RTS, 0, NULL); lp->cnms = sim_os_msec (); /* record time of connection */ if (sim_switches & SWMASK ('V')) { /* -V flag reports connection on port */ - sim_os_ms_sleep (TMXR_DTR_DROP_TIME); + sim_os_ms_sleep (TMXR_DTR_DROP_TIME); /* Wait for DTR to be noticed */ + lp->ser_connect_pending = FALSE; /* Mark line as ready for action */ + lp->conn = TRUE; tmxr_report_connection (mp, lp); /* report the connection to the line */ } } @@ -2833,7 +2835,9 @@ while (*tptr) { sim_control_serial (lp->serport, TMXR_MDM_DTR|TMXR_MDM_RTS, 0, NULL); lp->cnms = sim_os_msec (); /* record time of connection */ if (sim_switches & SWMASK ('V')) { /* -V flag reports connection on port */ - sim_os_ms_sleep (TMXR_DTR_DROP_TIME); + sim_os_ms_sleep (TMXR_DTR_DROP_TIME); /* Wait for DTR to be noticed */ + lp->ser_connect_pending = FALSE; /* Mark line as ready for action */ + lp->conn = TRUE; tmxr_report_connection (mp, lp); /* report the connection to the line */ } } @@ -3661,6 +3665,9 @@ t_stat tmxr_attach_ex (TMXR *mp, UNIT *uptr, CONST char *cptr, t_bool async) t_stat r; int32 i; +if (mp->dptr == NULL) /* has device been set? */ + mp->dptr = find_dev_from_unit (uptr); /* no, so set device now */ + r = tmxr_open_master (mp, cptr); /* open master socket */ if (r != SCPE_OK) /* error? */ return r; @@ -3681,9 +3688,6 @@ if (!async || (uptr->flags & TMUF_NOASYNCH)) /* if asynch disabled */ uptr->dynflags |= TMUF_NOASYNCH; /* tag as no asynch */ #endif -if (mp->dptr == NULL) /* has device been set? */ - mp->dptr = find_dev_from_unit (uptr); /* no, so set device now */ - if (mp->dptr) { for (i=0; ilines; i++) { mp->ldsc[i].expect.dptr = mp->dptr;