LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Comwrt isn't sending anything until a Comread is called. Why?

   I was struggling with this yesterday. I called a bunch of comwrt functions and nothing was being sent out of the com port (despite adding a reasonable amount of delay time afterwards). I eventually found out that the output is sent only after a comread is called. The problem is that some parts of my application write to the com port and don't receive anything back. This causes the comread function to pause for several seconds because nothing is read. Why isn't the comwrt function alone good enough. Is there anything else that I can call to force the port to physically output what it has in its buffer?
0 Kudos
Message 1 of 2
(3,172 Views)
Unless you explicitly specify not to use an intermediate output queue, the actual buffer to port transfer occurs in a separate thread. In this scenario, ComWrt just buffers data to be transferred by a worker thread. I would expect that given enough time for Windows to switch active threads (you mentioned adding a delay), your bytes would be written. That said, I would try changing the way you open the port: call OpenComConfig and pass -1 as the output queue size. This will cause ComWrt to push data directly to the port, rather than using the library's intermediate buffer and worker threads.

Mert A.
National Instruments
0 Kudos
Message 2 of 2
(3,165 Views)