Package jssc

Examples of jssc.SerialPort


     */
    public SerialDAO(String portName, int baudrate, int databits, int stopbits, int parity, SerialUpdate update) {
        this.update = update;
        this.portName = portName;

        serialPort = new SerialPort(portName);
        try {
            if (!serialPort.isOpened()) {
                serialPort.openPort();
                serialPort.setParams(baudrate, databits, stopbits, parity);
                int mask = SerialPort.MASK_RXCHAR + SerialPort.MASK_CTS + SerialPort.MASK_DSR;
View Full Code Here


    protected SerialInputStream input;
    protected OutputStream output;
   
    protected synchronized void connect() throws Exception {
        disconnect();
        serialPort = new SerialPort(portName);
        serialPort.openPort();
        serialPort.setParams(
                baud,
                SerialPort.DATABITS_8,
                SerialPort.STOPBITS_1,
View Full Code Here

    }

    public void connect() {
  if (port == null) {
      try {
    port = new SerialPort(PortName);
    port.openPort();
    port.setParams(rate, databits, stopbits, parity);

    int eventMask = SerialPort.MASK_RXCHAR | SerialPort.MASK_BREAK;
    port.addEventListener(this, eventMask);
View Full Code Here

  }*/
 
  private boolean openSerialPort(String portName)
  {
    serialPort = new SerialPort(portName);
    try
    {
      System.out.println("Port opened: " + serialPort.openPort());
      System.out.println("Params set: " + serialPort.setParams(SerialPort.BAUDRATE_115200, 8, 1, 0));
     
View Full Code Here

        String[] ports = jssc.SerialPortList.getPortNames();
        ArrayList portList = new ArrayList();

        for (String port : ports) {
//            CommPortIdentifier port = (CommPortIdentifier) ports.nextElement();
            SerialPort _tmpPort = new SerialPort(port);
            if (!_tmpPort.getPortName().contains("Bluetooth")) {

            }

//            if (UtilityFunctions.getOperatingSystem().equals("mac")) {
//                if (_tmpPort.getPortName().contains("tty")) {
//                    continue; //We want to remove the the duplicate tty's and just provide the "cu" ports in the drop down.
//                }
//            }

            portList.add(_tmpPort.getPortName())//Go ahead and add the ports that made it though the logic above
        }

        String portArray[] = (String[]) portList.toArray(new String[0]);
        return portArray;
    }
View Full Code Here

//            CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(port);
        // Get the port's ownership
//            serialPort = (SerialPort) portId("TG", TIME_OUT);
        // set port parameters
        serialPort = new SerialPort(port);
        serialPort.openPort();
        serialPort.setParams(DATA_RATE,
                SerialPort.DATABITS_8,
                SerialPort.STOPBITS_1,
                SerialPort.PARITY_NONE);
View Full Code Here

   *             If an error occurred when reading from the input stream
   * @throws SerialPortException
   *             If timeout expires before connecting
   */
  public synchronized byte[] readBytes() throws SerialPortTimeoutException, SerialPortException {
    SerialPort sp = new SerialPort(serialPort);
    byte[] buffer = null;
    try {
      sp.openPort();
      sp.setParams(baud, dataBits, stopBits, parity);
      sp.purgePort(SerialPort.PURGE_RXCLEAR);
      sp.purgePort(SerialPort.PURGE_TXCLEAR);
      buffer = sp.readBytes(byteCount, timeout);
      log.info("Byte Count: " + byteCount);
      log.info("Value: " + new String(buffer));
    } catch (SerialPortTimeoutException e) {
      throw e;
    } catch (SerialPortException e) {
      throw e;
    } finally {
      if (sp.isOpened())
        sp.closePort();
    }

    return buffer;
  }
View Full Code Here

TOP

Related Classes of jssc.SerialPort

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.