Hello!
I'm doing a project for school which involves running an experiment with the use of two different programs, E-Prime & LabVIEW, the two of them connected with a TCP/IP connection. E-Prime runs the experiment and LabVIEW gathers data.
Basically what I want to happen is for E-Prime to send a (starting) trigger to LabVIEW, after which LabVIEW will sent a specific response before E-Prime continues again.
E-Prime unfortunately involves some (visual basic) programming of which I have very little knowledge about. This script I found has helped me out quite a bit though:
Code:
Dim MySocket As SocketDevice
dim nRead as long
dim inputStr as String
Debug.enabled = true
Set MySocket = New SocketDevice
MySocket.Name = "MySocket"
Dim theSocketDeviceInfo As SocketDeviceInfo
theSocketDeviceInfo.Server = "Rorschach-pc"
theSocketDeviceInfo.Port = 4444
theSocketDeviceInfo.SocketType = ebSocketTypeTcp
theSocketDeviceInfo.ByteOrdering = ebByteOrderingLittleEndian
'Open
MySocket.Open theSocketDeviceInfo
'********Send Trigger *********
MySocket.WriteString "Trigger"
MySocket.FlushOutputBuffer
'*****receive the initial message********
do while MySocket.InputCount = 0
loop
dim initial_response as String
do until MySocket.InputCount = 0
nRead = MySocket.ReadString(inputStr)
initial_response = initial_response & inputStr
loop
debug.print "read from the server: " + initial_response
inputStr = ""
Now the script works fine until the last part.
Code:
'*****receive the initial message********
do while MySocket.InputCount = 0
loop
dim initial_response as String
do until MySocket.InputCount = 0
nRead = MySocket.ReadString(inputStr)
initial_response = initial_response & inputStr
loop
debug.print "read from the server: " + initial_response
inputStr = ""
After that I need to rewrite it a little so that E-Prime will only continue after receiving a specific response from LabVIEW (in this case I want it to be "1").
If I keep it the way it is it won't matter whether LabVIEW sends a "1" or "2" response as long as it's one or the other (and that won't do).
I'm pretty sure it involves ReadString and/or initial_response but I just can't figure out the specifics.
I have no clue where to look anymore so any help or advice would be highly appreciated.