LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP read/write with state machine issue. Comms loop not executing

Hello to you all,

 

I have reached a dead end in my trouble shooting and would like some advice on where to look for solutions please.

 

I am currently controlling a piece of equipment vie sending an xml string over TCP to the device. I have a working program which communicates with the machine and receives a position string back from the device. The code i have is far from optimal and I have looked on this forum for how to improve the situation and understood a state machine is what i require. The issue i have is that when the entire program is contained within a single while loop it all works fine albeit a little slow.

When I have split the program and have one loop for the communication and a state machine for the processing etc, the communication loop never executes and the device times out.Currently I have the positional data being stored in a local variable and passed over to the communication loop. with the returned data stored as a local variable and sent to the state machine for processing. When initially run the PC and device connect fine but then eventually disconnect.

 

When the loop is simulated with a client immitating the device and talking to the device on localhost the tcp loop executes.

 

Has anyone else experienced this and could you please point me in the direction of where to look to improve my code?

 

This now has the files attached as the last post was deleted.

 

I am using windows 7 on the PC with an arduino for physical I/O. NI vision assistant is used for camera capture

Download All
0 Kudos
Message 1 of 3
(2,188 Views)

What do you mean by "never executes"? Is it stalling at reading and no data ever arrives? Are there any errors? What do you see in execution highlighting mode?

 

From what I can tell, your comm loop is configured to stop once any data has been received (string lenght !=0), so it will never iterate more than once. (it waits forever for data, and as soon as data arrives, the string length is nonzero and the loop stops). Once that loop has stopped, there will no longer be any communication until the program is restarted.

 

It is a bit hard to tell be cause you did not include any subVIs or type definitions. And since you were lazy and did not even give your enum typedef a reasonable and unique name ("control 1.ctl" is NOT a unique name!) I am getting conflicts because my downloads folder already has a control 1.ctl containing very different items, probably form another forum post similar to yours.

 

If you attach code with generic names, put it all inside a zip file.

0 Kudos
Message 2 of 3
(2,170 Views)

I am very sorry that i was lazy, it was not my intention. I have been working on this for a while now and did not think to rename as it is the only instance on my PC of a program with the control in it.

 

In terms of never executes, i had the loop iteration wired to the numeric to try and see how many iterations of the communication loop were running. When the program runs with a localhost client the loop runs continuously and iterates as it should. When i have connected to the external hardware the communication loop does not iterate. The external hardware does show that it is connect to the PC via the TCP communication as if it did not the hardware would show an error that it could not open a channel.

 

I have attached the missing parts inside a zip file now for you to view

0 Kudos
Message 3 of 3
(2,161 Views)