H316: Update error and warning messages to properly use SCP APIs

This commit is contained in:
Mark Pizzolato 2020-02-16 17:30:20 -08:00
parent bbb545d4bd
commit 36a732b26f
4 changed files with 15 additions and 37 deletions

View file

@ -268,7 +268,7 @@ void hi_link_error (uint16 line)
// Any physical I/O error, either for the UDP link or a COM port, prints a
// message and detaches the modem. It's up to the user to decide what to do
// after that...
fprintf(stderr,"HI%d - UNRECOVERABLE I/O ERROR!\n", line);
sim_printf("HI%d - UNRECOVERABLE I/O ERROR!\n", line);
hi_reset_rx(line); hi_reset_tx(line);
sim_cancel(PUNIT(line)); hi_detach(PUNIT(line));
PHIDB(line)->link = NOLINK;
@ -344,7 +344,6 @@ void hi_start_tx (uint16 line, uint16 flags)
tmp [0] = flags;
for (i = 0; i < count; i ++)
tmp [i + 1] = M [next+i];
//ret = udp_send(PDEVICE(line), PHIDB(line)->link, &M[next], count);
ret = udp_send(PDEVICE(line), PHIDB(line)->link, tmp, count);
free (tmp);
if (ret != SCPE_OK && ret != 66) hi_link_error(line);
@ -359,8 +358,7 @@ void hi_start_tx (uint16 line, uint16 flags)
// DLE, STX, ETX and checksum bytes, that would be added to the packet.
nbits = (((uint32) count)*2UL + 12UL) * 8UL;
PHIDB(line)->txdelay = (nbits * 1000000UL) / (PHIDB(line)->bps * rtc_interval);
//fprintf(stderr,"HI%d - transmit packet, length=%d, bits=%ld, interval=%ld, delay=%ld\n", line, count, nbits, rtc_interval, PHIDB(line)->txdelay);
sim_debug(IMP_DBG_IOT, PDEVICE(line), "HI%d - transmit packet, length=%d, bits=%ld, interval=%ld, delay=%ld\n", line, count, nbits, rtc_interval, PHIDB(line)->txdelay);
// That's it - we're done until it's time for the TX done interrupt ...
CLR_TX_IRQ(line);
}
@ -425,7 +423,6 @@ void hi_poll_rx (uint16 line)
// Read the packet into a temp buffer for disassembly.
tmp = (uint16 *)malloc (MAXDATA * sizeof (*tmp));
//count = udp_receive(PDEVICE(line), PHIDB(line)->link, pdata, maxbuf);
count = udp_receive(PDEVICE(line), PHIDB(line)->link, tmp, maxbuf+1);
if (count == 0) {free (tmp); return; }
if (count < 0) {free (tmp); hi_link_error(line); return; }
@ -533,7 +530,7 @@ int32 hi_io (uint16 host, int32 inst, int32 fnc, int32 dat, int32 dev)
udp_set_link_loopback (PDEVICE(host), PHIDB(host)->link, FALSE);
return dat;
case 005:
//fprintf (stderr, "HnENAB unimp.\r\n");
sim_printf("HnENAB unimp.\n");
// HnENAB - enable ...
sim_debug(IMP_DBG_IOT, PDEVICE(host), "enable host (PC=%06o)\n", PC-1);
return dat;
@ -550,7 +547,7 @@ int32 hi_io (uint16 host, int32 inst, int32 fnc, int32 dat, int32 dev)
case 001:
// HnRDY - skip on host ready ...
//sim_debug(IMP_DBG_IOT, PDEVICE(host), "skip on ready (PC=%06o %s)\n", PC-1, PHIDB(host)->ready ? "SKIP" : "NOSKIP");
//fprintf (stderr, "HnRDY unimpl.; always ready\r\n");
sim_printf("HnRDY unimpl.; always ready\n");
return PHIDB(host)->ready ? IOSKIP(dat) : dat;
case 002:
// HnEOM - skip on end of message ...
@ -559,7 +556,7 @@ int32 hi_io (uint16 host, int32 inst, int32 fnc, int32 dat, int32 dev)
return dat;
case 005:
// HnFULL - skip on host buffer full ...
fprintf (stderr, "HnFULL unimp.\r\n");
sim_printf("HnFULL unimp.\n");
sim_debug(IMP_DBG_IOT, PDEVICE(host), "skip on buffer full (PC=%06o %s)\n", PC-1, "NOSKIP");
return dat;
}
@ -635,10 +632,8 @@ t_stat hi_attach (UNIT *uptr, CONST char *cptr)
if ((uptr->flags & UNIT_ATT) != 0) detach_unit(uptr);
// The physical (COM port) attach isn't implemented yet ...
if (fport) {
fprintf(stderr,"HI%d - physical COM support is not yet implemented\n", host);
return SCPE_ARG;
}
if (fport)
return sim_messagef(SCPE_ARG,"HI%d - physical COM support is not yet implemented\n", host);
// Make a copy of the "file name" argument. udp_create() actually modifies
// the string buffer we give it, so we make a copy now so we'll have something

