Read and Write Functions

To enable communications output, a port driver should provide a PortWrite function. For port drivers that use a transmit queue, the PortWrite function writes to the queue and returns immediately; an interrupt service routine actually sends the data. For port drivers that do not use a transmit queue, the PortWrite function sends the data and then returns. To enable a VCOMM client to resume transmission after a communications error, a port driver should provide a PortClearError function.

A port driver's PortTransmitChar function sends a high-priority character, such as an event character, ahead of any characters in the transmit queue. Typically, the port driver does not send the character immediately, but stores it in a special one-character buffer. The function can fail (return FALSE) if a character specified in a previous call is still waiting to be sent.

To enable communications input, a port driver should provide a PortRead function. For output-only devices, such as LPT ports, the PortRead function should simply return TRUE (success), and indicate zero bytes read. For port drivers that use a receive queue, the PortRead function should retrieve data from the receive queue and return immediately; an interrupt service routine actually reads data into the receive queue. The amount of data retrieved from the queue may be less than the amount requested. For port drivers that do not use a receive queue, the PortRead function actually reads data from the device. The amount of data read is less than the amount requested only if a read time-out occurs, in which case the return value is FALSE.

A port driver's PortGetQueueStatus function retrieves the status of the receive and transmit queues. A port driver's PortPurge function discards the contents of the transmit or receive queue.

See Also

PortClearError, PortGetQueueStatus, PortPurge, PortRead, PortTransmitChar, PortWrite