MgslTransmit


Prototype  
ULONG MgslTransmit( HANDLE hDevice,
                    PUCHAR pBuffer,
                    ULONG BufferSize,
                    PULONG pStatus,
                    LPOVERLAPPED pOverlapped );

Parameters  
hDevice
handle to open port
pBuffer
pointer to buffer containing transmit data
BufferSize
size of transmit data in bytes. This must be at least 2 for HDLC mode (address and control field) and no larger than the max frame size. Must be no larger than MAX_ASYNC_TRANSMIT for asynchronous mode.
pStatus
pointer to ULONG to hold returned transmit completion code
  TxStatus_OK Successful completion of transmit
  TxStatus_Underrun Device FIFO underrun error
  TxStatus_Cancel User transmit abort complete
  TxStatus_CtsFailure CTS went inactive during transmission
  (*) Refer to the section entitled "Sending Data using Buffered Transmit" for additional information
pOverlapped
Pointer to overlapped structure initialized with a WIN32 manual reset event object which will be signaled when the transmit operation completes
Return Value  
ERROR_INVALID_HANDLE
hDevice is invalid
ERROR_INVALID_PARAMETER
pBuffer, BufferSize, or pStatus is invalid.
ERROR_BUSY
a request of this type is already pending
ERROR_IO_PENDING
Waiting for transmit operation to complete
ERROR_NOT_READY
if the port is configured for HDLC/SDLC Loop Mode and is not "OnLoop" when the call is made

Transmit data on the specified port. This function automatically enables the transmitter. In HDLC mode, the data is a single HDLC frame. In Asynchronous mode the data is a stream of asynchronous bytes. MgslTransmit always returns ERROR_IO_PENDING or an error status.

When the transmission completes, the API sets pStatus and signals the event object in the OVERLAPPED structure. Only one transmit operation may be pending. Calling MgslTransmit while a transmit is pending returns ERROR_BUSY.

NOTE: If MgslTransmit, returns ERROR_IO_PENDING, it is important that MgslTransmit not be called again, until the request completes. See the Caution note in the Asynchronous API Notification topic for more information.

Call MgslCancelTransmit to abort a pending transmission. In HDLC mode, the frame terminates with the HDLC abort sequence. In asynchronous mode the transmit buffer will be cleared. Monitor the event object until the transmit completes with TxStatus_Cancel. A pending transmission may complete normally after calling MgslCancelTransmit, but before the transmission is actually canceled.

If HDLC mode, even an MgslCancelTransmit request may not complete in a timely fashion. For example, assume the transmit clocks on the serial interface are absent or something else prevents the transmission of an abort sequence. If the pending transmission does not complete in a timely fashion with a status of TxStatus_Cancel, it may be necessary to disable the transmitter, using MgslEnableTransmitter.

If the port has been configured to operate in HDLC/SDLC Loop Mode, the adapter has to be inserted into the loop before a transmit operation can occur. If the application makes a MgslTransmit request and the adapter has not been inserted in the loop ("OnLoop"), the driver will return a status of ERROR_NOT_READY to indicate that the adapter is not in the loop.

See also: Sending Data, Using Buffered Transmits, MgslEnableTransmitter, Asynchronous API Notification, HDLC/SDLC Loop Mode


Previous Contents Next