Serial device open(2) hang.
Serial device open(2) hang.
- Subject: Serial device open(2) hang.
- From: Steve Checkoway <email@hidden>
- Date: Sat, 27 Jun 2009 17:55:01 -0700
I have a Keyspan USA-49WLC USB to 4 serial ports adapter which, when
plugged in, correctly shows 4 /dev/tty.USA* and 4 /dev/cu.USA*
devices. I'm trying to talk to a microcontroller on the other end of
the serial, reading and writing data, so the first step I'm taking is
to open(2) the appropriate tty. As far as I can tell, this is hanging
until I unplug the USB cable. Once I unplug it, it returns -1.
[mb:~/temp/serial] steve$ cat gah.c
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
int main( int argc, char *argv[] )
{
if( argc != 2 )
{
fprintf( stderr, "Usage: %s device\n", argv[0] );
return 1;
}
puts( "Opening file" );
int fd = open( argv[1], O_RDWR );
if( fd == -1 )
{
perror( argv[1] );
return 1;
}
puts( "Opened!" );
close( fd );
return 0;
}
[mb:~/temp/serial] steve$ gcc -Wall gah.c
[mb:~/temp/serial] steve$ ./a.out /dev/tty.USA49W62P1.1
Opening file
/dev/tty.USA49W62P1.1: Device not configured
This same code, when run on Linux using /dev/ttyS0, works as I would
expect: It prints "Opening a file" and then "Opened!".
Is this a problem with the Keyspan driver or (as is more likely) am I
doing something wrong?
--
Steve Checkoway
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden