discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Serial port problem with NSFileHandle


From: Andreas Höschler
Subject: Serial port problem with NSFileHandle
Date: Thu, 24 May 2007 11:22:33 +0200

Hello all,

we usually do

   struct termios _options;
   ...
   _fh = [NSFileHandle fileHandleForUpdatingAtPath:@"/dev/term/a"];
   tcsetattr([_fh fileDescriptor], TCSADRAIN, &_options);
   [_fh writeData:...;

to access a serial port. GSFileHandle does

- (id) initForUpdatingAtPath: (NSString*)path
{
  int   d = open([path fileSystemRepresentation], O_RDWR | O_BINARY);
  ...
}

This approach works with the built-in serial ports on our Debian and Solaris boxes. Now we are using an EdgePort Device (USB-Serial-Adaptor) to add four additional serial ports to a Solaris machine. This device is natively supported by Solaris. A few seconds after plugging in the device we see the following devices

        /dev/term/0
        /dev/term/1
        /dev/term/2
        /dev/term/3

Cool so far. However, openening these devices with NSFileHandle does not work. The line [NSFileHandle fileHandleForUpdatingAtPath:@"/dev/term/0"] blocks (never returns). We have to do

   int fdes = open([device cString], O_RDWR | O_NDELAY);
_fh = [[NSFileHandle alloc] initWithFileDescriptor:fdes closeOnDealloc:YES];

instead. This works! Should this option be added to the GSFileHandle code? I did not figure out what exactly this option does. Insights would be greatly appreciated!

Thanks,

   Andreas






reply via email to

[Prev in Thread] Current Thread [Next in Thread]