View file

@ -367,7 +367,7 @@ void mi_link_error (uint16 line)
// Any physical I/O error, either for the UDP link or a COM port, prints a
// message and detaches the modem. It's up to the user to decide what to do
// after that...
fprintf(stderr,"MI%d - UNRECOVERABLE I/O ERROR!\n", line);
sim_printf("MI%d - UNRECOVERABLE I/O ERROR!\n", line);
mi_reset_rx(line); mi_reset_tx(line);
sim_cancel(PUNIT(line)); mi_detach(PUNIT(line));
PMIDB(line)->link = NOLINK;
@ -700,10 +700,8 @@ t_stat mi_attach (UNIT *uptr, CONST char *cptr)
if ((uptr->flags & UNIT_ATT) != 0) detach_unit(uptr);
// The physical (COM port) attach isn't implemented yet ...
if (fport) {
fprintf(stderr,"MI%d - physical COM support is not yet implemented\n", line);
return SCPE_ARG;
}
if (fport)
return sim_messagef(SCPE_ARG,"MI%d - physical COM support is not yet implemented\n", line);
// Make a copy of the "file name" argument. udp_create() actually modifies
// the string buffer we give it, so we make a copy now so we'll have something

View file

@ -365,10 +365,8 @@ t_stat wdt_set_delay (UNIT *uptr, int32 val, CONST char *cptr, void *desc)
if (cptr == NULL) return SCPE_ARG;
newint = get_uint (cptr, 10, 65535, &ret);
if (ret != SCPE_OK) return ret;
if (newint != 0) {
fprintf(stderr,"WDT - timeout not yet implemented\n");
return SCPE_IERR;
}
if (newint != 0)
return sim_messagef(SCPE_IERR, "WDT - timeout not yet implemented\n");
wdt_delay = newint;
// TBA add calculations here???
return SCPE_OK;

View file

@ -136,7 +136,6 @@
// Local constants ...
#define MAXLINKS 10 // maximum number of simultaneous connections
// UDP connection data structure ...
// One of these blocks is allocated for every simulated modem link.
struct _UDP_LINK {
@ -235,18 +234,11 @@ t_stat udp_parse_remote (int32 link, const char *premote)
if ((strcmp (udp_links[link].lport, port) == 0) &&
(strcmp ("localhost", host) == 0))
fprintf(stderr,"WARNING - use different transmit and receive ports!\n");
return sim_messagef (SCPE_ARG, "WARNING - use different transmit and receive ports!\n");
return SCPE_OK;
}
t_stat udp_error (int32 link, const char *msg)
{
// This routine is called whenever a SOCKET_ERROR is returned for any I/O.
fprintf(stderr,"UDP%d - %s failed with error %d\n", link, msg, WSAGetLastError());
return SCPE_IOERR;
}
t_stat udp_create (DEVICE *dptr, const char *premote, int32 *pln)
{
// Create a logical UDP link to the specified remote system. The "remote"
@ -327,12 +319,7 @@ t_stat udp_send (DEVICE *dptr, int32 link, uint16 *pdata, uint16 count)
// Send it and we're outta here ...
iret = tmxr_put_packet_ln (&udp_lines[link], (const uint8 *)&pkt, (size_t)pktlen);
if (iret == 111)
{
fprintf (stderr, "link %d got connection refused\n", link);
return SCPE_OK;
}
if (iret != SCPE_OK) return udp_error(link, "tmxr_put_packet_ln()");
if (iret != SCPE_OK) return sim_messagef(iret, "UDP%d - tmxr_put_packet_ln() failed with error %s\n", link, sim_error_text(iret));
sim_debug(IMP_DBG_UDP, dptr, "link %d - packet sent (sequence=%d, length=%d)\n", link, ntohl(pkt.sequence), ntohs(pkt.count));
return SCPE_OK;
}
@ -366,7 +353,7 @@ int32 udp_receive_packet (int32 link, UDP_PACKET *ppkt)
ret = tmxr_get_packet_ln (&udp_lines[link], &pbuf, &pktsiz);
udp_lines[link].rcve = FALSE; // Disable receiver
if (ret != SCPE_OK) {
udp_error(link, "tmxr_get_packet_ln()");
sim_messagef (ret, "UDP%d - tmxr_get_packet_ln() failed with error %s\n", link, sim_error_text(ret));
return NOLINK;
}
if (pbuf == NULL) return 0;