Telling apart serial from // port

Hi!
I’m writing a SafeWrite() function for a journal log, and I want it to be a
possible drop-in replacement for write(). That log could be either a regular
file, a serial or a parallel printer. fstat() can tell apart a regular file
from a character special file, but how to tell a serial port apart from a
parallel port, once the open() is done?
Any clue or different approach welcome!
Thanks,
Martin

“Martin Gagnon” <martin.gagnon@genisys.qc.ca> wrote in message
news:bkdb50$cau$1@inn.qnx.com

Hi!
I’m writing a SafeWrite() function for a journal log, and I want it to be
a
possible drop-in replacement for write(). That log could be either a
regular
file, a serial or a parallel printer. fstat() can tell apart a regular
file
from a character special file, but how to tell a serial port apart from a
parallel port, once the open() is done?

Why would you need to know the difference?

At anyrate you can do what stty is doing :wink: Under QNX4 you could tell by
calling drv_info and look at the driver_type filed of the returned
structture.
Under QNX6 I don’t know what the equivalent call is. Get the QNX4 migration
kit and look at the source of drv_info.

Any clue or different approach welcome!

Thanks,
Martin

Hi Mario,

“Mario Charest” postmaster@127.0.0.1 wrote in message
news:bkdfrs$f6d$1@inn.qnx.com

“Martin Gagnon” <> martin.gagnon@genisys.qc.ca> > wrote in message
news:bkdb50$cau$> 1@inn.qnx.com> …
Hi!
I’m writing a SafeWrite() function for a journal log, and I want it to
be
a
possible drop-in replacement for write(). That log could be either a
regular
file, a serial or a parallel printer. fstat() can tell apart a regular
file
from a character special file, but how to tell a serial port apart from
a
parallel port, once the open() is done?

Why would you need to know the difference?

Because a serial printer doesn’t have control lines… (Select, PaperEnd,
Busy…)

At anyrate you can do what stty is doing > :wink: > Under QNX4 you could tell by
calling drv_info and look at the driver_type filed of the returned
structture.

stty < /dev/par1 provides the // printer status. My func uses devctl(fd,
DCMD_CHR_LINESTATUS…) and then checks for the LINESTATUS_PAR* flags to
determine the printer status.
Is this the way to go?

Thanks,
Martin

Under QNX6 I don’t know what the equivalent call is. Get the QNX4
migration
kit and look at the source of drv_info.

Any clue or different approach welcome!

Thanks,
Martin
\