KA10: Poll quicker for Chaosnet packet when there's traffic.

This commit is contained in:
Richard Cornwell 2023-12-31 11:17:43 -05:00 committed by Paul Koning
parent 2eaa31f10e
commit fc7b65cb47
2 changed files with 27 additions and 18 deletions

View file

@ -251,11 +251,12 @@ t_stat ch10_transmit ()
ch10_status |= OVER;
}
tx_count = 0;
ch10_status |= TXD;
ch10_test_int ();
return SCPE_OK;
}
void ch10_receive (void)
int ch10_receive (void)
{
size_t count;
const uint8 *p;
@ -264,16 +265,16 @@ void ch10_receive (void)
tmxr_poll_rx (&ch10_tmxr);
if (tmxr_get_packet_ln (&ch10_lines[0], &p, &count) != SCPE_OK) {
sim_debug (DBG_ERR, &ch10_dev, "TMXR error receiving packet\n");
return;
return 0;
}
if (p == NULL)
return;
return 0;
dest = ((p[4+CHUDP_HEADER] & 0xff) << 8) + (p[5+CHUDP_HEADER] & 0xff);
sim_debug (DBG_PKT, &ch10_dev, "Received UDP packet, %d bytes for: %o\n", (int)count, dest);
/* Check if packet for us. */
if (dest != address && dest != 0 && (ch10_status & SPY) == 0)
return;
return 1;
if ((RXD & ch10_status) == 0) {
count = (count + 1) & 01776;
@ -291,6 +292,7 @@ void ch10_receive (void)
if ((ch10_status & LOST) < LOST)
ch10_status += 01000;
}
return 1;
}
void ch10_clear (void)
@ -410,14 +412,15 @@ t_stat ch10_devio(uint32 dev, uint64 *data)
t_stat ch10_svc(UNIT *uptr)
{
sim_clock_coschedule (uptr, 1000);
(void)tmxr_poll_conn (&ch10_tmxr);
if (ch10_lines[0].conn) {
ch10_receive ();
if (ch10_receive ()) {
sim_activate_after (uptr, 300);
return SCPE_OK;
}
} else {
(void)tmxr_poll_conn (&ch10_tmxr);
}
if (tx_count == 0)
ch10_status |= TXD;
ch10_test_int ();
sim_clock_coschedule (uptr, 1000);
return SCPE_OK;
}

View file

@ -79,7 +79,7 @@ int ch11_read(DEVICE *dptr, t_addr addr, uint16 *data, int32 access);
uint16 ch11_checksum (const uint8 *p, int count);
void ch11_validate (const uint8 *p, int count);
t_stat ch11_transmit (struct pdp_dib *dibp);
void ch11_receive (struct pdp_dib *dibp);
int ch11_receive (struct pdp_dib *dibp);
void ch11_clear (struct pdp_dib *dibp);
t_stat ch11_svc(UNIT *);
t_stat ch11_reset (DEVICE *);
@ -349,10 +349,11 @@ ch11_transmit (struct pdp_dib *dibp)
ch11_csr |= CSR_TAB;
}
tx_count = 0;
ch11_csr |= CSR_TDN;
return SCPE_OK;
}
void
int
ch11_receive (struct pdp_dib *dibp)
{
size_t count;
@ -362,16 +363,16 @@ ch11_receive (struct pdp_dib *dibp)
tmxr_poll_rx (&ch11_tmxr);
if (tmxr_get_packet_ln (&ch11_lines[0], &p, &count) != SCPE_OK) {
sim_debug (DBG_ERR, &ch11_dev, "TMXR error receiving packet\n");
return;
return 0;
}
if (p == NULL)
return;
return 0;
dest = ((p[4+CHUDP_HEADER] & 0xff) << 8) + (p[5+CHUDP_HEADER] & 0xff);
sim_debug (DBG_PKT, &ch11_dev, "Received UDP packet, %d bytes for: %o\n", (int)count, dest);
/* Check if packet for us. */
if (dest != address && dest != 0 && (ch11_csr & CSR_SPY) == 0)
return;
return 1;
if ((CSR_RDN & ch11_csr) == 0) {
count = (count + 1) & 01776;
@ -392,6 +393,7 @@ ch11_receive (struct pdp_dib *dibp)
if ((ch11_csr & CSR_LOS) != CSR_LOS)
ch11_csr = (ch11_csr & ~CSR_LOS) | (CSR_LOS & (ch11_csr + 01000));
}
return 1;
}
void
@ -417,10 +419,14 @@ ch11_svc(UNIT *uptr)
DEVICE *dptr = find_dev_from_unit (uptr);
struct pdp_dib *dibp = (DIB *)dptr->ctxt;
sim_clock_coschedule (uptr, 1000);
(void)tmxr_poll_conn (&ch11_tmxr);
if (ch11_lines[0].conn) {
ch11_receive (dibp);
if (ch11_receive (dibp))
sim_activate_after (uptr, 300);
else
sim_clock_coschedule (uptr, 1000);
} else {
(void)tmxr_poll_conn (&ch11_tmxr);
sim_clock_coschedule (uptr, 1000);
}
if (tx_count == 0) {
ch11_csr |= CSR_TDN;