LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Various message length in serial port communication

Hi all,

 

I have a following problem. I am using LabView to communicate with a device over serial port. The device should not be asked more frequently than once a second. I am sending a question and should get an answer looking as follows:

 

FC 00 09 xxxx 4352

 

where xxxx should be 9 bytes long. Unfortunaltely the message has a various length - it always has a prefix and a tail but the length of part xxxx is various. I have already found this:

 

http://digital.ni.com/public.nsf/allkb/2D5F972CD550BBC386256F0B005E9A63

 

How can I cope with that problem? I enclosed a screenshot of a vi block diagram.

0 Kudos
Message 1 of 28
(3,792 Views)

I would remove the delay before the serial read, and set the bytes to read to a large number so you can get all available data back from the device. Then you might see what the device is trying to send.

0 Kudos
Message 2 of 28
(3,782 Views)

Thank for a reply.

 

How to set the bytes to read? In which block function?

0 Kudos
Message 3 of 28
(3,779 Views)

Use a Property Node set to Bytes at Port.

 

Your first post has a contradiction: You say xxxx should be 9 bytes long and then you say the length of the xxxx portion varies.  Which is correct?  Is the 09 byte preceding xxxx actually a "length of data" byte?

 

Is the "tail" always 4352? Is there a termination character?

 

What kind of device sends this data? Do yuo have documentation of the communications protocol?

 

There may be easier ways to approach this.  Please give us as much information as you can.

 

Lynn

Message 4 of 28
(3,776 Views)

OK, i will add that property node.

 

There should be 9 bytes at xxxx but in fact the number of bytes is different every time I read a message. The tail is always 4352 and there is no termination character (or I don't know anything about that).

 

This data is sent by a temperature controller which I am using. It is not a mass product, and I have a documentation only in Polish. Should I send it?

0 Kudos
Message 5 of 28
(3,776 Views)

Most of us do not read Polish, so do not post it unless someone specifically requests it.

 

You can use Match Pattern to search for the 4352 and another one to search for the prefix string.  The string between the two search strings will be your data string.

 

I suggest that you look through the documentation carefully to see if it explains the variable number of bytes.  That variation could make it difficult to interpret the result.

 

Lynn

Message 6 of 28
(3,766 Views)
I have already used matched pantern and this is how i know this results. The doxumentation says clearly about nine bits.
0 Kudos
Message 7 of 28
(3,763 Views)

If it is always sending 9 bytes, I do not understand why you sometimes see more.  Can you post some data where you see varying numbers of bytes?

 

Lynn

0 Kudos
Message 8 of 28
(3,760 Views)

That is the problem. I don't understand this either.

 

I attached few screenshots of buffer - you can see that the number of bytes is random.

Download All
0 Kudos
Message 9 of 28
(3,741 Views)

It looks like the extra bytes are always 00.  This suggests that default values are getting in somehow.

 

1. How are you configuring the port? Handshaking? Termination character enabled? Timeout?

2. Do you get any errors? What are they?

3. Try connecing an indicator to the "return count" output of the Read.  Does the count match the size of the strings you see?

 

Lynn

0 Kudos
Message 10 of 28
(3,728 Views)