1
0
mirror of https://github.com/aap/pdp6.git synced 2026-01-11 23:53:31 +00:00

emu: serial panel

This commit is contained in:
aap 2019-02-28 13:15:38 +01:00
parent eab4f5b891
commit 6760995000

View File

@ -3,6 +3,10 @@
#include <pthread.h>
#include "args.h"
#include <fcntl.h>
#include <termios.h>
// TODO: get rid of this
void updatepanel(Apr *apr) {}
@ -18,10 +22,18 @@ getms(void)
void
talkserial(int fd, Apr *apr, Ptr *ptr)
{
struct termios ios;
Apr oldapr;
char buf[32];
int n;
if(tcgetattr(fd, &ios) == 0){
cfsetispeed(&ios, B38400);
cfsetospeed(&ios, B38400);
cfmakeraw(&ios);
tcsetattr(fd, TCSANOW, &ios);
}
while(1){
if(apr == nil)
return;
@ -126,7 +138,7 @@ talkserial(int fd, Apr *apr, Ptr *ptr)
void
usage(void)
{
fprintf(stderr, "usage: %s [-t] [-d debugfile]\n", argv0);
fprintf(stderr, "usage: %s [-t] [-d debugfile] [-p paneltty]\n", argv0);
exit(1);
}
@ -135,12 +147,14 @@ main(int argc, char *argv[])
{
pthread_t cmd_thread, sim_thread;
const char *outfile;
const char *panelfile;
int fd;
Apr *apr;
Ptr *ptr;
outfile = "/dev/null";
panelfile = nil;
ARGBEGIN{
case 't':
dotrace = 1;
@ -148,6 +162,9 @@ main(int argc, char *argv[])
case 'd':
outfile = EARGF(usage());
break;
case 'p':
panelfile = EARGF(usage());
break;
default:
usage();
}ARGEND;
@ -164,9 +181,17 @@ main(int argc, char *argv[])
pthread_create(&sim_thread, nil, simthread, apr);
pthread_create(&cmd_thread, nil, cmdthread, nil);
fd = dial("localhost", 2000);
if(fd < 0)
err("can't connect to panel");
if(panelfile){
fd = open(panelfile, O_RDWR);
if(fd < 0)
err("Couldn't open %s", panelfile);
}else{
/* Just testing... */
fd = dial("localhost", 2000);
if(fd < 0)
err("can't connect to panel");
}
talkserial(fd, apr, ptr);
return 0;