Class SerialPortBean

java.lang.Object
net.solarnetwork.node.service.support.SerialPortBean
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
SerialPortBeanParameters

public class SerialPortBean extends Object implements Cloneable
A basic JavaBean class for serial port configuration elements.

The dataBits, stopBits, and parity class properties should be initialized to values corresponding to the constants defined in the gnu.io.SerialPort class (e.g. gnu.io.SerialPort#DATABITS_8, etc.).

Version:
1.1
Author:
matt
  • Constructor Details

    • SerialPortBean

      public SerialPortBean()
      Default constructor.
  • Method Details

    • getDefaultSettingSpecifiers

      public static List<net.solarnetwork.settings.SettingSpecifier> getDefaultSettingSpecifiers(String prefix)
      Get a list of setting specifiers for this bean.
      Parameters:
      prefix - bean prefix to use
      Returns:
      setting specifiers
    • getDefaultSettingSpecifiers

      public static List<net.solarnetwork.settings.SettingSpecifier> getDefaultSettingSpecifiers(SerialPortBean defaults, String prefix)
      Get a list of setting specifiers for this bean.
      Parameters:
      defaults - the default values to use
      prefix - the bean prefix to use
      Returns:
      setting specifiers
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • isDtr

      public boolean isDtr()
      Get the DTR toggle.
      Returns:
      the DTR toggle
    • setDtr

      public void setDtr(boolean dtr)
      Set the DTR toggle.
      Parameters:
      dtr - the DTR toggle to set
    • isRts

      public boolean isRts()
      Get the RTS toggle.
      Returns:
      the RTS toggle
    • setRts

      public void setRts(boolean rts)
      Set the RTS toggle.
      Parameters:
      rts - the RTS toggle to set
    • getBaud

      public int getBaud()
      Get the SerialPort communication speed.
      Returns:
      the baud; defaults to 19200
    • setBaud

      public void setBaud(int baud)
      Set the SerialPort communication speed.
      Parameters:
      baud - the baud to use
    • getDataBits

      public int getDataBits()
      Get the serial port data bits.
      Returns:
      the number of data bits; defaults to 8
    • setDataBits

      public void setDataBits(int dataBits)
      Set the serial port number of data bits.
      Parameters:
      dataBits - the number of data bits to use
    • getStopBits

      public int getStopBits()
      Get the serial port number of stop bits.
      Returns:
      the stop bits; defaults to 1
    • setStopBits

      public void setStopBits(int stopBits)
      Set the serial port number of stop bits.
      Parameters:
      stopBits - the number of stop bits to use
    • getParity

      public int getParity()
      Get the serial port parity.
      Returns:
      the parity; defaults to 0
    • setParity

      public void setParity(int parity)
      The serial port parity setting to use.

      Valid values are:

      0
      None
      1
      Odd
      2
      Even
      3
      Mark
      4
      Space
      Parameters:
      parity - the parity
    • getParityString

      public String getParityString()
      Get the parity as a string value.
      Returns:
      the parity, or null if not supported
      Since:
      1.1
      See Also:
    • setParityString

      public void setParityString(String parity)
      Set the parity as a string value.

      This method accepts the following values:

      • none
      • odd
      • even
      Parameters:
      parity - the parity value to set
      Since:
      1.1
    • getReceiveThreshold

      public int getReceiveThreshold()
      Get the receive threshold.
      Returns:
      the receive threshold; defaults to 40
    • setReceiveThreshold

      public void setReceiveThreshold(int receiveThreshold)
      Set the SerialPort receive threshold setting.

      If set to anything less than 0 then the receive threshold will be disabled.

      Parameters:
      receiveThreshold - the receive threshold to use
    • getFlowControl

      public int getFlowControl()
      Get the SerialPort flow control setting to use.
      Returns:
      the flow control; defaults to -1
    • setFlowControl

      public void setFlowControl(int flowControl)
      Set the SerialPort flow control setting to use.

      If less than 0 flow control will not be configured. The settings are:

      0
      None
      1
      RTS CTS in
      2
      RTS CTS out
      4
      XON XOFF in
      8
      XON XOFF out
      Parameters:
      flowControl - the flow control to use
    • getReceiveTimeout

      public int getReceiveTimeout()
      Get the receive timeout.
      Returns:
      the receive timeout; defaults to -1
    • setReceiveTimeout

      public void setReceiveTimeout(int receiveTimeout)
      Set the SerialPort receive timeout setting.

      If set to anything less than 0 then the receive timeout will be disabled.

      Parameters:
      receiveTimeout - the receive timeout to use
    • getReceiveFraming

      public int getReceiveFraming()
      Get the receive framing.
      Returns:
      the receive framing; defaults to -1
    • setReceiveFraming

      public void setReceiveFraming(int receiveFraming)
      Set the SerialPort receive framing setting.

      If set to anything less than 0 then the receive framing will be disabled.

      Parameters:
      receiveFraming - the receive framing to use
    • getDtrFlag

      public int getDtrFlag()
      Get the DTR flag.
      Returns:
      the DTR flag; defaults to 1
    • setDtrFlag

      public void setDtrFlag(int dtrFlag)
      Set the SerialPort DTR setting to use.

      When set to 0 DTR will be set to false. When set to 1 DTR will be set to true. When configured as less than zero the DTR setting will not be changed. The dtr property can also be used to set this as a boolean.

      Parameters:
      dtrFlag - the DTR flag to use
    • getRtsFlag

      public int getRtsFlag()
      Get the RTS flag.
      Returns:
      the RTS flag; defaults to 0
    • setRtsFlag

      public void setRtsFlag(int rtsFlag)
      Set the SerialPort RTS setting to use.

      When set to 0 RTS will be set to false. When set to 1 RTS will be set to true. When configured as less than zero the RTS setting will not be changed. The rts property can also be used to set this as a boolean.

      Parameters:
      rtsFlag - the RTS flag to use