12-02-2009 05:15 PM
Hi
My goal is to constantly archive data to a local machine thru a Telnet connection. I receive a small amount of streaming data (25 bytes/second) thru a static IP address. The code that is attached is my attempt to
1) initiate a Telnet connection to a static IP address
2) read the streaming data, write to binary file on local machine
3) send some pertinent info to the screen for the user
since I always want to have the VI reconnect if the Telnet connection is dropped (or times out), I attempt an "endless" loop that will
4) close the Telnet connection
5) reopen the Telnet connection
6) recommence writing data to binary file on local machine
My questions are:
Q1) Did I write this correctly? Behavior is erratic. Sometimes works perfectly, sometimes doesn't work. I am unclear if I need to use a sequence of events within the outer loop to properly reconnect whenever a telnet connection is lost (sequence1: open Telnet, 2: write data. 3: close session, loop back to 1).
Q2) Often, when there appears to be no successful Telnet connection (by this, I mean no data streams to the screen which indicates the data feed will not be written to a binary file on the local machine), the numbers in the "File Size (bytes)" continue to increase. When I open the binary file to see what is being written I find the same character repeated instead of the data I wish to collect. I think perhaps that the Telnet Read is reading something, but I don't know what it is, or how to control it. Any ideas?
Thanks!
12-02-2009 06:53 PM
At first glance, your code looks okay.
Q1. You do have a sequence established by way of the data flow of the wires.
Right now your inner loop only stops when someone presses that stop button. You probably should have that inner loop stop whenever an error is detected or a stop button is pressed. That way the program will stop the loop, close the connection and iterate on the outer loop to open the connection again and restart the inner loop.
I would wrap the inner loop in a case structure with the error wire connected to it's selector. That way the inner loop only executes in the even that the TCP/IP open connection executed without an error.
Q2. I don't know why you'd be repeating a character when the connection fails. Which character is it? Is it always the same character or is it sometimes other characters? I think if you do the steps I said in Q1, it would help solve that problem as the TCP/IP read won't occur when the TCP/IP open fails.
12-03-2009 02:56 PM
Q1: What a clever solution. I didn't know wiring the Error message to a Case Structure was an option, thank you! New code attached.
New issues, however. My Telnet sessions timeout and prompt a user to either Continue or Stop trying to connect (error 56). I need to automate this process so that it always attempts a connection even when no users are present for the prompt. Can I do this? I tried setting the Telnet Open Connection timeout to -1, but the same situation occurs, Error 56. Is this a system timeout as suggested in the Error message, and not a programmer-defined timeout?
Q2: Yes it is always the same characters ^@. Wiring the Case Structure to the Error message does eliminate this situation, but if no Telnet connection is established I continually receive Error 56 prompts as mentioned above.
12-03-2009 03:09 PM
I said stop the inner loop either when the button is pressed (as you still have) OR there is an error. So look at the status of the error wire and OR it with the stop button before wiring into the inner loops stop terminal.
I'm not sure why you'd be getting a stop/continue dialog for error 56 because I can't see anywhere in the code that would cause the dialog to pop up. Drop some more indicators on your error wires, or probes. Run with highlight execution turned on. Do any or all of these things until you can figure out where the error is occurring.
I don't know where ^@ would be getting generated from unless somehow the telnet protocol is doing it. What you could do is put a case structue or select statement in the middle of the string so that if there is no error, the string value goes from the read to the file. If there is an error, an empty string goes to the file.
12-03-2009 03:45 PM
I said stop the inner loop either when the button is pressed (as you still have) OR there is an error. So look at the status of the error wire and OR it with the stop button before wiring into the inner loops stop terminal.
Ok. Clear now.
I'm not sure why you'd be getting a stop/continue dialog for error 56 because I can't see anywhere in the code that would cause the dialog to pop up. Drop some more indicators on your error wires, or probes. Run with highlight execution turned on. Do any or all of these things until you can figure out where the error is occurring.
Ok. I can do this. More later if necessary.
I don't know where ^@ would be getting generated from unless somehow the telnet protocol is doing it. What you could do is put a case structue or select statement in the middle of the string so that if there is no error, the string value goes from the read to the file. If there is an error, an empty string goes to the file.
What do you mean by "in the middle"?
Q3: Is it possible that having multiple Telnet sessions open at one time would create issues like this? The final goal is to archive the telemetered data from 6 stations at once through the telnet port of one machine.
Go Beavers.
12-03-2009 04:24 PM - edited 12-03-2009 04:26 PM
Like this.
I wouldnt' think multiple telnet seesions would cause a problem as long as they were different IP addresses or ports.
Who are the Beavers?
12-03-2009 04:39 PM
I see. I like that. Thanks.
Who are the Beavers?
Oregon State; my employer, and hopefully after the big rivalry game tonight, the Pac-10 champs headed to the Rose Bowl.
12-03-2009 04:39 PM - edited 12-03-2009 04:41 PM
Who are the Beavers?
Oh the Civil War Game. Who's going to the Rose Bowl?
Can't wait to see you on the Blue...