LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert string into number of byte count for tcp ip read

Hello everyone,

 

Currently, I am working on project for tcp ip communication protocol. In tcp ip write command i can know how many bytes I have written but in tcp ip command I am not able to count how many bytes i have received at data output of tcp ip read. Only i can read how many bytes i want not actual count of bytes. There is no fuction available in labview for conversion of string into byte actual byte count (not byte array) . Can you suggest me some solution for this?

0 Kudos
Message 1 of 6
(4,537 Views)

Hi srk,

 

I am not able to count how many bytes i have received at data output of tcp ip read

As you receive a string from TCPIP-Read you could use StringLength to get the number of bytes read…

 

Can you attach a VI where you demonstrate the problem you have right now?

Best regards,
GerdW


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

I highly recommend you have a look at the STM library and see how they handle it.

 

If you have the data as a string, just use the String Length, flatten that to a string, send the length and then send the data.  On the read side, you first read the 8 bytes (I32) which will tell you how many bytes to read for the data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 6
(4,525 Views)

Hi GerdW,

 

Thank you for response. I have used string lenght. But it is giving output as same byte count as i have written for bytes to be read for tcp ip read block. It is not giving actual count of bytes.

 

For example, if i am sending 32 bytes from tcp ip write and i have given tcp ip read 64 bytes to be read. if i am attaching string length to tcp ip read data output, it is showing 64 bytes instead of 32 bytes!..

0 Kudos
Message 4 of 6
(4,517 Views)

@srk007 wrote:

For example, if i am sending 32 bytes from tcp ip write and i have given tcp ip read 64 bytes to be read. if i am attaching string length to tcp ip read data output, it is showing 64 bytes instead of 32 bytes!..


And I am guessing you are also getting twice the data as well.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(4,507 Views)

Hi  Crossrulz,

 

This is for example!... you can take value 15 instaed of 32 and any number greater than 15. It will show string length of tcp ip read (which is equal to bytes to be read for tcp ip read)..

0 Kudos
Message 6 of 6
(4,504 Views)