Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: fred@genesis.demon.co.uk (Lawrence Kirby)
Subject: Re: Serial I/O under Digital UNIX
Date: 1997/02/01	[thread overview]
Message-ID: <854757280snz@genesis.demon.co.uk> (raw)
In-Reply-To: 5ctc4i$o9p@news.fas.harvard.edu


In article <5ctc4i$o9p@news.fas.harvard.edu>
           joltes@fas.harvard.edu "Dick Joltes" writes:

>Question for the C & OSF gurus...

This isn't a question about the C language itself so I've added
comp.unix.programmer to the newsgroups list and removed comp.lang.c
from the followups. comp.lang.c is inappropriate for questions about
a specific platform.

>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.

However I see nothing here that requires the two reply bytes to be acted
on together.

>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).

That is entirely possible although I don't know Digital UNIX specifically.

> 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.

RAW mode covers a multitude of sins under termios, as you note there isn't
a simple setting for it. You need to give the exact settings you used.

...

>ics_expect (byte)
>
>        char byte;
>{
>        char buf[8];
>
>        if (read (fd, buf, 2) == 2) {
>                byte == buf[0];

This line doesn't appear to do anything particularly useful.

>                return;
>        }

The point being here that without knowing the exact settings it is impossible
to say whether both reply bytes will be returned through a single read,
whether they might be returned individually, read() might even return 0
length in some cases. Depending on your settings the tty may not be as "RAW"
as you thought it was, it may still be dong some form in input processing.

For robustness your code should expect to receive short input and be able
to recall read to get the rest of the input if that is the case.

>        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 did you receive from the read() call? What was the return value?
If it returned data what was it and what data did you expect? If read()
returned an error condition what was the value of errno?

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------




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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-31  5:00 Serial I/O under Digital UNIX Dick Joltes
1997-02-01  5:00 ` Lawrence Kirby [this message]
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