Skip to content

Commit daf8382

Browse files
committed
TMXR: Properly announce attach connection on serial lines when -V option is set
1 parent cb21246 commit daf8382

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

sim_serial.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* sim_serial.c: OS-dependent serial port routines
22
3-
Copyright (c) 2008, J. David Bryan
3+
Copyright (c) 2008, J. David Bryan, Mark Pizzolato
44
55
Permission is hereby granted, free of charge, to any person obtaining a
66
copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,7 @@
2727
UNIX-specific code and testing.
2828
2929
07-Oct-08 JDB [serial] Created file
30+
22-Apr-12 MP Adapted from code originally written by J. David Bryan
3031
3132
3233
This module provides OS-dependent routines to access serial ports on the host

sim_serial.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* sim_serial.h: OS-dependent serial port routines header file
22
3-
Copyright (c) 2008, J. David Bryan
3+
Copyright (c) 2008, J. David Bryan, Mark Pizzolato
44
55
Permission is hereby granted, free of charge, to any person obtaining a
66
copy of this software and associated documentation files (the "Software"),
@@ -24,6 +24,8 @@
2424
in this Software without prior written authorization from the author.
2525
2626
07-Oct-08 JDB [serial] Created file
27+
22-Apr-12 MP Adapted from code originally written by J. David Bryan
28+
2729
*/
2830

2931

sim_tmxr.c

+11-7
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,10 @@ if (lp->loopback)
697697
return loop_write (lp, &(lp->txb[i]), length);
698698

699699
if (lp->serport) { /* serial port connection? */
700-
if (sim_gtime () < lp->txnexttime)
700+
if ((sim_gtime () < lp->txnexttime) && (sim_is_running))
701701
return 0;
702702
written = sim_write_serial (lp->serport, &(lp->txb[i]), length);
703-
if (written > 0)
703+
if ((written > 0) && (sim_is_running))
704704
lp->txnexttime = floor (sim_gtime () + (written * lp->txdelta * sim_timer_inst_per_sec ()));
705705
return written;
706706
}
@@ -2724,7 +2724,9 @@ while (*tptr) {
27242724
sim_control_serial (lp->serport, TMXR_MDM_DTR|TMXR_MDM_RTS, 0, NULL);
27252725
lp->cnms = sim_os_msec (); /* record time of connection */
27262726
if (sim_switches & SWMASK ('V')) { /* -V flag reports connection on port */
2727-
sim_os_ms_sleep (TMXR_DTR_DROP_TIME);
2727+
sim_os_ms_sleep (TMXR_DTR_DROP_TIME); /* Wait for DTR to be noticed */
2728+
lp->ser_connect_pending = FALSE; /* Mark line as ready for action */
2729+
lp->conn = TRUE;
27282730
tmxr_report_connection (mp, lp); /* report the connection to the line */
27292731
}
27302732
}
@@ -2833,7 +2835,9 @@ while (*tptr) {
28332835
sim_control_serial (lp->serport, TMXR_MDM_DTR|TMXR_MDM_RTS, 0, NULL);
28342836
lp->cnms = sim_os_msec (); /* record time of connection */
28352837
if (sim_switches & SWMASK ('V')) { /* -V flag reports connection on port */
2836-
sim_os_ms_sleep (TMXR_DTR_DROP_TIME);
2838+
sim_os_ms_sleep (TMXR_DTR_DROP_TIME); /* Wait for DTR to be noticed */
2839+
lp->ser_connect_pending = FALSE; /* Mark line as ready for action */
2840+
lp->conn = TRUE;
28372841
tmxr_report_connection (mp, lp); /* report the connection to the line */
28382842
}
28392843
}
@@ -3661,6 +3665,9 @@ t_stat tmxr_attach_ex (TMXR *mp, UNIT *uptr, CONST char *cptr, t_bool async)
36613665
t_stat r;
36623666
int32 i;
36633667

3668+
if (mp->dptr == NULL) /* has device been set? */
3669+
mp->dptr = find_dev_from_unit (uptr); /* no, so set device now */
3670+
36643671
r = tmxr_open_master (mp, cptr); /* open master socket */
36653672
if (r != SCPE_OK) /* error? */
36663673
return r;
@@ -3681,9 +3688,6 @@ if (!async || (uptr->flags & TMUF_NOASYNCH)) /* if asynch disabled */
36813688
uptr->dynflags |= TMUF_NOASYNCH; /* tag as no asynch */
36823689
#endif
36833690

3684-
if (mp->dptr == NULL) /* has device been set? */
3685-
mp->dptr = find_dev_from_unit (uptr); /* no, so set device now */
3686-
36873691
if (mp->dptr) {
36883692
for (i=0; i<mp->lines; i++) {
36893693
mp->ldsc[i].expect.dptr = mp->dptr;

0 commit comments

Comments
 (0)