LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to send more then one data via tcp

Solved!
Go to solution

well guys

now i'm at work

so i will upload the VI's so you can take a look

and maybe try to help me!

 

 

Download All
0 Kudos
Message 11 of 43
(1,140 Views)

only one more question guys

i'm using it to test at the same PC

but when i finish this process

i will test it like

the server here and the client at another place

so it will work, right?

i only need to chance the IP at server

and then connect the client with this IP and port?

 

thanks

0 Kudos
Message 12 of 43
(1,135 Views)

Here is your problem: when you flatten to the string, LabVIEW prepends the length of the array (the number of items in the array).  However, the length you actually need is the number of bytes in the string.  Since you have an array of single-precision (32-bit) values, you need to multiply the length by 4.  Alternatively you could send the "prepend array or string size" input to false, and send the actual string length, similar to the example Mike sent using typecast.  Also, you need to set the initial length to 4 bytes (your code has it set to 6) since you want to read a single 32-bit (4 byte) value containing the number of bytes to read following that.

 

Finally, your for loop is generating an empty array, but I don't think that's causing you serious problems if you're just testing and don't care about the values.

0 Kudos
Message 13 of 43
(1,110 Views)

well thanks for your answer nathan!

i think i understand what are you talking about

but could you upload a screen shot or a vi?

so i can see it and understand better!

 

and yes, the for loop isn't a problem for me because is only for a test...

i already have another software that calculated it too me

i only put it there to show that those numbers that will appear on singles are variables

 

i will try change my code to typecast so, but if u can upload a screen shot with my error

or a vi correcting me it will be perfect!

 

0 Kudos
Message 14 of 43
(1,108 Views)

well nathan

i put a false constant on client at "data includes array or string size"

and the error don't appear anymore, but when i change the value of amostragem

the value of the client don't change, stay "0"

 

and when i put the false constant at server and client i receive an error of

"not enough memory to complete this operation"

Error 2 occurred at TCP Read in teste 3 - client.vi

Possible reason(s):

LabVIEW:  Memory is full.
=========================
NI-488:  Write detected no Listeners.

 

so i don't understand it very well!

0 Kudos
Message 15 of 43
(1,103 Views)

Here are the two approaches I described.  You should only use one of them; if you do both of these your code still won't work.  In both cases you must set "data includes array or string size" to false in the client.

 

1. Multiply the length by 4 (the size of a single-precision value).

 multiply size by 4.png

2. Prepend the actual string length, instead of the number of values in the array.

prepend string length.PNG

Message 16 of 43
(1,085 Views)

ok nathan now it works and don't have any error

but one thing is... when i change the single "amostragem" at server.. on the client the value don't change, this problem is because on the array i can put only one type of information? like only indicators or only controls?

because i have 6 indicators ( 3 voltages and 3 currents ) and 1 control ( amostragem )

that control is only to see if the client is receiving the information from server.....

because the for loop is only for example so all the values are "0" too

 

could you explain me that?

thanks

0 Kudos
Message 17 of 43
(1,082 Views)
I'm not seeing that problem when I run your code.  When I update amostragem on the server I see the new value on the client.  Can you upload your current version?  I am missing your RMS subVI, but that should not make a difference.  Have you probed your wires to see if it is being sent?
Message Edited by nathand on 08-20-2009 11:16 AM
0 Kudos
Message 18 of 43
(1,079 Views)

i already probed it and the server is sending the correct value but when it read at client it reads 0 to all the values...

and yes the subvi rms don't change anything... but i will send to you my current version and maybe you can see where is my mistake now!

 

thanks for all the help nathan!

Download All
0 Kudos
Message 19 of 43
(1,071 Views)
Your server doesn't match either of Nathan's examples.

Look at #2. When he sets the preprend array size to False (as you are doing now), he also calculates the length of the string and puts that in front of the string.
0 Kudos
Message 20 of 43
(1,065 Views)