LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquiring Data through serial port

Solved!
Go to solution

Hi,

I am acquiring data through a serial port. I have to acquire 25 different data packets with different headers. 22 of the packets are 90 bytes each while the remaining 3 are 30 bytes each. For example:

Packet 1: $SM123........89 (header=$SM, total bytes = 90)

Packet 1: $FG123........89 (header=$FG, total bytes = 90)

.

.

Packet n: $XY123........89 (header=$XY, total bytes = 90)

Packet n+1: $YZ123........29 (header=$YZ, total bytes = 30)

I can acquire a data packet with the same header, but can't do with all the headers. 

0 Kudos
Message 1 of 6
(154 Views)
Solution
Accepted by topic author Hameed97

Hi Hameed,

 


@Hameed97 wrote:

I am acquiring data through a serial port. I have to acquire 25 different data packets with different headers. 22 of the packets are 90 bytes each while the remaining 3 are 30 bytes each. 


Do those messages come with a (well-defined) TermChar?

Why not use that TermChar and request ALWAYS 100 bytes from VISARead?

 

When there is no TermChar: read just 3 bytes to receive the header ("$xy"), then read the number of bytes expected for that header…

 

Do you know this excellent video?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(131 Views)

Hi,

I have to acquire different data packets with different data lengths and different header Bytes. For example,

packet 1: $HA123....89 (3 header bytes, total length: 90) 

.

.

packet 15: $MN123....29 (3 header bytes, total length: 30)

...

packet 24: $YZ123....49 (3 header bytes, total length: 50) 

How can I do this. 

0 Kudos
Message 3 of 6
(86 Views)

Hi Hameed,

 

instead of high-jacking very old threads you could also answer questions in your own thread!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(70 Views)

Hi GerdW,

 

There is no TermChar,

 

"When there is no TermChar: read just 3 bytes to receive the header ("$xy"), then read the number of bytes expected for that header…"

 

This simple solution worked very well.

The video you mentioned is also very useful.

Thanks

 

Best regards,

Hameed

0 Kudos
Message 5 of 6
(32 Views)

HI GerdW,

 

Yes, you are right, I should have followed my thread instead of following an old thread.

 

 

Best regards,

 

Hameed

0 Kudos
Message 6 of 6
(31 Views)