Tag: at command

当我使用NetBeans 6.8和Eclipse运行此代码时,为什么输出会有所不同?

当我使用Eclipse和NetBeans 6.8运行以下代码时。 我想在我的计算机上看到可用的COM端口。 在Eclipse中运行时,它返回所有可用的COM端口,但在NetBeans中运行时,它似乎找不到任何端口.. public static void test(){ Enumeration lists=CommPortIdentifier.getPortIdentifiers(); System.out.println(lists.hasMoreElements()); while (lists.hasMoreElements()) { CommPortIdentifier cn=(CommPortIdentifier)lists.nextElement(); if ((CommPortIdentifier.PORT_SERIAL==cn.getPortType())) { System.out.println( “Name is serail portzzzz ” + cn.getName() + ” Owned status ” + cn.isCurrentlyOwned()); try{ SerialPort port1=(SerialPort)cn.open(“ComControl”,800000); port1.setSerialPortParams( 9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); System.out.println(“Before get stream”); OutputStream out=port1.getOutputStream(); InputStream input=port1.getInputStream(); System.out.println(“Before write”); out.write(“AT”.getBytes()); System.out.println(“After write”); int […]

GSM调制解调器以UCS2格式发送消息错误

我正在使用java使用AT命令与gsm调制解调器(西门子)进行通信。 我将调制解调器的编码设置为“UCS2”。 当我发送电话号码时发送消息时,我从设备收到错误: AT + CSCS = UCS2 好 AT + CSMP = 17,167,0,8 好 AT + CMGF = 1 好 AT + CMGS = “0919xxxxxxx” 错误 帮助我,PLEEEEEEASE! 🙁

如何将AT命令的输出转换为java中的字符串?

我正在尝试读取AT命令的结果(执行从控制台对GSM调制解调器执行各种操作的命令)。 我已经看到并成功测试了使用Java OuputStream类来获取AT命令的结果作为输出流但我需要做的是将结果不是作为输出流而是在我的类中的变量(现在为String)。 如果可以这样做的话 outStream.write((“Some At command”).getBytes()); 哪个工作正常,怎么可能做这样的事情 Strign resultOfCommmand=…..result of some AT command; 我是这样尝试的 InputStream is = new ByteArrayInputStream((“some at commamd”).getBytes()); String result = getStringFromInputStream(is); System.out.println(“66666666666666666666—–“+result); ///////////////////// private static String getStringFromInputStream(InputStream is) { BufferedReader br = null; StringBuilder sb = new StringBuilder(); String line; try { br = new BufferedReader(new InputStreamReader(is)); while ((line = […]

请求com端口时返回相同的请求

我试图通过COM端口发送AT命令,但只重新发送相同的命令。 package SerialConnections; import jssc.SerialPort; import jssc.SerialPortEvent; import jssc.SerialPortEventListener; import jssc.SerialPortException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static ru.telemetria.qa.utils.Utilities.waitTime; public class M234Serial { private static Logger log = LoggerFactory.getLogger(M234Serial.class); private SerialPort serialPort; private byte[] receivedData; private boolean isReceived; public M234Serial() throws Exception { serialPort = new SerialPort(“COM55”); } public void sendCommand() throws Exception { open(); String […]