smslib中的NoSuchPortException

时间:2016-12-18 16:43:59

标签: java sms sms-gateway smslib

以下是我发送短信的代码部分,

 public void sendMessage() throws Exception {
        SerialModemGateway gateway = new SerialModemGateway("modem.com1", "COM7", 9600, "STC", "");
        gateway.setInbound(true);
        gateway.setOutbound(true);
        //gateway.setSimPin("0000");
        //gateway.setSmscNumber("+9477000003");

        OutboundNotification outboundNotification = new OutboundNotification();
        InboundNotification inboundNotification = new InboundNotification();

        Service service = Service.getInstance();
        service.setOutboundMessageNotification(outboundNotification);
        service.setInboundMessageNotification(inboundNotification);
        service.addGateway(gateway);
        service.startService();

但这给了我以下日志输出。

`2016-12-18 21:52:55 INFO  smslib:114 - Version: 3.5.4
2016-12-18 21:52:55 INFO  smslib:115 - JRE Version: 1.8.0_51
2016-12-18 21:52:55 INFO  smslib:116 - JRE Impl Version: 25.51-b03
2016-12-18 21:52:55 INFO  smslib:117 - O/S: Windows 8.1 / amd64 / 6.3
2016-12-18 21:52:55 INFO  smslib:92 - Queue directory not defined. Queued messages will not be saved to filesystem.
2016-12-18 21:52:55 INFO  smslib:188 - GTW: modem.com1: Starting gateway, using Generic AT Handler.
2016-12-18 21:52:55 INFO  smslib:68 - GTW: modem.com1: Opening: COM7 @9600
2016-12-18 21:52:55 INFO  smslib:120 - GTW: modem.com1: Closing: COM7 @9600
2016-12-18 21:52:56 INFO  smslib:200 - GTW: modem.com1: Stopping gateway...
2016-12-18 21:52:56 INFO  smslib:120 - GTW: modem.com1: Closing: COM7 @9600
2016-12-18 21:52:56 INFO  smslib:204 - GTW: modem.com1: Gateway stopped.
org.smslib.GatewayException: Comm library exception: java.lang.RuntimeException: javax.comm.NoSuchPortException
    at org.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:102)
    at org.smslib.modem.AModemDriver.connect(AModemDriver.java:114)
    at org.smslib.modem.ModemGateway.startGateway(ModemGateway.java:189)
    at org.smslib.Service$1Starter.run(Service.java:277)`

在“设备管理器”中,

In Device Manager

在调制解调器属性中,

In modem properties

在端口属性中,

In port properties

对于上述两个端口(COM7,COM8),我在日志中遇到了异常。

0 个答案:

没有答案