• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Serial device open(2) hang.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Serial device open(2) hang.


  • Subject: Re: Serial device open(2) hang.
  • From: Tom Hohensee <email@hidden>
  • Date: Sat, 27 Jun 2009 22:42:05 -0500

Steve,
Serial out is the tty prefixed with cu.

./a.out/dev/cu.USA49W62P1.1

Tom

On Jun 27, 2009, at 7:55 PM, Steve Checkoway wrote:

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

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: UITextView symbols
  • Next by Date: Re: Serial device open(2) hang.
  • Previous by thread: Re: Base SDK and deployment target Q
  • Next by thread: Re: Serial device open(2) hang.
  • Index(es):
    • Date
    • Thread