Jump to content

TCP/IP (Java/ LabVIEW)


Recommended Posts

Hi all!

After some time working on the TCP/IP communication between Java and LabVIEW I have decided to post a question to hopefully get an answer on my issues.

The intention is to use LabVIEW to control some basic I/O operation according to instructions given via TCP/IP from Java (Server) to LabVIEW (Client). The connection itself works, but LabVIEW receives not the correct data/ or receives it in a wrong format :-) I have already had a look at National Instruments website: http://zone.ni.com/devzone/devzoneweb.nsf/...6256ED800706823 and I like the described concept.

From the Java side the main method looks like:

byte[] b = new byte[80];

80 Bytes, because I would like to send the following information:

Byte 0..3 (Packet Size)

Byte 4..5 (Data Type)

Byte 6..9 (Data -> 32 Bit Integer)

Socket client = server.accept();

OutputStream out = client.getOutputStream();

out.write(b);

LabVIEW:

I am using LabVIEWs TCP Read function with 80 bytes to read preset.

My question:

  • How can I make sure to receive the data in a way that I can work with it within LabVIEW? I have already tried to endianize the data within Java but it didn't work out.

It would be great to hear from you soon.

longestral

Link to comment
From the Java side the main method looks like:

byte[] b = new byte[80];

80 Bytes, because I would like to send the following information:

Byte 0..3 (Packet Size)

Byte 4..5 (Data Type)

Byte 6..9 (Data -> 32 Bit Integer)

Socket client = server.accept();

OutputStream out = client.getOutputStream();

out.write(b);

LabVIEW:

I am using LabVIEWs TCP Read function with 80 bytes to read preset.

My question:

  • How can I make sure to receive the data in a way that I can work with it within LabVIEW? I have already tried to endianize the data within Java but it didn't work out.

You must be doing something wrong with endianizing or such. But this shouldn't be that difficult to figure out. Just go debug on the LabVIEW side! Look at the data you read from the TCP/IP socket and display it in a string control. Now play with the display mode of that string control and look at what you can see. In Hex mode you definitely should see a pattern you can then further trace to see what might be wrong.

While endianizing in Java might be the solution I'm not sure that is actually the right way. Java being a platform independant (at least that is the intention isn't it ?) development platform may already do some endianizing on its own internally and in that case likely chooses the big endian or network byte order format which happens to be the same as what LabVIEW uses. Otherwise Java client server applications between Intel and non Intel platforms couldn't communicate seemlessly.

Rolf Kalbermatter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.