Example #1
0
        private void ValidateCRCWithPrinter(uint expectedCRC)
        {
            if (mInterfaceVersion == BootloaderController.BootloaderInterfaceVersion.V1)
            {
                if ((int)expectedCRC != (int)m_oBootloaderConnection.GetCRCFromChip(CRC_Type.App))
                {
                    throw new Exception("Firmware failed redundancy check.");
                }
            }
            else
            {
                if (mInterfaceVersion != BootloaderController.BootloaderInterfaceVersion.V2)
                {
                    throw new Exception("Unsupported Bootloader Interface");
                }

                m_oBootloaderConnection.SPout(75);
                m_oBootloaderConnection.SPout(65);
                byte[] numArray = m_oBootloaderConnection.ReadBytes(3);
                var    str      = string.Format("{0}{1}{2}", (char)numArray[0], (char)numArray[1], (char)numArray[2]);
                if (str == "ok\r")
                {
                    return;
                }

                if (str == "no\r")
                {
                    throw new Exception("Firmware failed redundancy check.");
                }

                throw new Exception(string.Format("'K' gave an unexpected result - {0}", str));
            }
        }