Exemplo n.º 1
0
        /// <summary>
        /// Wait for a reply from the device, after sending a command.
        /// If the command is not what was expected, an exception is raised.
        /// </summary>
        /// <param name="expected_command">The command that is expected</param>
        /// <returns>Raw payload bytes</returns>
        protected override byte[] ReadReply(byte expected_command)
        {
            byte[] response = ReceiveFrame();
            byte   command;

            byte[] payload;
            HLDCProtocol.ParsePacket(response, out command, out payload);

            if (command != expected_command)
            {
                throw new Exception("HLDC Protocol Error - Invalid reply");
            }

            return(payload);
        }
Exemplo n.º 2
0
 protected override void SendPacket(byte command, byte[] payload = null)
 {
     byte[] packet = HLDCProtocol.CreatePacket(command, payload);
     serial.Write(packet, 0, packet.Length);
 }