News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

serial port buffers

Started by redskull, October 04, 2006, 04:24:13 AM

Previous topic - Next topic

redskull

I'm new to the process of treating comm ports like files, so some windows serial port methodology escapes me.  Does serial port input get stored in a buffer, and then read out of the buffer using ReadFile?  If so, does it work something like Console input buffers?  Hypothetically, if I opened a connection, and input came in, but I never used ReadFile, would it just stack up in there indefinitly?  If I set all the time-outs to zero, and make a call to readfile, and no data has come in, will it just stay hung in the ReadFile function until something does?  If I only read in 1 byte, and 4 bytes have come in, will the other three be there waiting for me later?  Does 'asynchronous' (overlapped) file i/o have anything at all to do with 'asynchronous' serial port operation?  Am I anywhere near the right track?

as always, you guys are awesome for putting up with such ridiculous questions.

alan
Strange women, lying in ponds, distributing swords, is no basis for a system of government

agathon

Hi,

Synchronous serial communication is a protocol which is usually realized in hardware. The serial device speaks to another serial device continuously Communication is established at power up. The transmitter comes up and begins sending a continuous stream of SYNC characters. When the receiver comes up, it monitors the serial line bit by bit until it recognizes a SYNC character. The receiver then switches into a mode in which each block of eight (for instance) bits is transferred into a receive buffer unless it is a SYNC character. SYNC  characters are discarded. The transmitter sends SYNC characters until it receives input from its driver. It transmits characters on the serial line until it has no more characters to send, then reverts to sending SYNC characters. In contrast to asynchronous serial communication, synchronous serial communication requires no start or stop bits, therefor maximizing the efficiency of the serial link.

In asynchronous serial communication, the transmitter is silent until its driver sends it characters to transmit. The asynchronous transmitter prefixes some number of start bits, and appends some number of stop bits, to each character that it sends. When it has no character to send, it is silent.

As you can see, the asynchronicity of asynchronous serial communication is unrelated to the asynchronicity of asynchronous file i/o.

Hope this helps,
Cordially,
RWM