Here's one headsup. I've got a USA-19QW keyspan adapter with up to
date drivers and I've been happy with it until, coincidentally, this
AM. I tried to use some termios code with VMIN and VTIME timeouts
that works on FreeBSD, cygwin, and RTEMS unchanged and I couldn't get
it to work on my powerbook. I finally gave up and hacked in a SIGALRM
timeout with interrupted system calls enabled after trying for an hour
or so to figure out what was wrong, checking driver revs, etc.
Here are the code snippets if anyone notices anything.
Pertinent setup, TIMEOUTS_BROKEN set for Apple:
#if TIMEOUTS_BROKEN
siginterrupt(SIGALRM, 1); // Cause reads to be interrupted
signal(SIGALRM, timed_out);
#else
ntermio.c_lflag &= ~(ECHO|ICANON|ISIG); // No echo, non-canonical
input, no signals
/*
* Don't strip to seven bits, do XON or XOFF, ignore CR, or map
things around..
*/
ntermio.c_iflag &= ~(ICRNL|IGNCR|ISTRIP|INPCK|IXON|IXOFF|INLCR);
ntermio.c_oflag &= ~(OPOST); // Don't do output processing.
// Get the first character with a half second timeout.
ntermio.c_cc[VMIN] = 0;
ntermio.c_cc[VTIME] = 5; // 5 times .1 is 1/2 second
if (tcsetattr(fd, TCSANOW, &ntermio)) {
return latch_errno("tcsetattr");
}
if ((n = read(fd, inbuf, 1)) != 1) {
if (n == 0) {
return crash("No response from the OncoScanner.");
}
fprintf(stderr, "Read %d characters from the OncoScanner
instead of 1.\n", (int)n);
return latch_errno("read");
}
// We know it is out there. Set an inter-byte timeout to get
the rest.
// XXX Still could hang if the device disappears
ntermio.c_cc[VMIN] = 4; // four more bytes.
ntermio.c_cc[VTIME] = 1; // They shouldn't be more than .1
seconds apart.
if (tcsetattr(fd, TCSANOW, &ntermio)) {
return latch_errno("tcsetattr");
}
if ((n = read(fd, inbuf + 1, 4)) != 4) {
fprintf(stderr, "Read returned %d, not 4.\n", (int)n);
return latch_errno("read");
}
#else
alarm(2);
if ((n = read(fd, inbuf, 5)) != 5) {
fprintf(stderr, "Read returned %d bytes, not 5 bytes.\n",
(int)n);
return latch_errno("read");
}
alarm(0);
#endif
Peter
Peter Dufault
HD Associates, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Scitech mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/scitech/email@hidden