Class MpsLegacyTunnelConnection


  • public class MpsLegacyTunnelConnection
    extends MpsTunnelConnection
    A connection to a slave device behind a MPS Master (MPS Beacon, BraceID, etc.). The connection to the master can be established by any means. The MPS must be correctly set up before calling MpsTunnelConnection.connect(). The link to the slave device can either be established in advance or you pass an EID to the constructor. This class may then be used to opaquely tunnel data to and from the slave device. This class uses DAT command to communicate to the slave device instead of BINXT commands used by the `MpsTunnelConnection`. Thus the class supports legacy beacons/MPS version that only use the DAT protocol. Every datastream must at the time of the flush, this includes `send()` call, must end in CR and have CRs in the right distance. This also means that `MpsLegacyTunnelConnection` may not be used as a drop-in for existing ICommConnections in every situation (if the code breaks these restrictions). Just as `MpsTunnelConnection`, both outgoing and incoming data may be duplicated, making this even less fit to drop into some existing ICommConnection-user. `MpsTunnelConnection` should always be preferred if the circumstances allow it. bug Furthermore, you cannot currently send more than one CR-terminated line before flushing and users must check for errors, which are MPS-specific, like `TOE` manually in their code. This can and should all be handled within the class.
    • Constructor Detail

      • MpsLegacyTunnelConnection

        public MpsLegacyTunnelConnection​(ICommConnection connection,
                                         java.lang.String slaveEID)
        Construct a MPS Tunneling Connection. A link to the slave device will be established during connect().
        Parameters:
        connection - The connection to the master device (MPS).
        slaveEID - The slave's EID (8 bytes hexadecimal string) or null.
      • MpsLegacyTunnelConnection

        public MpsLegacyTunnelConnection​(ICommConnection connection)
        Construct a MPS Tunneling Connection. The link to the slave device must already be established.
        Parameters:
        connection - The connection to the master device (MPS).
    • Method Detail

      • setLinked

        public void setLinked​(boolean linked)
        Sets whether to use linked communication or not. This must only be set before a connection established. Once the connection is established one this value can only be modified after a disconnect is called.
        Parameters:
        linked - true if linked communication should be used, false otherwise
      • isLinked

        public boolean isLinked()
        Returns whether to use linked communication.
        Returns:
        true if linked communication is being used, false otherwise
      • connect

        public void connect()
                     throws CommConnectionException
        Description copied from class: ICommConnection
        This method opens a connection. Parameters are passed through the constructor
        Overrides:
        connect in class MpsTunnelConnection
        Throws:
        CommConnectionException - possible Errorcodes:
        • for TCP Connection:
          • ETHERNET_UNKNOWN_HOST
          • ETHERNET_TIMEOUT
          • WRONG_PARAMETER
        • for USB Connection:
          • DEVICE_IN_USE
          • NO_LIBRARY_FOUND
          • NO_DEVICES_FOUND
          • USB_SET_BAUDRATE
          • USB_SET_DATA_CHARACTERISTICS
          • USB_SET_FLOWCONTROL
          • USB_SET_TIMEOUTS
        • for RS232 Connection:
          • NO_LIBRARY_FOUND
          • SERIAL_PORT_NOT_EXIST
          • SERIAL_PARAMETER_NOT_SET
          • DEVICE_IN_USE
          • SERIAL_NO_ACCESS
          • SERIAL_NO_INITIALISE
      • send

        public void send​(byte[] senddata)
                  throws CommConnectionException
        Description copied from class: ICommConnection
        Sends data to the connected device
        Overrides:
        send in class MpsTunnelConnection
        Parameters:
        senddata - data/command send to the connected device
        Throws:
        CommConnectionException - possible Errorcodes:
        • for TCP Connection:
          • WRONG_PARAMETER
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for USB Connection:
          • WRONG_PARAMETER
          • UNHANDLED_ERROR
          • NOT_INITIALISE
        • for RS232 Connection:
          • WRONG_PARAMETER
          • CONNECTION_LOST
          • UNHANDLED_ERROR
          • NOT_INITIALISE