LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial read block

I am using Labview8.2. I have developed a vi which receives the data serially. I have to receive different number of bytes while the vi is running. The problem is that when I give a certain value(say 64) to the control "bytes to read", the read block reads the same number of bytes for the first time i.e. the indicator "return count" shows 64 but when i change the value of  control "bytes to read" to some other value(say 24) it goes on to read the same 64 bytes and the indicator "return count" also shows 64. I have placed it in a while loop. After sending the same data of 24 bytes twice or thrice the indicator "return count" changes its value to 24 but still it reads wrong data. Can u please give any suggestion to solve this problem?
 
Thanks
0 Kudos
Message 1 of 7
(3,225 Views)
Hi!
   Can you post your code? Possibly a picture of it, since I have LV 7.1 Smiley Happy

graziano
0 Kudos
Message 2 of 7
(3,221 Views)

I agree with Graziano -- please post your code.  The "bytes to read" should not be a control, it should be a property node.  See below.  The reference input to this property node should be the comm port you are reading.

 

Tom



Message Edited by Tom Haggerty on 01-03-2008 07:07 AM
0 Kudos
Message 3 of 7
(3,202 Views)
Hi Tom,
   I suppose it was meant "byte count" terminal?

   

graziano


Message Edited by Graziano on 01-03-2008 07:09 AM
0 Kudos
Message 4 of 7
(3,190 Views)

Thanks Graziano.  You are right.  This means that there might be a delay in the serial read.  If you specify 64 bytes to read and there are not 64 bytes at the port to be read, it will wait until there are 64 bytes before it completes.  If you change the control while it is still waiting for the 64 bytes to read from the last "request" it will read the 64 bytes and then start reading 24 with the next read.

 

This is one of several scenarios that could be occurring.  Without knowing the specific application, this is my best guess!

 

If you want to seperate the data coming in from the serial port, it would probably be better to read all (or if it is streaming) a fixed amount of data all the time and splitting up the data by another method after you have it read.

 

I hope this helps!

Tom

0 Kudos
Message 5 of 7
(3,186 Views)
I'd suggest to overcome this problem, if possible, using "serial end for read: Termination char" property....

...anyway, still waiting for the code Smiley Tongue

graziano
0 Kudos
Message 6 of 7
(3,178 Views)
thaks for ur suggestions. i'll try to solve it by the methods that u people have suggested and will let u know if i get any further problem...
(sorry i mentioned the wrong name of the control. Yes! it is "byte count" and the indicator is "return count")
0 Kudos
Message 7 of 7
(3,157 Views)