Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: joltes@fas.harvard.edu (Dick Joltes)
Subject: Serial I/O under Digital UNIX
Date: 1997/01/31	[thread overview]
Message-ID: <5ctc4i$o9p@news.fas.harvard.edu> (raw)


Question for the C & OSF gurus...

I'm porting some C code from an old Ultrix box.  The code talks to a
specialized "cash acceptor" module that has a serial interface--you
send a query (1 byte) to the acceptor, and it responds with a copy of
the query byte plus its response to it (i.e. status codes, etc.).  The
serial device is connected to a terminal server which is accessed using
LAT (DEC's Local Area Transport protocol).  The LAT component seems
to be working fine, and worked perfectly under Ultrix.

The problem is that the old open/read calls don't seem to be working.
I get invalid data when I query the cash acceptor module, and I think
it has to do with the change from clist to STREAMS-based I/O under
Digital UNIX (& OSF).  I put the device into RAW mode using standard
termios calls as we did under Ultrix (though there was a specific call
under Ultrix that did everything necessary at once) and then just try
writing a query byte to the device.  It returns something (or at least
it seems to) but it's not the correct string.

The following asks the device for its status:

ics_status ()

{
        int status;

        ics_send (Get_Status);
        ics_expect (Get_Status);
        status = ics_read ();

	[return codes deleted...]

Finally, ics_send & ics_expect do the actual calls:

ics_send (byte)

        char byte;
{
        if (write (fd, &byte, 1) != 1) {
                fprintf (stderr, "Line not accepting characters.\n");
                exit (1);
        }
}

ics_expect (byte)

        char byte;
{
        char buf[8];

        if (read (fd, buf, 2) == 2) {
                byte == buf[0];
                return;
        }
        else {
                fprintf (stderr, "ics_expect: Bad response from unit: %d\n",
                (int) buf[0]);
                exit (1);
        }
}

The write completes without error, but every time I try running the
code I get the "Bad response..." error from ics_expect.

So what's so different about doing reads & writes to STREAMS devices?
Do I need to make major code changes to do this?  Any help would be
greatly appreciated.  Direct e-mail responses are fine--I'd be more
than happy to summarize if there's interest.

Thanks!

------------------------------------------------------------------------------
Dick Joltes                                 mailto: <joltes@fas.harvard.edu>
Manager, Multiplatform Svcs               http://www.fas.harvard.edu/~joltes
------------------------------------------------------------------------------
The other day upon the stair / I met a man who wasn't there.
He wasn't there again today / I think he's from the CIA.   -- Mad Magazine



             reply	other threads:[~1997-01-31  5:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-31  5:00 Dick Joltes [this message]
1997-02-01  5:00 ` Serial I/O under Digital UNIX Lawrence Kirby
1997-02-03  5:00   ` Dick Joltes
1997-02-03  5:00 ` Eric Werme
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox