public void notestCase04() { File serialLine = new File("/dev/ttyUSB0"); byte[] buf = new byte[30]; try { SerialLine p = new SerialLine(serialLine, 115200, 8, 1, "n"); InputStream in = p.getInputStream(); OutputStream out = p.getOutputStream(); while (true) { System.out.println("Check if GSM Modem is ready."); // out.write ("ath".getBytes()); out.write(MSG_AT_QUERY); out.flush(); int cx = IoTestUtils.readLine(in, buf); if (cx == MSG_AT_OK_RESPONSE.length && IoTestUtils.byteArrayCompare(buf, MSG_AT_OK_RESPONSE, MSG_AT_OK_RESPONSE.length)) break; System.out.println("GSM Modem is not ready yet."); try { Thread.sleep(1000); } catch (InterruptedException e) { } } System.out.println("GSM Modem is ready."); out.write(MSG_AT_CBC_QUERY); out.flush(); while (true) { int cx = IoTestUtils.readLine(in, buf); System.out.print(cx + " bytes received: '"); for (int k = 0; k < cx; k++) IoTestUtils.printOneByte(System.out, buf[k]); System.out.println("'"); if (cx == -1) break; if (IoTestUtils.byteArrayCompare(buf, MSG_AT_OK_RESPONSE, MSG_AT_OK_RESPONSE.length)) break; if (IoTestUtils.byteArrayCompare(buf, MSG_AT_CBC_RESPONSE, MSG_AT_CBC_RESPONSE.length)) System.out.println("Mobile Phone Accu Capacity"); } System.out.println(); p.close(); assertTrue(true); } catch (IOException e) { e.printStackTrace(); fail(); } }
public void notestCase02() { File serialLine = new File("/dev/ttyUSB1"); byte[] buf = new byte[30]; try { SerialLine p = new SerialLine(serialLine, 115200, 8, 1, "n"); InputStream in = p.getInputStream(); OutputStream out = p.getOutputStream(); out.write(MSG_AT_CBC_QUERY); while (true) { int cx = IoTestUtils.readLine(in, buf); System.out.print(cx + " bytes received: '"); for (int k = 0; k < cx; k++) IoTestUtils.printOneByte(System.out, buf[k]); System.out.println("'"); if (cx == -1) break; if (IoTestUtils.byteArrayCompare(buf, MSG_AT_OK_RESPONSE, MSG_AT_OK_RESPONSE.length)) break; if (IoTestUtils.byteArrayCompare(buf, MSG_AT_CBC_RESPONSE, MSG_AT_CBC_RESPONSE.length)) System.out.println("Mobile Phone Accu Capacity"); } System.out.println(); p.close(); assertTrue(true); } catch (IOException e) { e.printStackTrace(); assertTrue(false); } }