爱问知识人 爱问教育 医院库

java代码获取GPRS怎么获?

首页

java代码获取GPRS怎么获?

java代码获取GPRS怎么获取

提交回答
好评回答
  • 2014-03-25 23:41:51
      // 初始化方法
    public boolean init() {
    portList = CommPortIdentifier。getPortIdentifiers();
    // 遍历端口
    while (portList。hasMoreElements()) {
    portId = (CommPortIdentifier) portList。
      nextElement(); // 串行端口 if (portId。getPortType() == CommPortIdentifier。PORT_SERIAL) { System。out。println(portId。getName()); // 端口号 if (portId。
      getName()。equals("COM3")) { try { serialPort = (SerialPort) portId。open(this。getClass()。getName(), 5000);//这行报错 // 添加端口事件监听 serialPort。
      addEventListener(this); serialPort。notifyOnDataAvailable(true); } catch (PortInUseException e) { e。printStackTrace(); return false; } catch (TooManyListenersException e) { return false; } try { is = serialPort。
      getInputStream(); outputStream = serialPort。getOutputStream(); br = new BufferedReader(new InputStreamReader(is)); // 初始化串口 serialPort。
      setSerialPortParams(9600,SerialPort。DATABITS_8, SerialPort。STOPBITS_1,SerialPort。PARITY_NONE); System。out。println("端口COM3初始化成功"); outputStream。
      write("AT\r"。getBytes()); System。out。println(is。
      read()); return true; } catch (IOException e) { return false; } catch (UnsupportedCommOperationException e) { return false; } } } } return false; }。

    韩***

    2014-03-25 23:41:51

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 178-197
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):