Interface SCPSenderReceiver

All Superinterfaces:
AutoCloseable, Closeable, Connection
All Known Implementing Classes:
BMPConnection, DelegatingSCPConnection, SCPConnection

public interface SCPSenderReceiver
extends Connection
Sends an SCP request and receives a response to it.
Author:
Donal Fellows
  • Method Details

    • getSCPData

      default ByteBuffer getSCPData​(SCPRequest<?> scpRequest)
      Returns the data of an SCP request as it would be sent down this connection.
      Parameters:
      scpRequest - message packet to serialise
      Returns:
      The buffer holding the data. The data should be written into the start of the buffer and should end at the position.
    • send

      default void send​(SCPRequest<?> request) throws IOException
      Sends an SCP request down this connection.

      Messages must have the following properties:

      • sourcePort is null or 7
      • sourceCpu is null or 31
      • sourceChipX is null or 0
      • sourceChipY is null or 0
      tag in the message is optional; if not set, the default set in the constructor will be used.

      sequence in the message is optional; if not set, (sequence number last assigned + 1) % 65536 will be used

      Parameters:
      request - message packet to send
      Throws:
      IOException - If there is an error sending the message
    • getChip

      ChipLocation getChip()
      Returns:
      The chip at which messages sent down this connection will arrive at first.
    • receiveSCPResponse

      default SCPResultMessage receiveSCPResponse​(Integer timeout) throws SocketTimeoutException, IOException, InterruptedException
      Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.
      Parameters:
      timeout - The time in milliseconds to wait for the message to arrive; if null, will wait forever, or until the connection is closed.
      Returns:
      The SCP result, the sequence number, and the data of the response. The buffer pointer will be positioned at the point where the payload starts.
      Throws:
      IOException - If there is an error receiving the message
      SocketTimeoutException - If there is a timeout before a message is received
      InterruptedException - If communications are interrupted.
    • receiveSCPResponse

      SCPResultMessage receiveSCPResponse​(int timeout) throws SocketTimeoutException, IOException, InterruptedException
      Receives an SCP response from this connection. Blocks until a message has been received, or a timeout occurs.
      Parameters:
      timeout - The time in milliseconds to wait for the message to arrive, or until the connection is closed.
      Returns:
      The SCP result, the sequence number, and the data of the response. The buffer pointer will be positioned at the point where the payload starts.
      Throws:
      IOException - If there is an error receiving the message
      SocketTimeoutException - If there is a timeout before a message is received
      InterruptedException - If communications are interrupted.
    • send

      void send​(ByteBuffer requestData, int seq) throws IOException
      Send a request that expects a response to be appropriately directed to the thread that is calling this method.
      Parameters:
      requestData - The message data to send.
      seq - The sequence number to come in the response.
      Throws:
      IOException - If there is an error sending the message
      See Also:
      Connection.send(ByteBuffer)