mil.dod.th.ose.rxtxtty/src/mil/dod/th/ose/rxtxtty/RxtxSerialPortImpl.java
private void applyProperties() throws PhysicalLinkException // NOCHECKSTYLE: NOPMD complexity
                                                                // TD: method from ARL, could be cleaned up
    {
        checkRxtxPort();

        final int baudRate = m_Attributes.baudRate();
        final int dataBits = m_Attributes.dataBits();
        final ParityEnum parity = m_Attributes.parity();
        final StopBitsEnum stopBits = m_Attributes.stopBits();
        final FlowControlEnum flowControl = m_Attributes.flowControl();
        final int timeout = m_Attributes.readTimeoutMs();
        
        int rxtxDataBits = 0;
        int rxtxStopBits = 0;
        int rxtxParity = 0;
        int rxtxFlowControl = 0;

        switch (dataBits)
        {
            case 5: // NOCHECKSTYLE: Simple lookup, magic number ok
                rxtxDataBits = gnu.io.SerialPort.DATABITS_5;
                break;
            case 6: // NOCHECKSTYLE: Simple lookup, magic number ok
                rxtxDataBits = gnu.io.SerialPort.DATABITS_6;
                break;
            case 7: // NOCHECKSTYLE: Simple lookup, magic number ok
                rxtxDataBits = gnu.io.SerialPort.DATABITS_7;
                break;
            case 8: // NOCHECKSTYLE: Simple lookup, magic number ok
                rxtxDataBits = gnu.io.SerialPort.DATABITS_8;
                break;
            default:
                throw new PropertyValueNotSupportedException(SerialPortAttributes.CONFIG_PROP_DATA_BITS, dataBits);
        }

        switch (stopBits)
        {
            case ONE_STOP_BIT:
                rxtxStopBits = gnu.io.SerialPort.STOPBITS_1;
                break;
            case TWO_STOP_BITS:
                rxtxStopBits = gnu.io.SerialPort.STOPBITS_2;
                break;
            case ONE_5_STOP_BITS:
                rxtxStopBits = gnu.io.SerialPort.STOPBITS_1_5;
                break;
            default:
                throw new PropertyValueNotSupportedException(SerialPortAttributes.CONFIG_PROP_STOP_BITS, dataBits);
        }

        switch (parity)
        {
            case NONE:
                rxtxParity = gnu.io.SerialPort.PARITY_NONE;
                break;
            case ODD:
                rxtxParity = gnu.io.SerialPort.PARITY_ODD;
                break;
            case EVEN:
                rxtxParity = gnu.io.SerialPort.PARITY_EVEN;
                break;
            default:
                throw new PropertyValueNotSupportedException(SerialPortAttributes.CONFIG_PROP_PARITY, dataBits);
        }

        switch (flowControl)
        {
            case NONE:
                rxtxFlowControl = gnu.io.SerialPort.FLOWCONTROL_NONE;
                break;
            case HARDWARE:
                rxtxFlowControl = gnu.io.SerialPort.FLOWCONTROL_RTSCTS_IN | gnu.io.SerialPort.FLOWCONTROL_RTSCTS_OUT;
                break;
            case XON_XOFF:
                rxtxFlowControl = gnu.io.SerialPort.FLOWCONTROL_XONXOFF_IN | gnu.io.SerialPort.FLOWCONTROL_XONXOFF_OUT;
                break;
            default:
                throw new PropertyValueNotSupportedException(SerialPortAttributes.CONFIG_PROP_FLOW_CONTROL, dataBits);
        }

        try
        {
            if (timeout < 0)
            {
                m_RxtxPort.disableReceiveTimeout();
                m_RxtxPort.enableReceiveThreshold(1);
            }
            else
            {
                m_RxtxPort.enableReceiveTimeout(timeout);
                m_RxtxPort.disableReceiveThreshold();
            }
            m_RxtxPort.setSerialPortParams(baudRate, rxtxDataBits, rxtxStopBits, rxtxParity);
            m_RxtxPort.setFlowControlMode(rxtxFlowControl);
        }
        catch (final UnsupportedCommOperationException e)
        {
            throw new PhysicalLinkException("Unable to set parameters", e);
        }
    }
