ComAcqReceiveBytes

This is a special function which is a one-step ComAcquire and ComReceiveBytes call. The parameters are nearly identical to ComReceiveBytes; the only difference is the addition of MinRequired. Note that errors relating to port acquisition and a "short read" may be returned.

ComAcqReceiveBytes attempts to acquire the port non-exclusively, so the caller is responsible for gaining exclusive port access if it is appropriate. If the port cannot be acquired, the acquisition error is returned. Non-exclusive acquisition is requested, as this function is provided for subsystems that need to poll for receive data. Note that the companion function, ComAcqSendBytes, does gain exclusive access because it will typically be called after polling for and finding an appropriate message.

In operation, this function first checks the receive buffer to see if the minimum number of bytes the caller requires is present. If not, then the error ESHORT is returned. If the required minimum is available, the call copies data from the communication buffer to the caller's buffer, up to the caller's specified maximum number of bytes. Copying fewer bytes than the caller specified maximum is not an error; neither is copying bytes up to the caller's maximum and leaving some in the communication buffer.