01-30-2010 05:25 AM
Hi,
I'm trying to send an array of clusters with varible size over TCP/IP,. But I'm facing the following problems:
1) I need to accept the size of array data from the user and increase the size dynamically.
I'm doing this using the property node but how do I convey the new size to my TCP read?
2) I need to wire an input to my 'bytes to read' of the TCP read.
But the number of bytes to read changes dynamically
How do I ensure the correct number of bytes are read and reflected on the client side?
3) Is there anyway I can use global varibles over a network such that their values are updated just as if they would on one computer?
Will be a great help if someone posts a solution!
Thank you...
01-30-2010 09:33 AM
01-30-2010 10:38 AM
twilightfan wrote:2) I need to wire an input to my 'bytes to read' of the TCP read.
But the number of bytes to read changes dynamically
How do I ensure the correct number of bytes are read and reflected on the client side?
It's exactly the same as we discussed earlier: Simply prepend the data size as descibed in the link to make the actual size part of the message.
In this case you would flatten from (and then unflatten to) an array of clusters. Everything remains the same, except the data type.
twilightfan wrote:I'm doing this using the property node but how do I convey the new size to my TCP read?
I don't understand why you use a property node. Makes no sense. If the user is allowed to select an array size, wouldn't it be a control instead?
You also cannot increase an array size with a property node, you would use plain array data operations instead. (You could use a property node to increase the size of the array container for example, but that does not change the array size). 😉
(It really depends on what you are trying to do. As Putnam mentioned, a network shared variable for the array of clusters might be an alternative to the entire thing.)
01-30-2010 09:28 PM
Hi,
Using shared variables is the first thing I tried after trying to use global variables. But I could not figure out how to connect the variables in my program to the ones on the other computer. I did select the network published option and added their libraries to my projects. Is there any other configuration I have to make in order to ensure that my shared variables reflect the data correctly? I'm using 1 instance of a shared variable in the server to read the number of bytes and another instance of it to write it to TCP read in the client.I have similarly employed a second shared variable to send the bytes to read on the server side. Also, I have a third shared variable that reads the input from the user and gives the data to the property node "number of columns" of the array of clusters on both the input and the output side so that the array size changes accordingly.
How do I configure the shared variables to respond to certain IP addresses i.e. those of the client?
Thanks..
01-30-2010 09:42 PM
Altenbach,
The first thing I tried was the solution you had earlier given me. But I recieve error 74 when I try using it
with unflatten from string and error 1105 when I try to use unflatten from xml string. Also, the type constant
I need to wire to the type input of both these nodes is creating a problem as it is no longer a constant.i.e. since i'm accepting user input for my array size [esp. number of columns that I'm varying using property node so as to
dynamically create more elements in the array] is variable. But I solved these problems by using a local variable as the type input and an error handler for the unflatten from string/ xml string nodes. Still, conveying the size info to TCP read is creating a problem.
In the VI you had attached earlier, when I use TCP read twice, the second TCP read gets truncated data because
its no longer just the first four bytes that specify the length of the data, it could be more as my array of cluster
can be pretty huge. I'm kind of stuck at this..unable to figure out a few details about shared variable nodes as well!
(as mentioned above) would be a great help if you could attach an example for either solution. I'm using the
same io clusters as before but now they are present in an array each.
Thanks..
01-31-2010 03:12 AM - edited 01-31-2010 03:13 AM
twilightfan wrote:Altenbach,
... xml string. ...number of columns that I'm varying using property node s... I solved these problems by using a local variable as the type input ...o TCP read is creating a problem.... second TCP read gets truncated data because
its no longer just the first four bytes that specify the length of the data, it could be more as my array of cluster can be pretty huge.
01-31-2010 03:36 AM
01-31-2010 03:57 AM
Altenbach,
I have attached a sample VI. As you can see in this VI, there are 3 variables I need to share in a TCP/IP connection
1) The 'number of columns' variable (same for both input and output side)
2) The size of string sent from server to notify TCP read on client side
3) The size of the string sent from client to notify the TCP read on the server side.
Do try flattening/unflattening the string using actual TCP read and write nodes for the localhost, you will recieve error 74.
Thanks ..
01-31-2010 04:00 AM
As to your question regarding how big the strings are, as you will clearly see in my VI,
I have no clue until the user types in the input!
01-31-2010 11:20 AM
The "numcols" property has nothing to do with the size of the 2D array, it simply defines how many columns are visible on the front panel at the same time. It does not change the data size!
If you always want to show all columns, just get the dimension from the array size after unflattening, no need to send the information. If you want to display a different number of columns compared to the actual number of columns in the 2D array, you could prepend that number similar to what we currently do with the size. On the receiving side you would first read the size, read the remaining string, then split the remaining string at byte 4 into the substring for numcols and the cluster before unflattening each.
If you get TCP errors, please attach your actual TCP code so we can see what you are doing.
The attached modification shows how to always display all columns contained in the data. Of course don't overdo this, e.g. don't try to display millions of columns. 😉