Client got out-of-Stream. Network library

edited April 2014 in Library Questions

Hello everybody, I am working on a project in wich I want to send and recieve data (Strings) from a device wich is connectet via ethernet. The reason for ethernet is because these devices are used in industrial enviroment and are organized in a network. The device has a chip on it which creates its own webserver.

I have no access to the firmware of the device. All I've got ist the data for connecting (IP, Port, etc) and the information for the communication protocol (the fabricator made its own protocol).

example:

    if I send the String: GET VER\n
    the Device sends me: S V1.13 @ LED-C3A Controller\n
    (every message has a line-feed ('\n') at the end in both directions.)

Also I know it connects via TCP.

The device connects correctly. I've tested it with the Software with which it is delivered.

The problem:

500-600ms after I've started my program I get the message: client got out-of-Stream. After that I cant send any commands without getting more errors.

The odd thing is that I send a command, after the connection is set, then wait 600ms (required from protocol), lose the connection (client got out-of-Stream) and get the correct answer from the device.

Here is my code:

import processing.net.*;
Client SLUX;

String dataIn = new String("");

void init_SLUX()
{
  println("connect to: 193.168.122.150");
  SLUX = new Client(this, "192.168.122.150", 1580);

  println("connected");
  println("command: get version");
     SLUX.write("GET VER" + '\n');
     println("wait");
     int millisStart = millis();
     while ((millis() - millisStart) < 600){;} ;
  println("check answer");
       if (SLUX.available() > 0) 
    { 
      dataIn = SLUX.readString();
      print("version is: ");
      println(dataIn);
    }

    println("end of init");
}

    void setup()
      {
      size(displayWidth - 50, displayHeight - 100);

       init_SLUX();
      }


    void draw()
    {

    }

I used println() insted of Breakpoints since there is no such thing in Processing (yet). Here is the terminal-output I get when I run the program:

connect to: 193.168.122.150
connected
command: get version
wait
Client got end-of-stream.
check answer
version is: S V1.13 @ LED-C3A Controller 1

end of init

Any suggestions?

PS: Please excuse my english. It's not my native language.

Answers

  • Answer ✓

    Problem solved. Please close this Discussion.

Sign In or Register to comment.