예제 #1
0
        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);
        }
예제 #2
0
        public void SendCommandWithAck(SerialCommand command)
        {
            if (!serialPort.IsOpen)
            {
                throw new InvalidOperationException("Serial port is not open");
            }

            var bytesToWrite = command.GetAllBytes();

            var response = WriteBytesAndGetResponse(bytesToWrite);

            if (response[0] != 0x07 || response[1] != 0xF3)
            {
                throw new InvalidOperationException("Expected ACK response, got something else");
            }
        }