LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

configuring using TCP connection

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

0 Kudos
Message 1 of 8
(3,476 Views)
Can you explain how to mean to receive this small config?  Is this actually a transaction over the connection you have just opened?
0 Kudos
Message 2 of 8
(3,472 Views)

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.

0 Kudos
Message 3 of 8
(3,469 Views)
I don't know of any way to communicate in the connection phase.  Could you just add a step after the connection to communicate the config data and then proceed with the streaming?
0 Kudos
Message 4 of 8
(3,466 Views)
I guess I don't understand the issue you have with the connection.

When your application starts, you would use the TCP Create Listener to sit and wait until somebody connects to it.
Once the connection is established use the first Word that comes across the socket as your configuration word and any subsequent data as your 9 data words.

As an alternative, you could preface your data word with a unique header. This header would identify the word as the confguration word or data word(s) and the software would respond to it appropriately.
Greg Sussman
Sr Business Manager A/D/G BU
0 Kudos
Message 5 of 8
(3,439 Views)

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

Jordan Power
Applications Engineer
National Instruments
0 Kudos
Message 6 of 8
(3,414 Views)

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.

0 Kudos
Message 7 of 8
(3,408 Views)

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

0 Kudos
Message 8 of 8
(3,398 Views)