X-Git-Url: http://gitweb.hachti.de/?a=blobdiff_plain;f=sw%2Fdumprest%2Foriginal%2Fdumbterm.c;fp=sw%2Fdumprest%2Foriginal%2Fdumbterm.c;h=b9b6f4fdbe44409f7c23e358ed2463ef8ddc68c5;hb=81e70d488b71bf995c459ca3a02c025993460ffa;hp=0000000000000000000000000000000000000000;hpb=07ec0278333ed187ac242dedcff13c56cf1b0b91;p=pdp8.git diff --git a/sw/dumprest/original/dumbterm.c b/sw/dumprest/original/dumbterm.c new file mode 100644 index 0000000..b9b6f4f --- /dev/null +++ b/sw/dumprest/original/dumbterm.c @@ -0,0 +1,75 @@ +/* This program will act as a dumb terminal, sending characters typed to + the PDP-8 and printing characters received. Can be used to test the + serial communications. + + The 8th bit is stripped for printing and set for sending to the PDP-8. + + On the PC ctrl-break will terminate the program +*/ +#ifdef PC +#include "encom.h" +#include +#else +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include + +#define ARRAYSIZE(a) (sizeof(a) / sizeof(a[0])) + +int terminate = 0; + +#include "config.c" +#include "comm.c" + +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 0 +#endif + +main(argc,argv) + int argc; + char *argv[]; +{ + int fd; + char serial_dev[256]; + long baud; + int two_stop; + unsigned char buf[256]; + int rc; + int cntr; + + printf("Enter ^I (control-I) or ^break to terminate program\n"); + setup_config(&baud,&two_stop,serial_dev); + + fd = init_comm(serial_dev,baud,two_stop); + + while(!terminate) { + if ((rc = getchar_nonblock()) > 0) { + buf[0] = rc | 0x80; + ser_write(fd,(char *)buf,1); + if (rc == '\n') { + buf[0] = '\r' | 0x80; + ser_write(fd,(char *)buf,1); + } + } + if ((rc = ser_read(fd,(char *) buf,sizeof(buf))) < 0) { + perror("\nstdin read failed\n"); + exit(1); + } + if (rc > 0) { + for (cntr = 0; cntr < rc; cntr++) + buf[cntr] &= 0x7f; + write(STDOUT_FILENO, buf, rc); + } + } + printf("Done\n"); + exit(0); + return(0); +}