LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

random read from serial port

Hi,
I want to read data from serial port, the data is sent randomly, the length of data is 120 bytes. I made a VI according to the example of LV7.1.
but some bytes is lost sometime,thanks. 
0 Kudos
Message 1 of 8
(3,391 Views)

Your question is very general.

I suggest you post your VI and give some more details about what kind of system you have (the instrument on the other side), what you expect to get and what you actually get.


___________________
Try to take over the world!
0 Kudos
Message 2 of 8
(3,376 Views)
Hi,
the instrument on the other side is a data taker made by ourself. it sends data randomly to PC or responds to PC's instruction. The data is like this
@04RD00030098E7FF8000018580F30B8F62170727150103010500F80000000007271600F8010500F60000000024*
sometime what I recieved is like this
@04RD00030098.
0 Kudos
Message 3 of 8
(3,374 Views)
We still need you to post your VI.
 
When you write a message, you will find an Attachment field hiding (it's under the Submit Post button), which you can use to attach your VI.

___________________
Try to take over the world!
0 Kudos
Message 4 of 8
(3,368 Views)
Are you using Bytes At Port to get the number of bytes to read?  If not, you could be reading just part of what is there.  Here is an example that I recently posted on using the serial port.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 8
(3,356 Views)
Is the Read function set to terminate on a Termination Character? Your example suggests that tha data stream may contain any character. If read is set to terminate on Carriage Return (0D) and that byte shows up in your data, the read will end. Use no termination character and read the number of bytes available at the port as tbob suggests.

Lynn
0 Kudos
Message 6 of 8
(3,346 Views)
here is my vi.
0 Kudos
Message 7 of 8
(3,328 Views)
As I mentioned above the VISA Configure Serial Port defaults to terminating read on a character, \n = 0xA. Here is an excerpt from the help file:

"termination char calls for termination of the read operation. The read operation terminates when the termination char is read from the serial device. 0xA is the hex equivalent of a linefeed character (\n). Change the termination char to 0xD for message strings that terminate with a carriage return (\r)."

If your data stream can contain the character 0xA, the read will terminate when that charater is received. If all 256 possible bytes may occur in your data, wire a False constant to the Enable Termination Char (T) input of the VISA Configure Serial Port VI.

Lynn
0 Kudos
Message 8 of 8
(3,311 Views)