Subject: Huh? TIOCMGET fails in 1.3.3? How's 1.4?
To: None <port-sparc@netbsd.org>
From: Michael Maciolek <mikem@ne.cohesive.com>
List: port-sparc
Date: 07/12/1999 15:25:33
I'm running NetBSD 1.3.3 on a Sparc IPC.  It's slow but passable.
I don't ask it to do much, and it obliges.

I just acquired a Casio QV-700 digital camera which has a serial
interface for downloading pictures to a host computer; it comes
with software to let it talk to MacOS and Winblows-XX, but UNIX
is another story.  Well, to make a long story short, I tracked
down a copy of a free utility called qvplay (now at version 0.94)
and it appears to work on various Unix systems including FreeBSD,
so I tried it on my 1.3.3 system and it built like a charm.

Then I tried to run it and it complained "Can't set RTS OFF."

So I browsed through the program source and found out why I get the
error message - the program is doing an ioctl TIOCMGET/SET on the
serial port, and that ioctl is failing.  A bit more debugging and
I've reduced the problem to this little snippet of code which fails
just like the qvplay software.

The open() is succeeding, but the ioctl() is failing, and I have no
idea *why* it's failing.  I can't do a simple GET on the terminal
settings?  Am I being dense?  This identical code works just fine
under SunOS 4.x and (changing only "<sys/ioctl.h>" to "<termio.h>")
even under Solaris 2.6 - so why not NetBSD?

I tried to find a reference to any kind of tty ioctl bug in the
NetBSD GNATS database that might explain this, but only managed to
flail uselessly while turning up nothing.

Can anyone confirm that this is/was a problem as of 1.3.3, or tell
me how I'm being stupid?  And if somehow this is a *real* problem,
is it fixed in 1.4?  That would be enough to make me upgrade now.


prompt% cat tio.c

#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>

main() {
        int fd, mode, retcode;

        if ( 0 > (fd=open("/dev/ttyb",O_RDWR|O_NDELAY))) {
                perror("open /dev/ttyb");

        } else {
                if ( -1 == (retcode=ioctl(fd,TIOCMGET,&mode))) {
                        perror("ioctl TIOCMGET");
                } else {
                        printf("mode=0x%08x\n",mode);
                }
                close(fd);
        }
}

prompt% make tio
cc -O   -o tio tio.c 

prompt% ./tio
ioctl TIOCMGET: Inappropriate ioctl for device

Thanks for any assistance!

Regards,

Michael Maciolek