Package gnu.io

Examples of gnu.io.CommPortIdentifier


  private SerialPort _serialPort; 
  private InputStream _input;
  private OutputStream _output;

  private CommPortIdentifier ResolvePort(BacklightConfiguration bc)  {
    CommPortIdentifier portId = null;
    @SuppressWarnings("rawtypes")
    Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
    String portName = bc.PortName;

    while (portEnum.hasMoreElements()) {
      CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
      if (currPortId.getName() == portName) {
        portId = currPortId;
        break;
      }
    }
View Full Code Here


    }

    @Override
    protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception {
        RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress;
        final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value());
        final CommPort commPort = cpi.open(getClass().getName(), 1000);

        deviceAddress = remote;

        serialPort = (SerialPort) commPort;
    }
View Full Code Here

  protected Layer2Serial layer2;
 
 
  public SerialRXTXComm(String portName, Layer3Base layer3) throws NoSuchPortException, PortInUseException, UnsupportedCommOperationException, IOException, TooManyListenersException{
   
    CommPortIdentifier portIdentifier = CommPortIdentifier
        .getPortIdentifier(portName);
    if (portIdentifier.isCurrentlyOwned()) {
      throw new IOException("Port is currently in use");
    } else {
      CommPort commPort = portIdentifier.open(this.getClass().getName(),
          TIME_OUT);

      if (commPort instanceof SerialPort) {
        SerialPort serialPort = (SerialPort) commPort;
        serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
View Full Code Here

    private static HashSet<String> getAvailableSerialPorts() {
        HashSet<String> p = new HashSet<String>();
        Enumeration ports = CommPortIdentifier.getPortIdentifiers();
        while (ports.hasMoreElements()) {
            CommPortIdentifier com = (CommPortIdentifier) ports.nextElement();
            if (com.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                try {
                    CommPort port = com.open("CommUtil", 50);
                    port.close();
                    p.add(com.getName());
                } catch (PortInUseException e) {
                    Log.info("Port " + com.getName() + " busy.");
                } catch (Exception e) {
                    Log.info("Failed to open port " + com.getName());
                    e.printStackTrace();
                }
            }
        }
        return p;
View Full Code Here

        boolean isCommonPortname = portname.contains("ttyS") || portname.contains("COM");
    if ( ! isCommonPortname ) {
            System.setProperty("gnu.io.rxtx.SerialPorts", portname);
        }
    System.setProperty("gnu.io.rxtx.NoVersionOutput", "true");
    CommPortIdentifier commPortIdentifier = CommPortIdentifier.getPortIdentifier(portname);
    CommPort commPort = commPortIdentifier.open("tc65sh", 2000);
    serialPort = (SerialPort) commPort;
    serialPort.setSerialPortParams(baudrate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    serialPort.enableReceiveTimeout(2000);
    if ( flowControl == FLOWCONTROL_NONE ) {
      serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
View Full Code Here

    @Override
    protected synchronized ConnectFuture connect0(SocketAddress remoteAddress, SocketAddress localAddress,
            IoSessionInitializer<? extends ConnectFuture> sessionInitializer) {

        CommPortIdentifier portId;
        Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();

        SerialAddress portAddress = (SerialAddress) remoteAddress;

        // looping around found ports
        while (portList.hasMoreElements()) {
            portId = (CommPortIdentifier) portList.nextElement();
            if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                if (log.isDebugEnabled()) {
                    log.debug("Serial port discovered : " + portId.getName());
                }
                if (portId.getName().equals(portAddress.getName())) {
                    try {
                        if (log.isDebugEnabled()) {
                            log.debug("Serial port found : " + portId.getName());
                        }

                        SerialPort serialPort = initializePort("Apache MINA", portId, portAddress);

                        ConnectFuture future = new DefaultConnectFuture();
View Full Code Here

      }
    }
 
    void connect ( String portName ) throws Exception
    {
        CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
        if ( portIdentifier.isCurrentlyOwned() )
        {
            System.out.println("Error: Port is currently in use");
        }
        else
        {
            CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);
           
            if ( commPort instanceof SerialPort )
            {
                serialPort = (SerialPort) commPort;
                serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
View Full Code Here

    public void openPort() {
        if (port != null) {
            return;
        }
        try {
            CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName);
            port = (SerialPort) portId.open("SMSEngine", OPEN_PORT_TIMEOUT);
            out = new OutputStreamWriter(port.getOutputStream(), "ISO-8859-1");
            in = new InputStreamReader(port.getInputStream(), "UTF-8");
        } catch (NoSuchPortException e) {
            log.error("Port opening error (RXTX init). Port not found [" + portName + "]. Under Linux check lock file in /var/lock/");
            throw new RuntimeException(e);
View Full Code Here

            if(portnum.equals(""))
            {
              success=0;
              break;
            }
          CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(porta);
            SerialPort sp = (SerialPort)portId.open("Sms_GSM", 0);
            sp.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
            sp.setFlowControlMode(sp.FLOWCONTROL_NONE);

            in = sp.getInputStream();
            out = sp.getOutputStream();
View Full Code Here

    @SuppressWarnings("static-access")
  SerialToGsm(String porta) {
        try {
//            CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("serial0");
            portnum=porta;
          CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(porta);
            SerialPort sp = (SerialPort)portId.open("Sms_GSM", 0);
            sp.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
            sp.setFlowControlMode(sp.FLOWCONTROL_NONE);

            in = sp.getInputStream();
            out = sp.getOutputStream();
View Full Code Here

TOP

Related Classes of gnu.io.CommPortIdentifier

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.