From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,84a783003a16a7e6,start X-Google-Attributes: gidfee84,public X-Google-Thread: 1014db,84a783003a16a7e6,start X-Google-Attributes: gid1014db,public From: joltes@fas.harvard.edu (Dick Joltes) Subject: Serial I/O under Digital UNIX Date: 1997/01/31 Message-ID: <5ctc4i$o9p@news.fas.harvard.edu>#1/1 X-Deja-AN: 213500826 organization: Harvard University, Cambridge, Massachusetts newsgroups: comp.unix.osf.osf1,comp.lang.c 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: 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