• 大小: 0.44M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-01-15
  • 语言: Java
  • 标签: 串口  java  源码  通信  a  

资源简介

windows下 如打不开串口的话,请参考这里 https://stackoverflow.com/questions/15955530/commportidentifier-getportidentifiers-is-empty

资源截图

代码片段和文件信息

package com.yang.serialport.manager;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.TooManyListenersException;

import com.yang.serialport.utils.ArrayUtils;
import com.yang.serialport.utils.ShowUtils;

import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.NoSuchPortException;
import gnu.io.PortInUseException;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import gnu.io.UnsupportedCommOperationException;

/**
 * 串口管理
 * 
 * @author yangle
 */
@SuppressWarnings(“all“)
public class SerialPortManager {

/**
 * 查找所有可用端口
 * 
 * @return 可用端口名称列表
 */
public static final ArrayList findPorts() {
// 获得当前所有可

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-10-03 12:18  SerialPortDemo-master\
     文件         684  2018-10-03 11:14  SerialPortDemo-master\.classpath
     文件         343  2018-07-18 10:38  SerialPortDemo-master\.fatjar
     文件           4  2018-07-18 10:38  SerialPortDemo-master\.gitignore
     文件         373  2018-07-18 10:38  SerialPortDemo-master\.project
     目录           0  2018-10-03 10:39  SerialPortDemo-master\.settings\
     文件          85  2018-07-18 10:38  SerialPortDemo-master\.settings\org.eclipse.core.resources.prefs
     文件         617  2018-07-18 10:38  SerialPortDemo-master\.settings\org.eclipse.jdt.core.prefs
     文件       11340  2018-07-18 10:38  SerialPortDemo-master\LICENSE
     文件         605  2018-07-18 10:38  SerialPortDemo-master\README.md
     文件      138510  2018-07-18 10:38  SerialPortDemo-master\SerialPortDemo.jar
     目录           0  2018-10-12 20:02  SerialPortDemo-master\bin\
     目录           0  2018-10-12 20:02  SerialPortDemo-master\bin\com\
     目录           0  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\
     目录           0  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\
     目录           0  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\manager\
     文件         301  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\manager\SerialPortManager$DataAvailableListener.class
     文件        1395  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\manager\SerialPortManager$SerialPortListener.class
     文件        4675  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\manager\SerialPortManager.class
     目录           0  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\ui\
     文件        2084  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\ui\Mainframe$1.class
     文件        1235  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\ui\Mainframe$2.class
     文件         826  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\ui\Mainframe$3.class
     文件        2077  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\ui\Mainframe$4.class
     文件         579  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\ui\Mainframe$5.class
     文件        8492  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\ui\Mainframe.class
     目录           0  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\utils\
     文件         617  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\utils\ArrayUtils.class
     文件        2059  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\utils\ByteUtils.class
     文件        1269  2018-10-12 20:02  SerialPortDemo-master\bin\com\yang\serialport\utils\ShowUtils.class
     文件       84992  2008-12-08 14:45  SerialPortDemo-master\bin\rxtxParallel.dll
............此处省略19个文件信息

评论

共有 条评论