LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/IP sending integers

We want to communicate with a server from CRIO-9082 using TCP/IP. The server  
can only send and receive integers and I know the TCP functions in LabVIEW can  
only send and receive strings. Is there a way to solve this problem? We don't  
have control over the server. Thanks

0 Kudos
Message 1 of 3
(4,744 Views)

Hi yaoyuc,

 

May I ask if you can provide a code which you have created on this project? May I know the setup of your project? Is the server using LabVIEW as well? What is your LabVIEW version and what do you mean by you have no control over the server?

 

If you want to send integers using TCP/IP functions, I suggest that you should convert that integer into string and at your server side (if it uses LabVIEW), you need to revert the steing back to integer. To do this, you'll need to add some functions before the TCP read and TCP write functions.

 

Before the TCP write, you'll need to convert integer into string by using Format into String function (Functions Pallate >> String). 

 

Before the TCP read, you'll need to convert that string into integer by using Scan from String function (Functions Pallate >> String)

 

I suggest that you should use Quick help (Ctrl+H).

 

Hope it helps

 

Warmest regards,

Lennard.C

Learning new things everyday...
0 Kudos
Message 2 of 3
(4,723 Views)

Hi,

 

TCP does not know the difference between strings and integers. It just sends bytes. LabVIEW's TCP Write.vi interprets the input string as an array of bytes.

 

Use Flatten to String to reinterpret your integers as bytes, then pass the "byte string" into TCP Write.vi. Make sure you:

  • Set prepend array or string size? to FALSE, or else extra data will get added
  • Find out the integer width that the server expects (how many bytes per integer?)
  • Find out what byte order the server expects (little-endian or big-endian?)

 

If you want to see the bytes in a string, right-click the string constant/control/indicator and select "Hex Display"

Certified LabVIEW Developer
0 Kudos
Message 3 of 3
(4,717 Views)