Accessing the TX device driver using Windows

The CPI library uses standard Windows routines to access the TX kernel mode device driver. The interface between the library and the driver is based on a Windows file handle. The library opens a channel like a file, reads from and writes to the driver like a file, and closes the channel like a file.

The host can receive packets asynchronously. Windows provides standard mechanisms for receiving unsolicited packets. The library posts read calls to the driver that do not block. The application can then use Windows WaitForSingleObject or WaitforMultipleObjects to determine when those reads complete with a received packet from the TX device. Use cpi_wait_obj to retrieve the handle to pass to these Windows calls. Pass zero in the dwTimeout parameter, which is equivalent to polling for packets, to tell Windows calls to return immediately. The same parameter can be set to infinite, in which case it does not return until there is a packet (when using WaitForSingleObject) or one of the list of handles had something to report (when using WaitForMultipleObjects).

A flow control mechanism queues TX board messages on the board if the host-based application does not service received packets quickly enough. The flow control mechanism removes the possibility of the TX driver needing to drop received packets. A similar mechanism exists for packets sent from a host-based application to the TX board.