code: @Override
      public void sendMenuCommand(MenuCommand msg) throws IOException {
          if (isConnected()) {
              synchronized (outputBuffer) {
                  cmdBuffer.clear();
                  protocol.toChannel(cmdBuffer, msg);
                  cmdBuffer.flip();
                  outputBuffer.clear();
                  outputBuffer.put(START_OF_MSG);
                  outputBuffer.put(protocol.getKeyIdentifier());
                  outputBuffer.put(cmdBuffer);
                  outputBuffer.flip();
                  logByteBuffer("Sending message on " + getConnectionName(), outputBuffer);
                  sendInternal(outputBuffer);
                  outputBuffer.clear();
              }
          } else {
              throw new IOException("Not connected to port");
          }
      }
docs: Sends a command to the remote with the protocol and usual headers.
  @param msg the message to send.
  @throws IOException if there are issues with the transport