Endless Telnet Read Loop

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!
Attachments:
MBB06RawTelemetry.vi ‏27 KB

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.

Similar Messages

  • Endless "Recovery Mode" loop on my iPhone 5.

    Last night I decided to update my iPhone 5 to iOS 7.0.3. I connected my phone to my PC using the lightning cable and opened up iTunes, which prompted me to update my iOS. I hit "Cancel" so I could do a sync and backup before updating (as I always do). I then went back to the phone summary page and clicked the button to update the phone. It took about 40 minutes to download the update and after it downloaded, it failed. My phone went into Recovery Mode (picture of cable pointing to iTunes symbol). The summary page now prompted an alert saying that it has detected a phone in Recovery Mode and will need to be restored before being used. I hit "Ok" and then hit the "Restore iPhone" button.  I got the warning that all data will be lost and I agreed to the terms of iOS 7.0.3 etc. The download then began. At the end of the download, nothing happenes at all. No error message appears. The phone screen simply goes black and then the Recovery Mode screen appears again. Once again, I am prompted to restore the phone. I have restored six times now and everytime it does the same thing. It is an endless loop.
    I have tried different methods such as using a different lightning cable, different USB ports on my PC, and holding the power button and home screen to force it out of Recovery methods. My wife has the extact same phone and hers updated fine on my PC.
    Any suggestions?

    akorman     Feb 9, 2014 8:21 AM 
      Re: Endless "Recovery Mode" loop on my iPhone 5.  in response to MFothy      
    I was having this same problem (endless recovery mode loop) but I also have a broken Home button, so I'm not able to enter DFU mode. The fix for me was to go through the recovery, but after it restores the firmware, iTunes will tell you to leave the phone connected to your computer while it reboots.
    If I leave it connected, the phone re-enters recovery mode. But, if I unplug the phone at this point (during the reboot) the phone goes to the Welcome screen and I can set it up again. If I try to restore from the iTunes backup, I get put back into recovery mode, but if I restore from iCloud backup, everything works.
    So, in short:
    Plug in the phone, start the recovery
    After firmware is installed (while the phone is rebooting), unplug from the computer
    Restore backup from iCloud, not iTunes
    I have been messing with this for hours now, I finally came across your response. This worked like a charm, thank you so much!!!

  • Query works in Tera Term but not in Telnet Read.vi

    I am using Telnet Write.vi to execute a command such as GET_VERSION
    Then using Telnet Read.vi, I am expecting several lines to be returned.
    This works if I manually do this with Tera Term.
    But with LabVIEW, the Telnet Read.vi simply returns the command from the Telnet Write.vi
    What do I have to configure to change this behavior?

    Edit:
    Needed to add carriage return +  newline 
    DUH.

  • Error 56 in Telnet Read

    Hi!
    Does anybody know why I get error 56 with Telnet Read function even
    connection is workin fine and I can receive messages trough Telnet? I
    have tryed to use Line read and normal mode. With normal mode i have
    use bytes to read values, which are same as send data or even smaller
    than sended data, but always I get error 56. After error 56 apperars,
    sended message from Telnet Read buffer is read to my VI and everything
    works correctly. Problem in this is that I would like to error handler
    to tell user when connection realy doesn't work, but now error 56 comes
    even everything works fine.
    Thanks for all help I can get.

    Using Labview 8.5, XP, Telnet Line Client, I get the following error 56, TCP Read in Telnet Buffered Read.vi->Telnet Read.vi:3->Telnet Line Client.vi.
    I looked up this error which looks to be a Networking error:  56 The network operation exceeded the user-specified or system time limit. 
    The data does seem to return properly but this has been an ongoing issue with previous Telnet clients we are using.

  • Basic File Read Loop

    I have been coding Java for quite awhile now; however, I had to teach myself how to code in Java. So, when I started coding basic file reading loops, my loops look like the following (assuming I am reading a text file a line at a time, say):
    String inputLine = null;
    inFile = new BufferedReader(new FileReader(new File("in.txt")));
    while (in.ready())
        inputLine = inFile.readLine();
        //Do stuff with input, etc.
    }However, as I read through forums, books, and other resources to keep myself up-to-date, I find that everywhere there is some sort of file reading routine, their basic read loop looks as follows:
    String inputLine = null;
    inFile = new BufferedReader(new FileReader(new File("in.txt")));
    while ((inputLine = inFile.readLine()) != null)
        //Do stuff with input, etc.
    }At essence these two loops accomplish the same thing: read data a line at a time. Is there any real differences between these two loops? Is one better/preferred over the other? If so, why? Is the difference primarily seen in multithreaded applications (due to how the ready() method works)? Or am I just making a big deal out of nothing?
    Thanks for your help,
    -Dok

    Well, I wouldn't use in.ready() although it probably does exactly what expected. Actually, I'd be wary about this idiom if I were reading from an interactive source (e.g. the tty). What is it that you're trying to check with "isReady()"? If someone stops typing for a moment, do you want to finish your read loop?
    Just use the "readLine() != null" - it's a simple and standard idiom. Use "isReady()" for specialized tasks, like trying to determine if you want to do some background processing while the user is snoozing, or something like that..

  • Telnet read problem -- Telnet read back

    I am trying to use telnet to send TL1 command to my UUT and expect to read back measurement data.  I was able to read proper data once in a while but most of the time I read back the TL1 command that I sent.  I tried different read mode and timeout period but nothing seem to matter.  My vi was written in Labview 8.2.1 with Internet toolkit.  I read in the forum about some limitation of the telnet read problem of the vi from the internet toolkit,  Is there any better read driver around?
    Thanks,
    Patrick 

    Hey!  I have a few questions for you that should help us solve this problem.  First, have you tried out the telnet shipping example "Telnet Line Client.vi".  This will help us minimize programming errors, etc.  Also, what type of device are you trying to communicate with?  Are there other forms of communication available?  For example, does the device also have a serial port, GPIB Port, etc.?  Also, is it possible to write to the device using TCP/IP (This is what telnet is based on)?  Let me know the answers to these questions and I will be better equipped to help you out!!
    Thanks!
    Dan
    Daniel Eaton
    National Instruments
    Systems Engineering
    Embedded and Industrial Control

  • Telnet Read VI and variable length response

    I am trying out Internet Toolkit's Telnet VIs.
    It seems that the Telnet Read VI defaults to 60 bytes.
    I am not sure what is the best way to deal with the situation of a variable length response.
    Some responses are 3 lines; others can be 50 lines.

    the line seperator is explicitedly <CR><LF> or carriage return and line feed. No other line seperator is automatically supported.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Telnet read problem

    While doing telnet read, if the operation times out, I don't get an error.
    I am using telnet read in line mode. My line separator is my prompt char
    "cli>". Timeout is set to 10seconds. If I turn of power to my device after I
    logged in successfully, my telnet read operation should fail, but telnet
    read return OK.
    vishi

    I just checked the version of the Internet Toolkit that I have just to check, and that is apparently the intended behaviour. For some reason, NI tends to not see timeouts as an error.
    The thing to do is open up the read icon and follow the error clusters through. In the version I have, there are several places where there is a small icon labled "NO TO" on the error cluster that (you guessed it) filters out any timeout errors that occur.
    The simple fix is to rename the read VI and then go through it and remove all the timeout filters--which really shouldn't be there in the first place.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How can i eject a dvd that seems to be in a reading loop

    how can i eject a dvd that seems to be in a reading loop

    A few options: restart holding down the mouse button; launch Disk Utility in Utilities folder, select the DVD on the left and click on the eject button.
    More suggestions here: http://osxdaily.com/2009/08/28/eject-a-stuck-disk-from-your-mac-dvd-super-drive/

  • Stop endless CD reading...

    hi,
    Is there any way to stop an endless CD reading? Sometimes I put an old CD which is maybe damaged or written in a non Mac format and the Reading take for ever, even if I close all the application it will still keep reading. It is very annoying that I have to restart my Mac, besides I think eventually it might damage the CD unit.
    Any help or ideas on how to cancel that? By the way is there any way to rescue an old file that the CD does not read?
    Best,
    Sebastiao

    I'm having the same problem with software CD's on a MacBook pro. I have two that won't read in my computer but will read in another MacBook pro and my old Pismo power book. When this first happened I though it was a fluke. I was able to install the software by burning a copy on my PC then reading it on the Mac. But I'm now having the problem the Sims 2 Pets game that needs the disk to run. It's not scratched, I just opened the package today.
    I have no problem with DVDs, CD-Rs, DVD+Rs, most CDs and all but my oldest DVD-Rs.
    MATSHITA DVD-R UJ-857:
    Firmware Revision: HAC1

  • Two Telnet read VI's running at the same time interfere with each other

    I have a situation where multiple tests must test multiple UUT’s on the same computer. To send commands to and get responses from the UUT's I use a telnet session. The telnet read VI uses a semaphore. Therefore when two separate top level VI's are running, each calling the Telnet read VI, if one Top Level VI is using the Telnet Read VI the other Top Level VI waits for the first one to complete before it can use the Telnet Read VI. This VI is setup for reentrant execution but because of the semaphore it cannot truly be used as a reentrant function. This causes severe problems when trying to communicate with two different telnet sessions simultaneously.
    In the past I have avoided this problem by compiling everything into an executable. Then each Top Level program runs completely independently with no interdependences. However, now I am implementing Teststand and I need to call the same Top Level VI's. I need to be able to get information into them and back out of them from Teststand. This means that I can no longer compile them into stand alone executables. I did compile each top level VI into its own Share DLL thinking that then each top level program would have its own library to call upon. This did not work. Even though both top level programs are compiled into their own DLL there is still interdependency when calling the telnet read VI. One program waits for the other to finish reading from its telnet connection before it can read from its own telnet connection. Since I have to continuously read from the telnet connection, sometimes for up to half and hour, the tests do not function simultaneously. How can I get around this? Is there a solution?
    Josh
    PS The Telnet Read VI I am refering to came with the Internet Toolset package. Attached is a copy of the VI I use to communicat with the UUT's.
    Attachments:
    GUI_Telnet_W-R_Auto.vi ‏64 KB

    Sorry about the confusion.
    The file I attached is in the hierarchy of two separate top-level VI's. The telnet connect is opened once and closed once in each top-level program. The ref number is then passed into and out of the VI that I attached. I use this VI to repeatedly send commands via telnet and wait for the appropriate responses. The telnet read VI is given a read line separator and reads from the telnet connection until it matches the read line separator with a text string read back from the telnet connection. If not match is found it times out and creates an error.
    I am not sure how to provide an example of the overall scheme since the problem occurs when both top level VI's are compiled each into their own shared DLLs. Those DLLs are then call from Teststand and at some points they are both running at the same time on the same computer connected to two different UUT's.
    The question I have is why does one DLL share functions with the other? When one DLL is using the telnet read VI the other DLL waits for the first one to finish with it before it can it use the telnet read VI. If they were both compiled separately each into their own DLL shouldn't they each have their own set of functions to call upon instead of having to share? I know that if the two top-level VI's are not compiled they cannot both execute the same sub-VI at the same time. The only way to get around this is to set the execution property on the sub-VI to reentrant.
    I actually fixed the problem by setting the VI I attached and the Telnet Buffered Read.VI (called by Telnet Read.vi) execution properties to reentrant. However, I am still concerned about two separate DLLs sharing sub-VIs. Why does it do this?
    Joshua

  • Endless start-up loop?

    Hi, our 14" ibook w/ recently repaired logic bd from Apple is now stuck in endless start-up. Powers up ok goes to blue "home" screen, dock appears at the bottom, macintosh hd icon visible, then starts again. I can click on any icon and it seems as if its working then just goes all blue again. What's up w/ this? Any ideas b/f I head back to the Apple store?
    Ken

    Are you able to start up in Safe Mode? If so, that could resolve the endless loop. This will take quite awhile longer than a normal startup because it does a file check and repair of the hard disk.
    If this works you will see your normal desktop. Once completely started up in Safe Mode, try to restart normally. If you can start up, then go to Applications > Utilities > Disk Utility. Select the named boot volume in the left sidebar ("Macintosh HD" unless you've renamed it). Repair permissions on it.
    See if you are able to do a little hard drive maintenance to help things out. If this doesn't help, then I'd head back to the Store.
    Good luck.

  • Reading Loop

    I am following a non-blocking IO model for a client program of mine. I have flags for READABLE, WRITEABLE, etc. I run an infinite loop on deciding an io operation based on these flags. My io operations do not have infinite loops, only finite loops for sending all the packets in the out queue. My problem is that my program stays as READABLE: basically I tell it to read in 3 bytes (a packet header), read in the whole packet, store the packet in the "in" queue for parsing, maybe parse the packet, and then lower the READABLE flag and raise the WRITEABLE flag. What I believe happens is that it gets caught in the InputStream.read(header, 0, 3) call. I believe that the read method itself waits for data to come in before moving on, similar to ServerSocket.accept() waiting for clients to connect before moving on. Is this true? And if so, what can I do to fix it, so that if data isn't at the port for reading I can just move on.
    I use the java.io. package. Perhaps I should move onto the java.nio.channels package? Would this help the situation? (I've looked into it, but only want to do it if it's necessary in keeping the non-blocking model.)

    ... Ok to sum it up, when you call InputStream.read(sampleByteArray[], offset, len) to read data into a byte array does the read call WAIT until data arrives at the port it's listening to, or does it move on if there is no data there? Can someone please answer?

  • Telnet read isuue

    Hi all
    First of all thanks for taking time to help me with my problem. Let me explain
    I have developed a telnet connection program that connects to a switch and interacts with it. But unfortunately when i try to login to the switch after sending the password the switch does not reply.
    If i try and connect directly (without the use of my program) with the switch using telnet i can login without any problems.
    below is the flow
    1. readUntil the prompt "USERNAME>"
    2. send the username
    3. readUntil the propmt "PASSWORD>"
    4. send the password
    5. readUntil the prompt "WELCOME>"
    i can get to step 5 using the telnet utility. But im not getting the "WELCOME>" prompt when i use my program.
    the readUntil() method reads the input and returns what ever that is sent. It reads character by character
    While the send(String value) method writes the String value as a byte stream along with a Carriage Return.
    When using my program step 5 does not return anything. (The switch doesnt reply) But it provides the correct output when i use a telnet connection.
    I have checked Both the read and send methods and cannot find a flaw.
    what could be the reasons for this ?
      private StringBuffer readUntil(String pattern) {
        try {
          System.out.println(
          char lastChar = pattern.charAt(pattern.length() - 1);
          StringBuffer sb = new StringBuffer();
          //for timinging out purposes
          long startTime = System.currentTimeMillis();
          long currentTime = 0;
          char ch = ' ';
          while (true) {
            currentTime = System.currentTimeMillis();
            if ( (currentTime - startTime) > TIME_OUT) {
              return sb.append(TIME_OUT_STRING);
            if (ch == lastChar) {
              if (sb.toString().endsWith(pattern)) {
                System.out.println("");
                System.out.println(
                return sb;
            if (in.available() > 0) {
              ch = (char) in.read();
              sb.append(ch);
              System.out.print(ch);
              startTime = System.currentTimeMillis();
            else {
              Thread.sleep(1);
        catch (Exception e) {
          Debug.getInstance().printUsingDebug(e);
          logger.log(Level.SEVERE, "Problem in Reading from stream", e);
        return null;
      private int writeln(String value) {
        try {
          out.write(value.getBytes());
          out.write(13);
        catch (IOException ex) {
          Debug.getInstance().printUsingDebug(ex);
        return ConnectorError.SUCCESS;
    }Please note that this program works fine with the same type of switch on several other machines.

    currentTime = System.currentTimeMillis();
    if ( (currentTime - startTime) > TIME_OUT) Delete that and use Socket.setSoTimeout, and catch SocketTimeoutException below.
    if (in.available() > 0) {Delete this test.
    else {
    Thread.sleep(1);
    }Delete this 'else' block. Just let the read() block until data arrives or the timeout occurs.
    catch (Exception e) {Here you must distinguish between SocketTimeoutException and IOException. There's not much point in catching anything else.
    out.write(value.getBytes());
    out.write(13);
      out.write(value+"\r\n".getBytes();
      out.flush();

  • Endless sign in loop with Creative Cloud

    I'm on Mavericks 10.9.4 can't access Creative Cloud or any of the software. I click on the Cloud Icon and read that I have been signed out, so I sign in and read that I have been signed out etc. etc.
    Help.
    Thanks,
    Connie

    Sign Out When Sign In http://forums.adobe.com/thread/1450581?tstart=0 may help
    -and http://helpx.adobe.com/creative-cloud/kb/unable-login-creative-cloud-248.html
    -and 'looping' https://forums.adobe.com/thread/1504792

Maybe you are looking for