- * This function should never be called except in very specific cases involving - * USB-to-Serial converters with buggy device drivers. - *
- * - * @see SerialPort#disablePortConfiguration() - */ - public void disablePortConfiguration() { - disablePortConfiguration = true; - } } diff --git a/src/main/java/com/ghgande/j2mod/modbus/util/SerialParameters.java b/src/main/java/com/ghgande/j2mod/modbus/util/SerialParameters.java index db15de1b..83d28f2d 100644 --- a/src/main/java/com/ghgande/j2mod/modbus/util/SerialParameters.java +++ b/src/main/java/com/ghgande/j2mod/modbus/util/SerialParameters.java @@ -33,6 +33,7 @@ */ public class SerialParameters { + private static final boolean DEFAULT_RS485_DISABLE_CONTROL = false; private static final boolean DEFAULT_RS485_MODE = false; private static final boolean DEFAULT_RS485_TX_ENABLE_ACTIVE_HIGH = true; private static final boolean DEFAULT_RS485_ENABLE_TERMINATION = false; @@ -57,6 +58,7 @@ public class SerialParameters { private boolean rs485RxDuringTx; private int rs485DelayBeforeTxMicroseconds; private int rs485DelayAfterTxMicroseconds; + private boolean rs485DisableControl; /** * Constructs a new SerialParameters instance with @@ -80,6 +82,7 @@ public SerialParameters() { rs485TxEnableActiveHigh = DEFAULT_RS485_TX_ENABLE_ACTIVE_HIGH; rs485DelayBeforeTxMicroseconds = DEFAULT_RS485_DELAY_BEFORE_TX_MICROSECONDS; rs485DelayAfterTxMicroseconds = DEFAULT_RS485_DELAY_AFTER_TX_MICROSECONDS; + rs485DisableControl = DEFAULT_RS485_DISABLE_CONTROL; } /** @@ -392,6 +395,29 @@ public void setDatabits(String databits) { } } + /** + * Disables RS-485 control signals management. + *+ * Please note that this is only effective on Linux. + *
+ * This function forces RS-485 mode to stay untouched, + * regardless of the current setting of RS-485 mode. + *
+ * This function is necessary for Linux drivers that don't handle TIOCGRS485 properly. + */ + public void disableRs485Control() { + this.rs485DisableControl = true; + } + + /** + * Returns whether RS-485 control signals management is disabled. + * + * @return true if RS-485 control signals management is disabled. + */ + public boolean isRs485ControlDisabled() { + return this.rs485DisableControl; + } + /** * Returns the number of data bits as String. *