【问题标题】:why GSM modem is not responding to program but responding to hyperterminal or docklight?为什么 GSM 调制解调器不响应程序但响应超级终端或码头灯?
【发布时间】:2012-01-24 06:45:44
【问题描述】:

已编辑:

我正在用 java 开发 SMS 应用程序以读取 SMS。我正在将 AT 命令发送到 GSM 模式以发送 SMS,消息发送成功,但我 没有从调制解调器得到任何响应。如果我通过超级终端发送 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 命令后读取,但我没有收到任何来自调制解调器的响应。

【问题讨论】:

  • 你能发布你的端口配置吗?

标签: java sms gsm modem at-command


【解决方案1】:

Issues receving in RXTX

为串口设置流控后,它工作正常。

serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN |    SerialPort.FLOWCONTROL_RTSCTS_OUT);

【讨论】:

  • 我也在使用相同的应用程序,但无法发送消息,因为我已成功获取端口号...请帮我解决我的问题...
【解决方案2】:

请确保您拥有installed all libraries required by SMSlib 并且您的调制解调器在supported modems list 上。不需要支持调制解调器,但可以立即消除兼容性问题。

您还应该验证您的调制解调器是否连接正确。您可以通过AT commands 直接对其执行一些操作。

【讨论】:

  • 调制解调器工作正常。我已经通过超级终端检查过了。
  • 您使用的是 Linux 还是 Windows?
  • 好的,请确认您是否已按照安装过程中的所有步骤进行操作。当 SMSlib 缺少一些库时,我遇到了类似的问题,但那是在 Linux 下。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-02
相关资源
最近更新 更多