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)

 

0 Kudos
Message 1 of 20
(349 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
Message 2 of 20
(332 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
(319 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)

0 Kudos
Message 4 of 20
(275 Views)
Highlighted
Solution
Accepted by 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
Message 5 of 20
(270 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
(254 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
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 7 of 20
(250 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
(245 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.

0 Kudos
Message 9 of 20
(215 Views)

Kindly help me perfect on the server side.

Vi.png

0 Kudos
Message 10 of 20
(203 Views)