From 0a7c9de1e1757d3d74ab2ada839c75a7f01e88b7 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Wed, 13 Jun 2018 04:51:34 -0700 Subject: [PATCH] TMXR: Change rx and tx delta values to be usecs including the speed factor --- 3B2/3b2_iu.c | 2 +- 3B2/3b2_ports.c | 4 ++-- PDP11/pdp11_dz.c | 2 +- sim_console.c | 6 +++--- sim_tmxr.c | 42 +++++++++++++++++++++--------------------- sim_tmxr.h | 6 +++--- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/3B2/3b2_iu.c b/3B2/3b2_iu.c index 7cc4c8ea..eacb1e11 100644 --- a/3B2/3b2_iu.c +++ b/3B2/3b2_iu.c @@ -728,7 +728,7 @@ void iu_write(uint32 pa, uint32 val, size_t size) break; case THRB: /* TX/RX Buf B */ iu_tx(PORT_B, bval); - sim_activate_abs(contty_xmt_unit, contty_ldsc[0].txdelta); + sim_activate_abs(contty_xmt_unit, contty_ldsc[0].txdeltausecs); break; case OPCR: iu_state.opcr = bval; diff --git a/3B2/3b2_ports.c b/3B2/3b2_ports.c index 90506ca0..fc388210 100644 --- a/3B2/3b2_ports.c +++ b/3B2/3b2_ports.c @@ -762,7 +762,7 @@ t_stat ports_xmt_svc(UNIT *uptr) (ports_state[ln].oflag & ONLCR) && !(ports_state[ln].crlf)) { if (tmxr_putc_ln(&ports_ldsc[ln], 0xd) == SCPE_OK) { - wait = MIN(wait, ports_ldsc[ln].txdelta); + wait = MIN(wait, ports_ldsc[ln].txdeltausecs); sim_debug(IO_DBG, &ports_dev, "[%08x] [ports_xmt_svc] [LINE %d] XMIT (crlf): %02x (%c)\n", R[NUM_PC], ln, 0xd, 0xd); @@ -776,7 +776,7 @@ t_stat ports_xmt_svc(UNIT *uptr) ports_state[ln].crlf = FALSE; if (tmxr_putc_ln(&ports_ldsc[ln], c) == SCPE_OK) { - wait = MIN(wait, ports_ldsc[ln].txdelta); + wait = MIN(wait, ports_ldsc[ln].txdeltausecs); ports_state[ln].tx_chars--; ports_state[ln].tx_addr++; sim_debug(IO_DBG, &ports_dev, diff --git a/PDP11/pdp11_dz.c b/PDP11/pdp11_dz.c index 633ead5d..c9e7ddad 100644 --- a/PDP11/pdp11_dz.c +++ b/PDP11/pdp11_dz.c @@ -536,7 +536,7 @@ switch ((PA >> 1) & 03) { /* case on PA<2:1> */ if (c >= 0) { /* store char */ tmxr_putc_ln (lp, c); dz_update_xmti (); - sim_activate_after_abs (&dz_unit[1], lp->txdelta);/* */ + sim_activate_after_abs (&dz_unit[1], lp->txdeltausecs); } } break; diff --git a/sim_console.c b/sim_console.c index 8459d985..aa10ba60 100644 --- a/sim_console.c +++ b/sim_console.c @@ -2155,8 +2155,8 @@ t_stat sim_show_cons_speed (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONS { if (sim_con_ldsc.rxbps) { fprintf (st, "Speed = %d", sim_con_ldsc.rxbps); - if (sim_con_ldsc.bpsfactor != TMXR_BPS_UNIT_SCALE) - fprintf (st, "*%.0f", sim_con_ldsc.bpsfactor / TMXR_BPS_UNIT_SCALE); + if (sim_con_ldsc.bpsfactor != 1.0) + fprintf (st, "*%.0f", sim_con_ldsc.bpsfactor); fprintf (st, " bps\n"); } return SCPE_OK; @@ -2799,7 +2799,7 @@ if (!sim_rem_master_mode) { (sim_con_ldsc.serport == 0)) { /* and not serial? */ if (c && sim_con_ldsc.rxbps) /* got something && rate limiting? */ sim_con_ldsc.rxnexttime = /* compute next input time */ - floor (sim_gtime () + ((sim_con_ldsc.rxdelta * sim_timer_inst_per_sec ()) / sim_con_ldsc.bpsfactor)); + floor (sim_gtime () + ((sim_con_ldsc.rxdeltausecs * sim_timer_inst_per_sec ()) / USECS_PER_SECOND)); if (c) sim_debug (DBG_RCV, &sim_con_telnet, "sim_poll_kbd() returning: '%c' (0x%02X)\n", sim_isprint (c & 0xFF) ? c & 0xFF : '.', c); return c; /* in-window */ diff --git a/sim_tmxr.c b/sim_tmxr.c index 030013df..ea1bcb47 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -735,7 +735,7 @@ else { } } if ((written > 0) && (lp->txbps) && (sim_is_running)) - lp->txnexttime = floor (sim_gtime () + ((written * lp->txdelta * sim_timer_inst_per_sec ()) / lp->bpsfactor)); + lp->txnexttime = floor (sim_gtime () + ((written * lp->txdeltausecs * sim_timer_inst_per_sec ()) / USECS_PER_SECOND)); return written; } @@ -1784,9 +1784,9 @@ if (lp->rxbpi == lp->rxbpr) /* empty? zero ptrs */ lp->rxbpi = lp->rxbpr = 0; if (val) { /* Got something? */ if (lp->rxbps) - lp->rxnexttime = floor (sim_gtime () + ((lp->rxdelta * sim_timer_inst_per_sec ()) / lp->bpsfactor)); + lp->rxnexttime = floor (sim_gtime () + ((lp->rxdeltausecs * sim_timer_inst_per_sec ()) / USECS_PER_SECOND)); else - lp->rxnexttime = floor (sim_gtime () + ((lp->mp->uptr->wait * sim_timer_inst_per_sec ()) / TMXR_BPS_UNIT_SCALE)); + lp->rxnexttime = floor (sim_gtime () + ((lp->mp->uptr->wait * sim_timer_inst_per_sec ()) / USECS_PER_SECOND)); } tmxr_debug_return(lp, val); return val; @@ -2173,8 +2173,8 @@ if ((lp->txbfd && !lp->notelnet) || (TXBUF_AVAIL(lp) > 1)) {/* room for char (+ sim_exp_check (&lp->expect, chr); /* process expect rules as needed */ if (!sim_is_running) { /* attach message or other non simulation time message? */ tmxr_send_buffered_data (lp); /* put data on wire */ - sim_os_ms_sleep(((lp->txbps) && (lp->txdelta > 1000)) ? /* rate limiting output slower than 1000 cps */ - (lp->txdelta - 1000) / 1000 : + sim_os_ms_sleep(((lp->txbps) && (lp->txdeltausecs > 1000)) ? /* rate limiting output slower than 1000 cps */ + (lp->txdeltausecs - 1000) / 1000 : 10); /* wait an approximate character delay */ } return SCPE_OK; /* char sent */ @@ -2477,24 +2477,24 @@ if (*cptr == '*') { if (r != SCPE_OK) return r; - lp->bpsfactor = TMXR_BPS_UNIT_SCALE * bpsfactor; + lp->bpsfactor = bpsfactor; } if ((lp->serport) && (lp->bpsfactor != 0.0)) - lp->bpsfactor = TMXR_BPS_UNIT_SCALE; -lp->rxdelta = _tmln_speed_delta (speed); + lp->bpsfactor = 1.0; +lp->rxdeltausecs = (uint32)(_tmln_speed_delta (speed) / lp->bpsfactor); lp->rxnexttime = 0.0; uptr = lp->uptr; if ((!uptr) && (lp->mp)) uptr = lp->mp->uptr; if (uptr) - uptr->wait = lp->rxdelta; + uptr->wait = lp->rxdeltausecs; if (lp->bpsfactor == 0.0) - lp->bpsfactor = TMXR_BPS_UNIT_SCALE; + lp->bpsfactor = 1.0; lp->txbps = lp->rxbps; -lp->txdelta = lp->rxdelta; +lp->txdeltausecs = lp->rxdeltausecs; lp->txnexttime = lp->rxnexttime; if (lp->o_uptr) - lp->o_uptr->wait = lp->txdelta; + lp->o_uptr->wait = lp->txdeltausecs; return SCPE_OK; } @@ -2532,7 +2532,7 @@ for (i = 0; i < mp->lines; i++) { /* initialize lines */ lp->mp = mp; /* set the back pointer */ lp->modem_control = mp->modem_control; if (lp->bpsfactor == 0.0) - lp->bpsfactor = TMXR_BPS_UNIT_SCALE; + lp->bpsfactor = 1.0; } mp->ring_sock = INVALID_SOCKET; free (mp->ring_ipad); @@ -3938,8 +3938,8 @@ else { if (mp->lines == 1) { if (mp->ldsc->rxbps) { fprintf(st, ", Speed=%d", mp->ldsc->rxbps); - if (mp->ldsc->bpsfactor != TMXR_BPS_UNIT_SCALE) - fprintf(st, "*%.0f", mp->ldsc->bpsfactor / TMXR_BPS_UNIT_SCALE); + if (mp->ldsc->bpsfactor != 1.0) + fprintf(st, "*%.0f", mp->ldsc->bpsfactor); fprintf(st, " bps"); } } @@ -3967,13 +3967,13 @@ else { fprintf(st, ", Loopback"); if (lp->rxbps) { fprintf(st, ", Speed=%d", lp->rxbps); - if (lp->bpsfactor != TMXR_BPS_UNIT_SCALE) - fprintf(st, "*%.0f", lp->bpsfactor / TMXR_BPS_UNIT_SCALE); + if (lp->bpsfactor != 1.0) + fprintf(st, "*%.0f", lp->bpsfactor); fprintf(st, " bps"); } else { - if (lp->bpsfactor != TMXR_BPS_UNIT_SCALE) - fprintf(st, ", Speed=*%.0f bps", lp->bpsfactor / TMXR_BPS_UNIT_SCALE); + if (lp->bpsfactor != 1.0) + fprintf(st, ", Speed=*%.0f bps", lp->bpsfactor); } fprintf (st, "\n"); } @@ -4679,8 +4679,8 @@ else { fprintf (st, " speed = %u", lp->rxbps); else fprintf (st, " speed = %u/%u", lp->rxbps, lp->txbps); - if (lp->bpsfactor / TMXR_BPS_UNIT_SCALE > 1.0) - fprintf (st, "*%.0f", lp->bpsfactor / TMXR_BPS_UNIT_SCALE); + if (lp->bpsfactor > 1.0) + fprintf (st, "*%.0f", lp->bpsfactor); fprintf (st, " bps\n"); } } diff --git a/sim_tmxr.h b/sim_tmxr.h index 47d5a8fe..16953ee2 100644 --- a/sim_tmxr.h +++ b/sim_tmxr.h @@ -170,11 +170,11 @@ struct tmln { uint32 rxpboffset; /* rcv packet buffer offset */ uint32 rxbps; /* rcv bps speed (0 - unlimited) */ double bpsfactor; /* receive speed factor (scaled to usecs) */ -#define TMXR_BPS_UNIT_SCALE 1000000.0 - uint32 rxdelta; /* rcv inter character min time (usecs) */ +#define USECS_PER_SECOND 1000000.0 + uint32 rxdeltausecs; /* rcv inter character min time (usecs) */ double rxnexttime; /* min time for next receive character */ uint32 txbps; /* xmt bps speed (0 - unlimited) */ - uint32 txdelta; /* xmt inter character min time (usecs) */ + uint32 txdeltausecs; /* xmt inter character min time (usecs) */ double txnexttime; /* min time for next transmit character */ uint8 *txpb; /* xmt packet buffer */ uint32 txpbsize; /* xmt packet buffer size */