为什么 GSM 调制解调器不响应程序但响应超级终端或扩展坞灯?
编辑:
我在java中开发短信应用程序用于读取短信。我将AT命令发送到GSM模式以发送短信,消息正在成功发送,但我没有得到来自调制解调器的任何响应。如果我通过超级终端发送 AT 命令,我会收到响应。确切的问题是什么?
InputStream inputStream;
OutputStream out;
this.inputStream = serialPort.getInputStream();
this.out = serialPort.getOutputStream();
out.write(("AT"+"\r").getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
out.write(("AT+CMGF=1"+"\r").getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
out.write(("AT+CMGS=\""+"+91xxxxxxxxxx"+"\""+"\r").getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
out.write(("TEST "+cntrlZ).getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
//Im using SerialPortEventListener to read the input from modem
int a = inputStream.available();
System.out.println(inputStream.available() + " BYTES AVAILABLE ");
inputStream.read(readBuffer, 0, a);
我也尝试在发送每个 AT 命令后阅读,但我没有从调制解调器收到任何响应。
EDITED:
Im developing SMS application in java for reading SMS.Im sending AT commands to GSM mode for sending an SMS,messages is sending successfully ,but im not getting any response from the modem.If i send the AT commands through Hyperterminal im getting the response.Whats the exact problem?
InputStream inputStream;
OutputStream out;
this.inputStream = serialPort.getInputStream();
this.out = serialPort.getOutputStream();
out.write(("AT"+"\r").getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
out.write(("AT+CMGF=1"+"\r").getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
out.write(("AT+CMGS=\""+"+91xxxxxxxxxx"+"\""+"\r").getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
out.write(("TEST "+cntrlZ).getBytes());
try {
Thread.sleep(1500);
} catch (InterruptedException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
//Im using SerialPortEventListener to read the input from modem
int a = inputStream.available();
System.out.println(inputStream.available() + " BYTES AVAILABLE ");
inputStream.read(readBuffer, 0, a);
I also tried to read after sending each AT commands,but im not getting anything as a response from the modem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
RXTX 接收问题
设置串口的流量控制后,它工作正常。
Issues receving in RXTX
After setting the flow control for the serial port its working fine.
请确保您已安装了 SMSlib 所需的所有库并且您的调制解调器已打开支持的调制解调器列表。支持调制解调器不是必需的,但可以立即消除兼容性问题。
您还应该验证调制解调器是否正确连接。您可以通过AT命令直接对其进行一些操作。
Please make sure that you have installed all libraries required by SMSlib and your modem is on supported modems list. Having supported modem is not required, but can eliminate compatibility problem right off the bat.
Also you should verify if your modem is connected properly. You could perform some operations on it directly, via AT commands.