public void SendCommandWithResponse(SerialCommand command) { if (!serialPort.IsOpen) { throw new InvalidOperationException("Serial port is not open"); } var bytesToWrite = command.GetAllBytes(); var responseBuffer = WriteBytesAndGetResponse(bytesToWrite); command.ApplyResponseAndVerify(responseBuffer); }