[nSLUG] /dev/ttyS0: open from Perl ??

George N. White III aa056 at chebucto.ns.ca
Wed Mar 10 11:13:08 AST 2004

On Wed, 10 Mar 2004, Mike wrote:

> I'm trying to get a Kodak DC40 talking to my PC.  To do this, I have
> to converse with the serial port (not USB).  A Perl script called
> kdcpi should do this but doesn't.
> The problem seems to be that an attempt to open /dev/ttyS0 hangs.
> That is, a call to open or sysopen (or to IO::File->new which uses
> either open or sysopen) never returns.
> If I disconnect the camera and plug my modem back in, an attempt to
> open /dev/ttyS0 turns on the the DTR light but nothing further
> happens.  The [sys]open call hangs and never returns.
>    /dev/ttyS0 works with pppd and minicom
>    /dev/ttyS0 is rw-rw-rw
> The kdcpi script uses IO::File->new($tty,$O_RDWR) and thus sysopen.
> It's said to work.  Looking at the C code for minicom and the
> Serial-Programming-HOWTO, I don't see any special incantations needed
> to do an open on /dev/ttyS0.
> What am I missing?

ttyS0 is often a symbolic link, you need to see the permissions on
the actual device file:

$ ls -l /dev/ttyS0 /dev/tts/0
crw-rw---- 1 gwhite  tty 4, 64 Mar 9 14:24 /dev/tts/0
lr-xr-xr-x 1 root    root    5 Jan  9 15:02 /dev/ttyS0 -> tts/0

You may also encounter permission issues for lock files.  I can't
get kermit to work except as "sudo kermit" or I get:

(/usr2/people/gwhite/) C-Kermit>set port /dev/ttyS0
Sorry, write access to UUCP lockfile directory denied.

George N. White III  <aa056 at chebucto.ns.ca>
  Head of St. Margarets Bay, Nova Scotia, Canada

More information about the nSLUG mailing list