0

I am working on a university project, where I require communicating Java with Labview, bidirectional, and send and receive data in floating point, in data buffers, because the application in Labview generates data at high speed, but I temporarily store and send when the array has a size of 100.

One of my difucultades is to convert data sent from Labview to Java format and viceversa.

Thanks!!

Raul
  • 465
  • 5
  • 16
  • 1
    What do you have so far? – Soana Sep 16 '14 at 14:01
  • If you're writing both the LabVIEW and Java software then the format is up to you. What have you tried so far and what result did you get? – nekomatic Sep 17 '14 at 19:07
  • so far I'm creating the data server and the client in labview. But what worries me is not the TCP / IP connection, that's easy. What I see is to send and receive complex data types with Labview, for example, do not know how to receive and interpret a floating point number sent from labview, as well as get an array of floating point numbers. Also put a identifier on those numbers, to know what each means. Thank you for your help !! – Raul Sep 18 '14 at 19:15

2 Answers2

1

As far as I can see, you have two options:

  1. Use a text base protocol (XML, JSON, something of your own) and just send the literal "1.3454".
    1. pro: it's probably human readable, which simplifies debugging/ asserting that the correct data is transferred. It is also simpler to have different types of messages.
    2. con: This may mean a loss of precision and definitely means some kind of overhead.
  2. If you just have this one kind of data, you could also extract the bytes of the float and send them, so that the other end can read exactly four bytes and reconstruct the float.
    1. pro: no overhead
    2. con: There might be a problem with endianess. I'm not sure if LabVIEW and Java handle all their data in a specific endian or if it depends on the hardware. You might need to reorder the read bytes before reassembling them back to a float. Also different kinds of messages can get more complicated. On this best read the documentation on the TCP Read VI

You can also mix both approaches: extract the bytes from the float, treat each byte as a character and assemble them as a string, which you put into your text based protocol.

Soana
  • 711
  • 7
  • 15
0

Consider using Labview standard tcp-ip lib or websocket.

Khachik Sahakyan
  • 1,982
  • 15
  • 24
  • have any link ?. I see that WebSocket is not what I need. Thanks for your help !! – Raul Sep 18 '14 at 19:18
  • http://www.facstaff.bucknell.edu/mastascu/elabs/networkinstrumentation/tcpip/labviewtcpip01.htm http://www.facstaff.bucknell.edu/mastascu/elessonshtml/Network/Network3NoteTCPIPinLV.html – Khachik Sahakyan Sep 18 '14 at 21:00