I wish to terminate a request for reading data (viReadAsync) from a serial port. In my multi-threaded program, I have one thread waiting indefinitely for something to arrive on the port. I wish to terminate the request from another thread by calling viTerminate. The call to viTerminate works just fine: it forces the pending viWaitOnEvent to return. However, viWaitOnEvent returns VI_SUCCESS, which gives no indication why it returned (terminated? received data?). How can I determine why viWaitOnEvent returned?
I have tried viGetAttribute with VI_ATTR_STATUS with the VI_EVENT_IO_COMPLETION (returned VI_ERROR_INV_OBJECT), the session (returned VI_ERROR_NSUP_ATTR), the context (returned VI_ERROR_INV_OBJECT), and the job ID (returned VI_ERROR_INV_OBJECT).
I have also tried to get the number of bytes read with VI_ATTR_RET_COUNT. The session fails (returned VI_ERROR_INV_OBJECT), VI_EVENT_IO_COMPLETION fail (returned VI_ERROR_INV_OBJECT)...