Serial port for read/write problem

Serial port for read/write problem

Post by Dr Jaime V Mir » Tue, 22 Jun 1999 04:00:00



Hi,

I am having trouble opening a serial port for read/write operations.
Basically, I don't seem to be able to do both operations on the same
port (sequentially, of course).
The serial HOWTO's are not much help as they only deal with reading, and
any documentation I've been able to find I find isconfussingly
complicated and not affective any way. Surely, there must be a more
simple and neat way of doing such simple operations. Any ideas welcome.

Jaime

 
 
 

Serial port for read/write problem

Post by Robert Lync » Tue, 22 Jun 1999 04:00:00



Quote:

> Hi,

> I am having trouble opening a serial port for read/write operations.
> Basically, I don't seem to be able to do both operations on the same
> port (sequentially, of course).
> The serial HOWTO's are not much help as they only deal with reading, and
> any documentation I've been able to find I find isconfussingly
> complicated and not affective any way. Surely, there must be a more
> simple and neat way of doing such simple operations. Any ideas welcome.

> Jaime

You might find:

http://www.veryComputer.com/

a useful source of info.

HTH. Bob L.
--

http://www.veryComputer.com/~rm*/

 
 
 

1. Serial I/O Problem: Reading/Writing the same Port

I am trying to do Serial I/O in C through the RS-232 port on an
HP 425t running HP-UX 8.0.  I need to both read from and write
to this port.  I have set up two file descriptors (read, write).  
For each byte that is written to this port, an identical byte is to
be returned on the read channel.  There is a dumb terminal (VT220)
connected to this port; when a sent character (sent using write())
is displayed on the terminal, a person hits that same key to simulate
the echo back to the workstation.  This character is displayed on
the VT220 (which I assume means that it has been sent out on the
serial line), but a read() of size 1 does not terminate on
the workstation.  Many many keys can be pressed and the read() does
not terminate until a <CR> is hit.  Successive read() calls pick
up all the extra characters that were sent after the initial keystroke
and before the <CR> (i.e. *each* read() did not require its own <CR>
in order to see the character, just the first one).

I have read and re-read the man pages for open(), termio(), ioctl(), ...
and now need to ask for help.

I thought that read() did not buffer its input;  I have two questions:

  (1) Is it possible that the dumb terminal is not sending the
character until the <CR>?  I always thought the definition of dumb
was that it did no thinking for you.  
  (2) Is it that the terminal line needs to be configured in such a way
to force the read() to terminate after each character is sent?  And if so,
please don't tell me to read the termio() man page one more time!

Please comment on this method for testing the Serial I/O -- I will
be very grateful for any suggestions.  

Thanks,


2. missing "Close" item onSWiM motif menu

3. Reading and writing to serial ports

4. Method for intrusion

5. serial port read/write error

6. K6 and Linux - are there problems ?

7. read/write to serial port

8. 19 inch monitor recommendations

9. read/write serial port

10. Setting serial port: read() and write()

11. How do you read/write serial port registers directly?

12. read/write serial port

13. Reading and writing to a serial port