mirror of
https://github.com/dschmenk/apple2pi.git
synced 2024-11-23 21:31:04 +00:00
Support detaching and reattaching of USB devices during runtime.
Note: At least some USB device types have their /dev/tty/ACMn number increased for every reattachment. Therefore, this new feature is to be used with a cmdline parameter like '/dev/tty/ACM*'. The quotes keeps the shell from globbing the wildcard.
This commit is contained in:
parent
95e16e6af0
commit
242a4bc6b5
48
src/a2pid.c
48
src/a2pid.c
@ -623,6 +623,21 @@ void main(int argc, char **argv)
|
||||
* Get vdrv images.
|
||||
*/
|
||||
vdrvactive = vdrvopen(vdrvdir);
|
||||
/*
|
||||
* Open socket.
|
||||
*/
|
||||
prlog("a2pid: Open server socket\n");
|
||||
bzero(&servaddr, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_port = htons(6551);
|
||||
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
srvfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (srvfd < 0)
|
||||
die("error: socket create");
|
||||
if (bind(srvfd,(struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
|
||||
die("error: bind socket");
|
||||
if (listen(srvfd, MAX_CLIENT - 1) < 0)
|
||||
die("error: listen socket");
|
||||
#if defined(SETSERCLK) && defined(__ARMEL__)
|
||||
/*
|
||||
* Initialize ACIA clock for Apple II Pi card
|
||||
@ -630,18 +645,21 @@ void main(int argc, char **argv)
|
||||
if (devtty == deftty)
|
||||
gpclk(271); /* divisor for ~1.8 MHz => (500/271) MHz */
|
||||
#endif
|
||||
/*
|
||||
* Come back here on serial read error.
|
||||
*/
|
||||
openserial:
|
||||
/*
|
||||
* Open serial port.
|
||||
*/
|
||||
if (!pathmatch(&devtty, ttypattern))
|
||||
die("error: serial port not found");
|
||||
while (!pathmatch(&devtty, ttypattern))
|
||||
usleep(1000);
|
||||
prlog("a2pid: Open serial port\n");
|
||||
#ifdef TRACE
|
||||
printf("a2pid: open %s\n", devtty);
|
||||
#endif
|
||||
a2fd = open(devtty, O_RDWR | O_NOCTTY);
|
||||
if (a2fd < 0)
|
||||
die("error: serial port open");
|
||||
while ((a2fd = open(devtty, O_RDWR | O_NOCTTY)) < 0)
|
||||
usleep(1000);
|
||||
tcflush(a2fd, TCIFLUSH);
|
||||
tcgetattr(a2fd, &oldtio); /* save current port settings */
|
||||
bzero(&newtio, sizeof(newtio));
|
||||
@ -679,22 +697,7 @@ void main(int argc, char **argv)
|
||||
newtio.c_cc[VMIN] = 3; /* blocking read until 3 chars received */
|
||||
tcsetattr(a2fd, TCSANOW, &newtio);
|
||||
/*
|
||||
* Open socket.
|
||||
*/
|
||||
prlog("a2pid: Open server socket\n");
|
||||
bzero(&servaddr, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_port = htons(6551);
|
||||
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
srvfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (srvfd < 0)
|
||||
die("error: socket create");
|
||||
if (bind(srvfd,(struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
|
||||
die("error: bind socket");
|
||||
if (listen(srvfd, MAX_CLIENT - 1) < 0)
|
||||
die("error: listen socket");
|
||||
/*
|
||||
* Come basck here on RESET.
|
||||
* Come back here on RESET.
|
||||
*/
|
||||
reset:
|
||||
state = RUN;
|
||||
@ -973,7 +976,8 @@ reset:
|
||||
else
|
||||
{
|
||||
prlog("a2pid: error read serial port ????\n");
|
||||
state = STOP;
|
||||
close(a2fd);
|
||||
goto openserial;
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user