Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Large data from serial port

Hello,

 

I'm trying to read data from an instrument using serial port.  for my test file I'm using labview example, I attached its block diagram, the file name is "Basic Serial Write and Read_1 bit.vi".

 

as I said this is built it Labview example.

 

when reading small data such as temperature it works great.

when reading large data such as log set - not so great.

 

the default delay time between write and read is 500. If I reduce it I read less data then available. if I Increase it - I'm able to do this up to 580 - when I go to 600  I get an error:

 

"VISA:  (Hex 0xBFFF006C) An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived."

 

what is the problem and how to solve it? this is happens at LabView Example file...

 

 

0 Kudos
Message 1 of 6
(9,075 Views)

In your application, you need to wait until the buffer is full before reading the data.

If you write more data than fits in the buffer you get buffer overflow.

 

In a real application you read while the data is filled (you want to know how much data, or you use an endcharacter that signals the end of the data) and you try to read as fast as possible so that the buffer is not filled up.

 

What kind of data are you trying to read?

greetings from the Netherlands
0 Kudos
Message 2 of 6
(9,063 Views)

I'm trying to read log data from my instrument.   I don't knwo how much bytes it is exactly.

 

I understand your point but I don't know how to deal with it...

 

when I modify the delay between write and read operation I get less bytes. for delay of 500 I get about 4096 bytes, for 550 I get more data, for 580-600 - an error.

 

also I used read byte at port to read the entire buffer.

 

should flushing the buffer before operation should help?

 

how can I solve this to get more than 4096 bytes. I think I read something at changing (increasing) the default time of the read session, how do I do that?

 

 

0 Kudos
Message 3 of 6
(9,061 Views)
What is the instrument and have you set the enable termination character to true?

The example and your code has several flaws. For one, it only ruins once and then stops. You should NOT be using the ruin continuous button. Your write and read must be inside a loop. Second, using the bytes at serial port is almost always a mistake. Most instruments append a termination character and you simply set the read byte count to some arbitrarily high number. The read automatically ends when the termination character is detected. That also eliminates the silly fixed wait. The timeout value is changed with a VISA property node.

Are you sure you need 100 ms between characters during the write? It's that from the manual or from testing in a terminal emulation program such as hyperterminal?
0 Kudos
Message 4 of 6
(9,054 Views)

Do you know how much data (number of bytes) you are supposed to get back from the instrument?

 

What you really need to do is put the read into a WHILE loop.  Try to read something like 1000 bytes per iteration.  Loop until you get less data than you tried to read.  You will need to concatinate the strings to give you your full data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(9,043 Views)

串口接收有一个缓冲区,默认是4096个字节。你这种情况是 缓冲区溢出了。至于为什么溢出,你可以自己想想原因。对方发送太快,你接收处理的太慢。

0 Kudos
Message 6 of 6
(6,716 Views)