Class LCPResponder

  • All Implemented Interfaces:
    java.lang.Runnable

    public class LCPResponder
    extends java.lang.Thread
    Support for LCP commands
    Author:
    Lawrie Griffiths/Andy Shaw
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Constructor Summary

      Constructors 
      Constructor Description
      LCPResponder​(NXTCommConnector connector)
      Create a Responder using the provided connector The connector is used to create the listening connection used to accept remote commands.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int command​(byte[] inMsg, int len, byte[] reply)
      Process the actual command Default action is to call the LCP object to emulate the command
      protected void disconnect()
      Method called to disconnect the responder connect.
      boolean isConnected()
      Checks whether there is an active connection
      protected void postCommand​(byte[] inMsg, int inLen, byte[] replyMsg, int replyLen)  
      protected int preCommand​(byte[] inMsg, int len)
      Method called with a newly read command, before it is processed.
      void run()  
      void shutdown()
      Terminate the responder.
      protected void waitConnect()
      Method called when the responder is waiting for a new connection.
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

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

      • LCPResponder

        public LCPResponder​(NXTCommConnector connector)
        Create a Responder using the provided connector The connector is used to create the listening connection used to accept remote commands.
        Parameters:
        connector -
    • Method Detail

      • waitConnect

        protected void waitConnect()
        Method called when the responder is waiting for a new connection. Default action is to wait for the new connection and return.
      • disconnect

        protected void disconnect()
        Method called to disconnect the responder connect. Default action is to close the underlying connection object.
      • preCommand

        protected int preCommand​(byte[] inMsg,
                                 int len)
        Method called with a newly read command, before it is processed. Default action is to detect invalid commands and if detected to drop the connection.
        Parameters:
        inMsg - Newly read command
        len - length of the command
        Returns:
        the length of the command
      • command

        protected int command​(byte[] inMsg,
                              int len,
                              byte[] reply)
        Process the actual command Default action is to call the LCP object to emulate the command
        Parameters:
        inMsg - The command bytes
        len - length of the command
        reply - bytes to send back in response to the command
        Returns:
        length of the reply
      • postCommand

        protected void postCommand​(byte[] inMsg,
                                   int inLen,
                                   byte[] replyMsg,
                                   int replyLen)
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • shutdown

        public void shutdown()
        Terminate the responder. Abort any listening operation and close any open connections (this will also abort any current read requests).
      • isConnected

        public boolean isConnected()
        Checks whether there is an active connection
        Returns:
        true iff the responder is connected