I send via the OutputStram AT commands to the Acorp dial-up modem. The command passes, the modem "picks up the phone." I am trying to read the response through the InputStream and gives [B @ 127734f What is it? It seems "promised" that if the team passes - the modem should issue "OK". Does anyone have any thread thread considerations on this? Thank.
package server; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Enumeration; import gnu.io.*; public class Test { CommPortIdentifier portIdentifer; CommPort commPort; SerialPort serialPort; /** * @param args */ public Test() { try { portIdentifer = CommPortIdentifier.getPortIdentifier("/dev/ttyS0"); } catch (NoSuchPortException nspe) { System.out.println("нет таких портов"); } if (portIdentifer.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use"); } else { try { commPort = portIdentifer.open(this.getClass().getName(),2000); } catch (PortInUseException piue) { System.out.println("порт используется"); } if (commPort instanceof SerialPort) { serialPort = (SerialPort) commPort; try { serialPort.setSerialPortParams(57600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException ucoe) { System.out.println("не проходит операция"); } try { InputStream is = serialPort.getInputStream(); OutputStream os = serialPort.getOutputStream(); String massageOn = "AT V1 H1 \r"; String massageOff = "AT H0 \r"; os.write(massageOn.getBytes()); byte[] buffer = new byte[10000]; is.read(buffer); System.out.println(buffer.toString()); try { Thread.sleep(2000); } catch (Exception e) { } os.write(massageOff.getBytes()); } catch (IOException ioe) { System.out.println("инпут-аутпут"); } //(new Thread(new SerialReader(is))).start(); //(new Thread(new SerialWriter(os))).start(); } else { System.out.println("Error: Only serial ports are handled by this example."); } try { Thread.sleep(2000); serialPort.close(); } catch (InterruptedException ie) { System.out.println("interrupted"); } } } public static void main(String[] args) { new Test(); } }