public <T extends Message> T sendMessageSynchronous(Class<T> responseType, TransmittableMessage message) {
        T responseMessage = null;
        SynchronousMessageListener<T> messageListener = new SynchronousMessageListener<>(responseType);

        addMessageListener(messageListener);

        if (sendMessage(message)) {
            if (messageListener.waitForResponse()) {
                responseMessage = messageListener.getResponseMessage();
            }
        }

        removeMessageListener(messageListener);

        return responseMessage;
    }
public < T extends Message > T sendMessageSynchronous ( Class < T > responseType , TransmittableMessage message ) { T responseMessage = null ; SynchronousMessageListener < T > messageListener = new SynchronousMessageListener < > ( responseType ) ; addMessageListener ( messageListener ) ; if ( sendMessage ( message ) ) { if ( messageListener . waitForResponse ( ) ) { responseMessage = messageListener . getResponseMessage ( ) ; } } removeMessageListener ( messageListener ) ; return responseMessage ; }
Send a Message over the serial port and block/wait for the message response.
In cases where you do not need ASync behavior, or just want to send a single message and
handle a single response, where the async design may be a bit too verbose, use this instead.
By sending a message and dictacting the type of response, you will get the response message as the return
value, or null if the message was not received within the timeout blocking period.
@param message TransmittableMessage to be sent over the serial port
@param <T> Message type that you are expecting as a reply to the message being transmitted.
@return T message object if the project board sends a reply. null if no reply was sent in time.