Skip to content

Commit

Permalink
also accept \nOK\r\n as response from signal light
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Rampp authored and Florian Rampp committed Jul 14, 2012
1 parent f22f8bb commit efd01fb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@ public String send(String command) {

// command
Writer writer = new OutputStreamWriter(connection.getOutputStream(), Charsets.US_ASCII);
PrintWriter printer = new PrintWriter(writer, true);
printer.println(command);
writer.write(command + "\r\n");
writer.flush();

// response
Reader reader = new InputStreamReader(connection.getInputStream(), Charsets.US_ASCII);
BufferedReader bufferedReader = new BufferedReader(reader);
String response = bufferedReader.readLine();

// sometimes, the signal light returns "\nOK\r\n => read another line
if(response.isEmpty())
response = bufferedReader.readLine();

logger.debug("sent command '{}' and received response '{}' to signal light at {}", new Object[]{command, response, hostAndPort});

// close
Expand Down

0 comments on commit efd01fb

Please sign in to comment.