10-08-2017 03:52 AM
Hi all,
I am trying to send data from LabVIEW (client) to Matlab (server) using TCP/IP connection and made two simple examples (Test 1 & Test 2). In Test 1, after establishing the connection, LabVIEW (client) read a variable from Matlab (server), and write another variable to Matlab (server) which works fine. However, in Test 2, I switched the order of 'read' and 'write' which means that LabVIEW (client) write the variable to Matlab (server) first, and then read the other variable from Matlab (server). Test 2 does not work as I intended. Is there anything wrong with Test 2?
I would greatly appreciate if anyone could help me out.
10-08-2017 01:25 PM
What kind of errors are you getting?
Sorry, I am not really familiar with the matlab side, but are you writing and reading the correct number of bytes?
Some general comments for the LabVIEW side:
10-09-2017 02:01 AM
Thank you for your advice. The reason I converted the constants using 'I8' or 'I32' converter is that this simple example is a part of a more complex code which requires conversion.
Both examples are equivalent except that the order of 'TCP writing' and 'TCP reading'. I expected both examples should work regardless of the order of writing and reading. The symptoms I got from example 2 is that Matlab (Server) cannot get the variable from LabVIEW (Client).
I just realized why this problem occurred. When I first run Test2_Matlab_Server.m, this code tries to read the variable from LabVIEW (Client) so quickly even before I run Test2_LabVIEW_Client. vi (i.e., before the connection is established.) Now I think I can fix the problem.
Thank you.