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 Summary
Modifier and Type Method Description ChipLocation
getChip()
default ByteBuffer
getSCPData(SCPRequest<?> scpRequest)
Returns the data of an SCP request as it would be sent down this connection.SCPResultMessage
receiveSCPResponse(int timeout)
Receives an SCP response from this connection.default SCPResultMessage
receiveSCPResponse(Integer timeout)
Receives an SCP response from this connection.void
send(ByteBuffer requestData, int seq)
Send a request that expects a response to be appropriately directed to the thread that is calling this method.default void
send(SCPRequest<?> request)
Sends an SCP request down this connection.Methods inherited from interface uk.ac.manchester.spinnaker.connections.model.Connection
convertTimeout, getLocalIPAddress, getLocalPort, getRemoteIPAddress, getRemotePort, isClosed, isConnected, receive, receiveWithAddress, send, sendTo
-
Method Details
-
getSCPData
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
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
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
- sourcePort is
-
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, InterruptedExceptionReceives 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; ifnull
, 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 messageSocketTimeoutException
- If there is a timeout before a message is receivedInterruptedException
- If communications are interrupted.
-
receiveSCPResponse
SCPResultMessage receiveSCPResponse(int timeout) throws SocketTimeoutException, IOException, InterruptedExceptionReceives 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 messageSocketTimeoutException
- If there is a timeout before a message is receivedInterruptedException
- If communications are interrupted.
-
send
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)
-