/**
     * Update the properties for an open port.
     * 
     * @throws PhysicalLinkException
     *      if there is a problem applying the properties
     */
Update the properties for an open port.

@throws PhysicalLinkException
if there is a problem applying the properties
Update the properties for an open port . @throws PhysicalLinkException if there is a problem applying the properties
private void applyProperties() throws PhysicalLinkException 
    {
        checkRxtxPort();
        final int baudRate = m_Attributes.baudRate();
        final int dataBits = m_Attributes.dataBits();
        final ParityEnum parity = m_Attributes.parity();
        final StopBitsEnum stopBits = m_Attributes.stopBits();
        final FlowControlEnum flowControl = m_Attributes.flowControl();
        final int timeout = m_Attributes.readTimeoutMs();
        int rxtxDataBits = 0;
        int rxtxStopBits = 0;
        int rxtxParity = 0;
        int rxtxFlowControl = 0;
        switch (dataBits)
        {
            case 5: 
                rxtxDataBits = gnu.io.SerialPort.DATABITS_5;
                break;
            case 6: 
                rxtxDataBits = gnu.io.SerialPort.DATABITS_6;
                break;
            case 7: 
                rxtxDataBits = gnu.io.SerialPort.DATABITS_7;
                break;
            case 8: 
                rxtxDataBits = gnu.io.SerialPort.DATABITS_8;
                break;
            default:
                throw new PropertyValueNotSupportedException(SerialPortAttributes.CONFIG_PROP_DATA_BITS, dataBits);
        }
        switch (stopBits)
        {
            case ONE_STOP_BIT:
                rxtxStopBits = gnu.io.SerialPort.STOPBITS_1;
                break;
            case TWO_STOP_BITS:
                rxtxStopBits = gnu.io.SerialPort.STOPBITS_2;
                break;
            case ONE_5_STOP_BITS:
                rxtxStopBits = gnu.io.SerialPort.STOPBITS_1_5;
                break;
            default:
                throw new PropertyValueNotSupportedException(SerialPortAttributes.CONFIG_PROP_STOP_BITS, dataBits);
        }
        switch (parity)
        {
            case NONE:
                rxtxParity = gnu.io.SerialPort.PARITY_NONE;
                break;
            case ODD:
                rxtxParity = gnu.io.SerialPort.PARITY_ODD;
                break;
            case EVEN:
                rxtxParity = gnu.io.SerialPort.PARITY_EVEN;
                break;
            default:
                throw new PropertyValueNotSupportedException(SerialPortAttributes.CONFIG_PROP_PARITY, dataBits);
        }
        switch (flowControl)
        {
            case NONE:
                rxtxFlowControl = gnu.io.SerialPort.FLOWCONTROL_NONE;
                break;
            case HARDWARE:
                rxtxFlowControl = gnu.io.SerialPort.FLOWCONTROL_RTSCTS_IN | gnu.io.SerialPort.FLOWCONTROL_RTSCTS_OUT;
                break;
            case XON_XOFF:
                rxtxFlowControl = gnu.io.SerialPort.FLOWCONTROL_XONXOFF_IN | gnu.io.SerialPort.FLOWCONTROL_XONXOFF_OUT;
                break;
            default:
                throw new PropertyValueNotSupportedException(SerialPortAttributes.CONFIG_PROP_FLOW_CONTROL, dataBits);
        }
        try
        {
            if (timeout < 0)
            {
                m_RxtxPort.disableReceiveTimeout();
                m_RxtxPort.enableReceiveThreshold(1);
            }
            else
            {
                m_RxtxPort.enableReceiveTimeout(timeout);
                m_RxtxPort.disableReceiveThreshold();
            }
            m_RxtxPort.setSerialPortParams(baudRate, rxtxDataBits, rxtxStopBits, rxtxParity);
            m_RxtxPort.setFlowControlMode(rxtxFlowControl);
        }
        catch (final UnsupportedCommOperationException e)
        {
            throw new PhysicalLinkException("Unable to set parameters", e);
        }
    }
