Ejemplo n.º 1
0
        /// <summary>
        /// Checks crc of received frame and returns the data part.
        /// </summary>
        /// <param name="receiveBuffer">Receive buffer.</param>
        /// <returns>Tuple containing the crc status and the data array.</returns>
        private protected (bool, byte[]) CheckCrcAndExtractData(byte[] receiveBuffer)
        {
            if (!CRC8.Check(receiveBuffer, 0, receiveBuffer.Length - 1, receiveBuffer[receiveBuffer.Length - 1]))
            {
                return(false, new byte[0]);
            }

            byte[] receiveBytes = new byte[receiveBuffer.Length - 2];
            Array.Copy(receiveBuffer, 1, receiveBytes, 0, receiveBytes.Length);
            return(true, receiveBytes);
        }