04-07-2014 02:31 AM
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...
04-07-2014 06:31 AM
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?
04-07-2014 06:44 AM
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?
04-07-2014 07:38 AM
04-07-2014 02:56 PM
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.
03-20-2016 02:25 AM
串口接收有一个缓冲区,默认是4096个字节。你这种情况是 缓冲区溢出了。至于为什么溢出,你可以自己想想原因。对方发送太快,你接收处理的太慢。