ADU  Series - USB Data Acquisition Interface SDK 

Timeout Processing

The default behavior of ADU pipes is to wait (block) until a read or write operation completes. This may make the application appear to be "hung" while it waits for I/O.

The AduHid DLL provides the capability to use timeouts for reads and writes.

Activate timeout processing by supplying a non-zero value for the iTimeout argument when an ADU pipe is opened.

        HANDLE hDevice;
        hDevice = OpenAduDevice(1);

Any non-zero value for iTimeout will activate the timeout processing.

On every read and write supply the iTimeout in milli-seconds as the fifth argument.

        iRC = WriteAduDevice(hDevice, "RK1", 3, 0, 500);

The above call waits 500 milli-seconds for the write operation to complete. If the waiting period expires then 0 is returned to the iRC field. Calling GetLastError immediately after a timeout will yield an error code of 1460 (ERROR_TIMEOUT).

All pending I/O operations for the pipe are cancelled when a timeout occurs. This applies to both write and read operations. (eg. if a read times out then all pending writes and reads on the pipe are cancelled).

When I/O operations timeout the program will have to take appropriate action to retry or inform the user of trouble.

An alternative to timeouts is multi-threading, but that is beyond the scope of this document.

NOTE: The iTimeout parameter must be zero if timeout processing was not activated during the opening of the pipe.

NOTE: Each pipe has its own timeout property. For example the ADU Device pipe may be using timeouts while the ADU Stream pipe is in blocking mode.