private void applyProperties ( ) throws PhysicalLinkException { checkRxtxPort ( ) ; final int baudRate = m_Attributes . baudRate ( ) ; final int dataBits = m_Attributes . dataBits ( ) ; final ParityEnum parity = m_Attributes . parity ( ) ; final StopBitsEnum stopBits = m_Attributes . stopBits ( ) ; final FlowControlEnum flowControl = m_Attributes . flowControl ( ) ; final int timeout = m_Attributes . readTimeoutMs ( ) ; int rxtxDataBits = 0 ; int rxtxStopBits = 0 ; int rxtxParity = 0 ; int rxtxFlowControl = 0 ; switch ( dataBits ) { case 5 : rxtxDataBits = gnu . io . SerialPort . DATABITS_5 ; break ; case 6 : rxtxDataBits = gnu . io . SerialPort . DATABITS_6 ; break ; case 7 : rxtxDataBits = gnu . io . SerialPort . DATABITS_7 ; break ; case 8 : rxtxDataBits = gnu . io . SerialPort . DATABITS_8 ; break ; default : throw new PropertyValueNotSupportedException ( SerialPortAttributes . CONFIG_PROP_DATA_BITS , dataBits ) ; } switch ( stopBits ) { case ONE_STOP_BIT : rxtxStopBits = gnu . io . SerialPort . STOPBITS_1 ; break ; case TWO_STOP_BITS : rxtxStopBits = gnu . io . SerialPort . STOPBITS_2 ; break ; case ONE_5_STOP_BITS : rxtxStopBits = gnu . io . SerialPort . STOPBITS_1_5 ; break ; default : throw new PropertyValueNotSupportedException ( SerialPortAttributes . CONFIG_PROP_STOP_BITS , dataBits ) ; } switch ( parity ) { case NONE : rxtxParity = gnu . io . SerialPort . PARITY_NONE ; break ; case ODD : rxtxParity = gnu . io . SerialPort . PARITY_ODD ; break ; case EVEN : rxtxParity = gnu . io . SerialPort . PARITY_EVEN ; break ; default : throw new PropertyValueNotSupportedException ( SerialPortAttributes . CONFIG_PROP_PARITY , dataBits ) ; } switch ( flowControl ) { case NONE : rxtxFlowControl = gnu . io . SerialPort . FLOWCONTROL_NONE ; break ; case HARDWARE : rxtxFlowControl = gnu . io . SerialPort . FLOWCONTROL_RTSCTS_IN | gnu . io . SerialPort . FLOWCONTROL_RTSCTS_OUT ; break ; case XON_XOFF : rxtxFlowControl = gnu . io . SerialPort . FLOWCONTROL_XONXOFF_IN | gnu . io . SerialPort . FLOWCONTROL_XONXOFF_OUT ; break ; default : throw new PropertyValueNotSupportedException ( SerialPortAttributes . CONFIG_PROP_FLOW_CONTROL , dataBits ) ; } try { if ( timeout < 0 ) { m_RxtxPort . disableReceiveTimeout ( ) ; m_RxtxPort . enableReceiveThreshold ( 1 ) ; } else { m_RxtxPort . enableReceiveTimeout ( timeout ) ; m_RxtxPort . disableReceiveThreshold ( ) ; } m_RxtxPort . setSerialPortParams ( baudRate , rxtxDataBits , rxtxStopBits , rxtxParity ) ; m_RxtxPort . setFlowControlMode ( rxtxFlowControl ) ; } catch ( final UnsupportedCommOperationException e ) { throw new PhysicalLinkException ( "Unable to set parameters" , e ) ; } }
Update the properties for an open port.
Update the properties for an open port .
// NOCHECKSTYLE: NOPMD complexity // TD: method from ARL, could be cleaned up // NOCHECKSTYLE: Simple lookup, magic number ok // NOCHECKSTYLE: Simple lookup, magic number ok // NOCHECKSTYLE: Simple lookup, magic number ok // NOCHECKSTYLE: Simple lookup, magic number ok