Esempio n. 1
0
 public static SerialPortToRobot openPort(String serialPortFile, SerialPortInfo serialPortInfo) {
   SerialPorts.refreshPortIdentifiers();
   SerialPortToRobot serialPort = null;
   try {
     serialPort = new SerialPortToRobot(serialPortFile, serialPortInfo);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return serialPort;
 }
Esempio n. 2
0
 public SerialPortToRobot(String fileName, SerialPortInfo portInfo)
     throws PortInUseException, UnsupportedCommOperationException, TooManyListenersException,
         IOException {
   serialPortFileName = fileName;
   identifier = SerialPorts.getPortIdentifier(serialPortFileName);
   if (identifier == null)
     throw new RuntimeException("Port identifier " + serialPortFileName + " not found");
   serialPort = (SerialPort) identifier.open("RLPark", 2000);
   serialPort.addEventListener(this);
   serialPort.setFlowControlMode(portInfo.flowControl);
   serialPort.setSerialPortParams(
       portInfo.rate, portInfo.databits, portInfo.stopbits, portInfo.parity);
   serialStreams = new SerialStreams(serialPort);
   setNotifiers();
 }