crc() public method

public crc ( int padlen ) : int
padlen int
return int
Ejemplo n.º 1
0
        public void currentChecksum(Firmware fw)
        {
            if (self.bl_rev < 3)
            {
                return;
            }

            this.port.ReadTimeout = 1000; // 1 sec

            int expect_crc = fw.crc(self.fw_maxsize);

            __send(new byte[] { (byte)Code.GET_CRC,
                                (byte)Code.EOC });
            int report_crc = __recv_int();

            self.__getSync();

            print("FW File 0x" + hexlify(BitConverter.GetBytes(expect_crc)) + " " + expect_crc);
            print("Current 0x" + hexlify(BitConverter.GetBytes(report_crc)) + " " + report_crc);

            if (expect_crc == report_crc)
            {
                throw new Exception("Same Firmware. Not uploading");
            }
        }
Ejemplo n.º 2
0
        public void __verify_v3(Firmware fw)
        {
            //Expected 0x33E22A51
            //Got      0x8117524C
            //System.Exception: Program CRC failed


            //python
            //Expected 0x4c521781
            //Got      0x4c521781

            int expect_crc = fw.crc(self.fw_maxsize);

            __send(new byte[] { (byte)Code.GET_CRC,
                                (byte)Code.EOC });
            int report_crc = __recv_int();

            __getSync();

            print("Expected 0x" + hexlify(BitConverter.GetBytes(expect_crc)) + " " + expect_crc);
            print("Got      0x" + hexlify(BitConverter.GetBytes(report_crc)) + " " + report_crc);
            if (report_crc != expect_crc)
            {
                throw new Exception("Program CRC failed");
            }
        }
Ejemplo n.º 3
0
        public void currentChecksum(Firmware fw)
        {
            if (self.bl_rev < 3)
            {
                return;
            }

            __sync();

            this.port.ReadTimeout = 1000; // 1 sec

            if (self.fw_maxsize > 0)
            {
                int expect_crc = fw.crc(self.fw_maxsize);
                __send(new byte[] { (byte)Code.GET_CRC,
                                    (byte)Code.EOC });
                int report_crc = __recv_int();
                self.__getSync();

                print("FW File 0x" + hexlify(BitConverter.GetBytes(expect_crc)) + " " + expect_crc);
                print("Current 0x" + hexlify(BitConverter.GetBytes(report_crc)) + " " + report_crc);

                if (expect_crc == report_crc)
                {
                    throw new Exception("Same Firmware. Not uploading");
                }
            }

            if (self.extf_maxsize > 0)
            {
                int expect_crc = fw.extf_crc(fw.extf_image_size);

                byte[] size_bytes = BitConverter.GetBytes(fw.extf_image_size);

                __send(new byte[] { (byte)Code.EXTF_GET_CRC,
                                    size_bytes[0], size_bytes[1], size_bytes[2], size_bytes[3],
                                    (byte)Code.EOC });

                // crc can be slow, give it 10s
                __wait_for_bytes(4, 30);

                int report_crc = __recv_int();
                self.__getSync();

                print("Ext FW File 0x" + hexlify(BitConverter.GetBytes(expect_crc)) + " " + expect_crc);
                print("Current 0x" + hexlify(BitConverter.GetBytes(report_crc)) + " " + report_crc);

                if (expect_crc == report_crc)
                {
                    throw new Exception("Same Firmware. Not uploading");
                }
            }
        }
Ejemplo n.º 4
0
        public void __verify_extf(Firmware fw)
        {
            int expect_crc = fw.crc(self.extf_maxsize);

            __send(new byte[] { (byte)Code.EXTF_GET_CRC,
                                (byte)Code.EOC });
            int report_crc = __recv_int();

            __getSync();

            print("extf Expected 0x" + hexlify(BitConverter.GetBytes(expect_crc)) + " " + expect_crc);
            print("extf Got      0x" + hexlify(BitConverter.GetBytes(report_crc)) + " " + report_crc);
            if (report_crc != expect_crc)
            {
                throw new Exception("Program extf CRC failed");
            }
        }
Ejemplo n.º 5
0
        public void currentChecksum(Firmware fw)
        {
            if (self.bl_rev < 3)
                return;

            this.port.ReadTimeout = 1000; // 1 sec

            int expect_crc = fw.crc(self.fw_maxsize);
            __send(new byte[] {(byte)Code.GET_CRC,
				(byte) Code.EOC});
            int report_crc = __recv_int();
            self.__getSync();

            print("FW File 0x" + hexlify(BitConverter.GetBytes(expect_crc)) + " " + expect_crc);
            print("Current 0x" + hexlify(BitConverter.GetBytes(report_crc)) + " " + report_crc);

            if (expect_crc == report_crc)
                throw new Exception("Same Firmware. Not uploading");
        }
Ejemplo n.º 6
0
        public void __verify_v3(Firmware fw)
        {

            //Expected 0x33E22A51
            //Got      0x8117524C
            //System.Exception: Program CRC failed


            //python
            //Expected 0x4c521781
            //Got      0x4c521781

            int expect_crc = fw.crc(self.fw_maxsize);
            __send(new byte[] {(byte)Code.GET_CRC,
				(byte) Code.EOC});
            int report_crc = __recv_int();
            __getSync();

            print("Expected 0x" + hexlify(BitConverter.GetBytes(expect_crc)) + " " + expect_crc);
            print("Got      0x" + hexlify(BitConverter.GetBytes(report_crc)) + " " + report_crc);
            if (report_crc != expect_crc)
            {
                throw new Exception("Program CRC failed");
            }
        }