10-22-2008 09:29 AM
Hi,
I have a problem. My LabVIEW app needs to establish a TCP connection. During this connection, I need to recieve a small config, (in the form of a data word, containing one string) to make settings in my app. After this the same connection is used to receive a constant flow of data words (each data word is made up of 9 strings), until the app is closed or the connection is dropped by the other party.
Hope someone can help, I'm stumped!
Steve
10-22-2008 09:36 AM
10-22-2008 09:42 AM
Yes, I have already written the code that will establish a connection to receive a constant flow of data words, which functions fine. My problem is now I have to modify this to receive a one off data word on connection and then to revert back to a constant receive of data words.
Basically, the one off will set a mode in which the other data is used.
The only way I can think of is to establish a seperate connection, which is dropped after receiving one word. This doesn't seem to be the tidiest solution though.
10-22-2008 09:46 AM
10-22-2008 02:42 PM
10-23-2008 11:18 AM
Hi Steve,
Thank you for posting your issue. Now i understand that you need to create a system that will open on a trigger word and output data.
Have you thought about putting the receiver and transmit code in two case structures and some form of control to switch between them.
Here is a link to some information which may help you:
http://zone.ni.com/devzone/cda/tut/p/id/2710.
How else have you tried to implement your design?
Regards
10-23-2008 12:32 PM
Hi Steve
I think that the best way to solve your problem is with a kind of header that indentify the next data as a command or not.
For example I'm using TCP connections to transmit a continous flow of data and a heart beat of the connection in the midle of the data.
My way to determine wich is the data and wich is heart beat is this:
Header: 0xAA (message start)
NumOfBytesToRead: 0x04 (my heart beat message is 4 bytes)
TypeOfMessage: 0x02 (this byte tells me what are the next bytes that i'm gonna read 0x00 = Data ; 0x01 = Heart Beat ; 0x02 = Configuration Command)
DataBytes : [0x00 0x00 0xFA 0x01] (my 4 heat beat data)
CheckSum: 0xF9 (this is the checksum of the data
And for data I group 8 bytes.
Header: 0xAA (message start)
NumOfBytesToRead: 0x08 (my heart beat message is 4 bytes)
TypeOfMessage: 0x00 (this byte tells me what are the next bytes that i'm gonna read 0x00 = Data ; 0x01 = Heart Beat ; 0x02 = Configuration Command)
DataBytes : [0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08] (my 8 data bytes)
CheckSum: 0x08 (this is the checksum of the data
This way allows you to can send commands at any time and not just on the start of the connection.
I hope this can be usefull for you,
Regards.
10-24-2008 01:50 AM
Thanks for the ideas guys.
My solution, as it turned out was simple. I already had a mechanism to decypher the data word into seperate words. These words were passed to case structures and dealt with accordingly. All I had to do was modify the case structure ,that dealt with the first words, to deal with the config commands.
All seems well. I am however going to have a play with the header solution.
Thanks again.
Steve