LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP - Flatten, Unflatten string error

Solved!
Go to solution

Hi,

 

I have developed code using TCP Protocol to pass a string and the status of a Boolean signal. I am facing an issue and unable to fix it. Any help will be appreciated. Attaching both the client  and server vi(error faced)* here. Thank you.

 

*error faced in tcpServerTest.vi (attached)

 

Download All
0 Kudos
Message 1 of 20
(1,321 Views)

You are only reading 2 bytes.  Your string will contain at least 4 bytes since the length is prepended as a U32.  A common thing to do here is to get the length of your flattened string and transmit that first.  Then the client reads 4 bytes (I32) to get the length and then read that number of bytes.  You can then use the Unflatten From String on your read data to get your cluster value.


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
Message 2 of 20
(1,304 Views)

Vi.png

While trying to implement based on your advise, I am doing something wrong here. Could you throw some light on the same? Help in the form of screenshot or vi. 

0 Kudos
Message 3 of 20
(1,291 Views)

I further improved the code like this. Kindly look at both the client and server vis and help me perfect the code. (I guess changes needs to be done on the server side)

Download All
0 Kudos
Message 4 of 20
(1,247 Views)
Solution
Accepted by topic author salauddin

@salauddin wrote:

While trying to implement based on your advise, I am doing something wrong here. Could you throw some light on the same? Help in the form of screenshot or vi. 


 

On the client side, you first read 4 bytes to get the length.  Unflatten that value to an I32 and wire that directly to the next TCP Read to read 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
Message 5 of 20
(1,242 Views)

I am trying to implement this but unable to locate this bundling terminal in my palette (I am fairly new to LabVIEW).

salauddin_0-1578929320876.png

 

Kindly mention the name of the bundle functionality mentioned in your code(find screenshot below) so it will be easy for me to locate.

salauddin_1-1578929346588.png

0 Kudos
Message 6 of 20
(1,226 Views)

Hi salauddin,

 

hint: that "bundling terminal" is getting two strings as input and gives one string as output.

Have you looked into the string functions palette?

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
Message 7 of 20
(1,222 Views)

@GerdW wrote:

Hi salauddin,

 

hint: that "bundling terminal" is getting two strings as input and gives one string as output.

Have you looked into the string functions palette?


You could even say it stiches, links or concatenate the strings. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 20
(1,217 Views)

Dear GerdW, thanks a lot that I have perfected the code on the client end. Kindly help me perfect the code on the server end as well. Thank you so much in advance.

Download All
0 Kudos
Message 9 of 20
(1,187 Views)

Kindly help me perfect on the server side.

Vi.png

0 Kudos
Message 10 of 20
(1,175 Views)