Class RMIRemoteUARTPort

  • All Implemented Interfaces:
    java.io.Serializable, java.rmi.Remote, RMIUARTPort

    public class RMIRemoteUARTPort
    extends java.rmi.server.UnicastRemoteObject
    implements RMIUARTPort
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class java.rmi.server.RemoteObject

        ref
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected RMIRemoteUARTPort​(java.lang.String portName)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      byte getByte()
      read a single byte from the device
      void getBytes​(byte[] vals, int offset, int len)
      read a number of bytes from the device
      java.lang.String getModeName​(int mode)
      Get the string name of the specified mode.
      int getShort()
      read a single short from the device.
      void getShorts​(short[] vals, int offset, int len)
      read a number of shorts from the device
      boolean initialiseSensor​(int mode)
      Initialise the attached sensor and set it to the required operating mode.
      Note: This method is not normally needed as the sensor will be initialised when it is opened.
      int rawRead​(byte[] buffer, int offset, int len)
      Read bytes from the uart port.
      int rawWrite​(byte[] buffer, int offset, int len)
      Attempt to write a series of bytes to the uart port.
      void resetSensor()
      Reset the attached sensor.
      void setBitRate​(int bitRate)
      Set the bit rate of the port when operating in RAW mode.
      boolean setMode​(int mode)  
      java.lang.String toStringValue()
      Return the current sensor reading to a string.
      int write​(byte[] buffer, int offset, int len)
      Write bytes to the sensor
      • Methods inherited from class java.rmi.server.UnicastRemoteObject

        clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObject
      • Methods inherited from class java.rmi.server.RemoteServer

        getClientHost, getLog, setLog
      • Methods inherited from class java.rmi.server.RemoteObject

        equals, getRef, hashCode, toString, toStub
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RMIRemoteUARTPort

        protected RMIRemoteUARTPort​(java.lang.String portName)
                             throws java.rmi.RemoteException
        Throws:
        java.rmi.RemoteException
    • Method Detail

      • getByte

        public byte getByte()
                     throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        read a single byte from the device
        Specified by:
        getByte in interface RMIUARTPort
        Returns:
        the byte value
        Throws:
        java.rmi.RemoteException
      • getBytes

        public void getBytes​(byte[] vals,
                             int offset,
                             int len)
                      throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        read a number of bytes from the device
        Specified by:
        getBytes in interface RMIUARTPort
        Parameters:
        vals - byte array to accept the data
        offset - offset at which to store the data
        len - number of bytes to read
        Throws:
        java.rmi.RemoteException
      • getShort

        public int getShort()
                     throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        read a single short from the device.
        Specified by:
        getShort in interface RMIUARTPort
        Returns:
        the short value
        Throws:
        java.rmi.RemoteException
      • getShorts

        public void getShorts​(short[] vals,
                              int offset,
                              int len)
                       throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        read a number of shorts from the device
        Specified by:
        getShorts in interface RMIUARTPort
        Parameters:
        vals - short array to accept the data
        offset - offset at which to store the data
        len - number of shorts to read
        Throws:
        java.rmi.RemoteException
      • getModeName

        public java.lang.String getModeName​(int mode)
                                     throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        Get the string name of the specified mode.

        TODO: Make other mode data available.

        Specified by:
        getModeName in interface RMIUARTPort
        Parameters:
        mode - mode to lookup
        Returns:
        String version of the mode name
        Throws:
        java.rmi.RemoteException
      • toStringValue

        public java.lang.String toStringValue()
                                       throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        Return the current sensor reading to a string.
        Specified by:
        toStringValue in interface RMIUARTPort
        Throws:
        java.rmi.RemoteException
      • initialiseSensor

        public boolean initialiseSensor​(int mode)
                                 throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        Initialise the attached sensor and set it to the required operating mode.
        Note: This method is not normally needed as the sensor will be initialised when it is opened. However it may be of use if the sensor needs to be reset or in other cases.
        Specified by:
        initialiseSensor in interface RMIUARTPort
        Parameters:
        mode - target mode
        Returns:
        true if ok false if error
        Throws:
        java.rmi.RemoteException
      • resetSensor

        public void resetSensor()
                         throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        Reset the attached sensor. Following this the sensor must be initialised before it can be used.
        Specified by:
        resetSensor in interface RMIUARTPort
        Throws:
        java.rmi.RemoteException
      • close

        public void close()
                   throws java.rmi.RemoteException
        Specified by:
        close in interface RMIUARTPort
        Throws:
        java.rmi.RemoteException
      • setMode

        public boolean setMode​(int mode)
                        throws java.rmi.RemoteException
        Specified by:
        setMode in interface RMIUARTPort
        Throws:
        java.rmi.RemoteException
      • rawRead

        public int rawRead​(byte[] buffer,
                           int offset,
                           int len)
                    throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        Read bytes from the uart port. If no bytes are available return 0.

        Note: The port must have been set into RAW mode to use this method.

        Specified by:
        rawRead in interface RMIUARTPort
        Parameters:
        buffer - The buffer to store the read bytes
        offset - The offset at which to start storing the bytes
        len - The maximum number of bytes to read
        Returns:
        The actual number of bytes read
        Throws:
        java.rmi.RemoteException
      • rawWrite

        public int rawWrite​(byte[] buffer,
                            int offset,
                            int len)
                     throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        Attempt to write a series of bytes to the uart port. This call is non-blocking if there is no space in the write buffer a count of 0 is returned.

        Note: The port must have been set into RAW mode before attempting to use the method.

        Specified by:
        rawWrite in interface RMIUARTPort
        Parameters:
        buffer - The buffer containing the bytes to write
        offset - The offset of the first byte
        len - The number of bytes to attempt to write
        Returns:
        The actual number of bytes written
        Throws:
        java.rmi.RemoteException
      • setBitRate

        public void setBitRate​(int bitRate)
                        throws java.rmi.RemoteException
        Description copied from interface: RMIUARTPort
        Set the bit rate of the port when operating in RAW mode.
        Specified by:
        setBitRate in interface RMIUARTPort
        Parameters:
        bitRate - The new bit rate
        Throws:
        java.rmi.RemoteException
      • write

        public int write​(byte[] buffer,
                         int offset,
                         int len)
        Description copied from interface: RMIUARTPort
        Write bytes to the sensor
        Specified by:
        write in interface RMIUARTPort
        Parameters:
        buffer - bytes to be written
        offset - offset to the start of the write
        len - length of the write
        Returns:
        number of bytes written