Examples of SerialPort


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

Examples of jssc.SerialPort

    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

Examples of jssc.SerialPort

    }

    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

Examples of jssc.SerialPort

  }*/
 
  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

Examples of jssc.SerialPort

        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

Examples of jssc.SerialPort

//            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

Examples of org.contikios.cooja.interfaces.SerialPort

    }

    @Override
    public void doAction(Visualizer visualizer, Mote mote) {
      Simulation simulation = mote.getSimulation();
      SerialPort serialPort = null;
      for (MoteInterface intf : mote.getInterfaces().getInterfaces()) {
        if (intf instanceof SerialPort) {
          serialPort = (SerialPort) intf;
          break;
        }
View Full Code Here

Examples of org.smslib.helper.SerialPort

      if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
      {
        _formatter.format("%nFound port: %-5s%n", portId.getName());
        for (int i = 0; i < bauds.length; i++)
        {
          SerialPort serialPort = null;
          _formatter.format("       Trying at %6d...", bauds[i]);
          try
          {
            InputStream inStream;
            OutputStream outStream;
            int c;
            String response;
            serialPort = portId.open("SMSLibCommTester", 1971);
            serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN);
            serialPort.setSerialPortParams(bauds[i], SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
            inStream = serialPort.getInputStream();
            outStream = serialPort.getOutputStream();
            serialPort.enableReceiveTimeout(1000);
            c = inStream.read();
            while (c != -1)
              c = inStream.read();
            outStream.write('A');
            outStream.write('T');
            outStream.write('\r');
            Thread.sleep(1000);
            response = "";
            StringBuilder sb = new StringBuilder();
            c = inStream.read();
            while (c != -1)
            {
              sb.append((char) c);
              c = inStream.read();
            }
            response = sb.toString();
            if (response.indexOf("OK") >= 0)
            {
              try
              {
                System.out.print("  Getting Info...");
                outStream.write('A');
                outStream.write('T');
                outStream.write('+');
                outStream.write('C');
                outStream.write('G');
                outStream.write('M');
                outStream.write('M');
                outStream.write('\r');
                response = "";
                c = inStream.read();
                while (c != -1)
                {
                  response += (char) c;
                  c = inStream.read();
                }
                System.out.println(" Found: " + response.replaceAll("\\s+OK\\s+", "").replaceAll("\n", "").replaceAll("\r", ""));
              }
              catch (Exception e)
              {
                System.out.println(_NO_DEVICE_FOUND);
              }
            }
            else
            {
              System.out.println(_NO_DEVICE_FOUND);
            }
          }
          catch (Exception e)
          {
            System.out.print(_NO_DEVICE_FOUND);
            Throwable cause = e;
            while (cause.getCause() != null)
            {
              cause = cause.getCause();
            }
            System.out.println(" (" + cause.getMessage() + ")");
          }
          finally
          {
            if (serialPort != null)
            {
              serialPort.close();
            }
          }
        }
      }
    }
View Full Code Here

Examples of purejavacomm.SerialPort

          8 - requiredExtraBits);
      System.exit(1);
      return;
    }

    SerialPort p = (SerialPort) CommPortIdentifier.getPortIdentifier(
        args[0]).open(TwoPortSerialTest.class.getName(), 0);

    p.setSerialPortParams(baudRate, dataBits, stopBits, parity);

    OutputStream out = p.getOutputStream();

    final int N = (1 << dataBits);

    for (int n = 0; n < N; n++) {
      out.write(n);
View Full Code Here

Examples of purejavacomm.SerialPort

          8 - requiredExtraBits);
      System.exit(1);
      return;
    }

    SerialPort p = (SerialPort) CommPortIdentifier.getPortIdentifier(
        args[0]).open(TwoPortSerialTest.class.getName(), 0);

    p.setSerialPortParams(baudRate, dataBits + requiredExtraBits,
        SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    p.enableReceiveTimeout(10000);

    InputStream in = p.getInputStream();
    while (in.available() != 0) {
      in.read();
    }

    System.out.println("Waiting for A...");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.