10-08-2013 07:51 PM
Hi,
im trying to use labview to gather the log file of a device. The device will continuously sends logs if it is available.
The problem is,i occasionally receives junks data.refer to attached screenshot for example.
im using single while loop controlled by a button. Inside the loop,it will initialize the port and open it.
Then using the bytes at port property,it will read the available data at port using the visa read.
I cant give any screenshot for my block diagram yet because its not accessible from my company pc.
any help would be much appreciated
Solved! Go to Solution.
10-08-2013 08:01 PM
oh yeah,some extra info about the data that is sent by the device..
The lenght and time interval is not fixed. If someone wonder why im using the byte at serial port to read,this is why.
If i preset the lenght to be read,it will cause some delays because sometimes even by using the byte at port method, there will be 0-1+++ byte for a single read cycle
10-09-2013 07:54 AM
here's a snapshot of my block diagram
10-09-2013 09:25 AM
Don't open and close the VISA session inside the while-loop.
Does the respond from your device have any Termination charactor ? If yes, use that and NOT the Bytes at port
10-09-2013 09:53 AM
Next time, please post your VI instead of a picture, especially when you have case structures with invisible states.
Several things come to mind:
First the good part. There's nothing wrong with using the Bytes at serial port function to know when something's there to read if you don't have a termination character (the serial communication for our instruments actually uses two characters for termination because of our particular circumstances, so we have to use BaSP also).
Now the other stuff.
You are opening and closing the serial connection every time you read something. Just open it initially and close it after the loop is done. It's wasting a lot of effort, not to say time.
It's a lot easier to concatenate an ongoing string by using a shift register than a local variable (I think that's what you have, it's kind of small for me to see).
Get rid of the sequence structure. You have your actions connected by wires (although most of us would advise also connecting them with error cluster wires, so you can know what went wrong if it did), and that will enforce the sequence of actions through dataflow.
The property node stuff in the second sequence frame doesn't make much sense to me (but maybe that's just me), and it also is not synchronized to the indicator it's involved with, so there's a big possibility that it's not doing what you want it to.
Do you realize that you pass the number "80" as your mask in the VISA Flush? (Stick an indicator in there and check it out.) That is not a number it knows what to do with. Why are you flushing anyway?
I've attached a simple W/R VI, the Write part is simple primarily because you didn't give any information about your write function, we'll have to hope that you can just stick yours back in.
Cameron
10-09-2013 01:37 PM
10-09-2013 02:25 PM
>> I disagree about using the byes at serial port. If there are two termination characters, use the last and then just remove the very last character.
What if data can include that last character inside? Anyway you will need to check if it is really message end and concatenate data.
10-09-2013 02:29 PM
10-09-2013 02:36 PM
@Dennis_Knutson wrote:
I disagree about using the byes at serial port. If there are two termination characters, use the last and then just remove the very last character.
Doesn't work in our case, not with binary data and with an autonomous instrument which sends the string to the PC, which always has to be ready to catch it. Maybe I wasn't clear, we are using special encoding and a two-character "termination character" because of it.
Cameron
10-09-2013 02:39 PM
Data are spoiled because you flush everything you receive between bytes at port and flush buffer. Sometimes it is nothing and you get data you expect.
Reading removes read bytes from the buffer, you do not need to flush it.