LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timeout error even after a good session

In my vi, I make a serial connection to a device with a time out of 10s. Even when the connectios is succesfull, after 10 seconds, I have a time out error.

Does somebody have an idea what I do wrong?

Untitled.png 

0 Kudos
Message 1 of 5
(2,802 Views)

Hi Thomas,

                  This error can occur when you read or write large amounts of data, as large data sets often take longer than the default timeout period of 2000ms to transfer across the serial port. For VISA Read operations, this error may be induced by attempting to read more bits than are available at the serial port.

So try increasing the number of bytes read.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
0 Kudos
Message 2 of 5
(2,800 Views)

Since you have wired 100 as byte count in the read function,it would wait for the predefined time (10 secs) in your case expecting to get 100 bytes of data .

 

If its not able to get 100 bytes then it generates error.

 

Generally when i dont know the number of bytes that will be read from the serial port i generally read the bytes available at the port and wire to the read function

 

 

Bytes at port.png

0 Kudos
Message 3 of 5
(2,792 Views)

@nijams wrote:

Since you have wired 100 as byte count in the read function,it would wait for the predefined time (10 secs) in your case expecting to get 100 bytes of data .

 

If its not able to get 100 bytes then it generates error.

 

Generally when i dont know the number of bytes that will be read from the serial port i generally read the bytes available at the port and wire to the read function

 

 

Bytes at port.png


Using the above code, you would need to put this in a while loop to keep reading until the Bytes at Port = 0.  If you KNOW that the data terminates with a certain character AND this is text, and NOT binary, you can always enable the termination character in your serial port setup and simply set up the VISA read with a byte count greater than what you are expecting (like the 100 you specified) with no while loop.  If the termination is more than one character, you could always key on the last character and clean up the whitespace afterwards.

 

However the code quoted above will ALWAYS work for EVERYTHING.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 5
(2,772 Views)

I don't know what you are defining as a 'good session'. You can have nothing at all connected to the pc's serial port and you will get the exact same timeout. Your code makes little sense since you have a VISA Read and nothing connected to it's string output. Why?

 

Your code could have multiple reasons for getting a timeout. Did you do any sort of verification on the com settings, cable used, or command sent? I would suggest you do some basic debugging with a program like Hyperterminal or in MAX before you start writing any code.

0 Kudos
Message 5 of 5
(2,765 Views)