public static int dfuUpdate_RTR500BLE_bin(String comPortName, String binFileName, String datFileName)
        {
            int r = 0;
            bool bSts;
            DfuMain dfuMain = new DfuMain();

            bSts = dfuMain.update_RTR500_bin(comPortName, binFileName, datFileName);
            if (bSts)
                r = 0;
            else
                r = -1;

            return (r);
        }
        // Pass Method as Parameter using C#
        // http://stackoverflow.com/questions/2082615/pass-method-as-parameter-using-c-sharp
        // Func<int, object,int> arg
        public static int dfuUpdate_RTR500BLE_bin_2(Func<int, object, int> arg, String comPortName, String binFileName, String datFileName)
        {
            int r = 0;
            bool bSts;
            DfuMain dfuMain = new DfuMain();

            string[] workerResult = new string[2];
            workerResult[0] = "info";
            workerResult[1] = "calling arg(workerResult); in dfuUpdate_RTR500BLE_bin_2";
            r = arg(42, workerResult);

            bSts = dfuMain.update_RTR500_bin_2(arg, comPortName, binFileName, datFileName);
            if (bSts)
                r = 0;
            else
                r = -1;

            return (r);
        }
        // ref: my_dfu_OverSerial_program
        public int dfuProgram_RTR500BLE(String fileName, int Hexfile_type, String ComportName, UInt32 baudRate, int flowControl)
        {
            DfuMain dfuMain = new DfuMain();
            int r;
            r = 0;

            Console.Write("fileName     = {0}\n", fileName);
            Console.Write("Hexfile_type = {0}\n", Hexfile_type);
            Console.Write("ComportName  = {0}\n", ComportName);
            Console.Write("baudRate     = {0}\n", baudRate);
            Console.Write("flowControl  = {0}\n", flowControl);

            ks_hexToZip hexToZip = new ks_hexToZip();
            hexToZip.test_1(fileName);

            //dfu_main();
            // dfuMain.serial_RTR500("dummyZipPath", "COM61", 500000, 1); //    COM61 == RTR500BLE

            return (r);
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            int r = 0;
            bool bSts;
            DfuMain dfuMain = new DfuMain();

            string[] workerResult = new string[2];
            workerResult[0] = "info";
            workerResult[1] = "calling arg(workerResult); in dfuUpdate_RTR500BLE_bin_2";
               // r = arg(42, workerResult);

            #if false // OLD direct way
            DfuProgram.dfuUpdate_RTR500BLE_bin(m_theRTR500BLEComPortList[0], "dfu_temp.bin", "dfu_temp.dat");
            //bSts = dfuMain.update_Me_bin("112233445566", 1000000, "COM3", "test.bin", "test.dat");
            bSts = dfuMain.update_Me_bin("EE0DFCA3E988", 1000000, "COM3", "test.bin", "test.dat");
            if (bSts)
                r = 0;
            else
                r = -1;
            #else
            //bSts = dfuMain.update_Me_bin("EE0DFCA3E988", 1000000, "COM3", "test.bin", "test.dat");
            bgWorker_3_argument arg3 = new bgWorker_3_argument();
            arg3.Address = "EE0DFCA3E988";
            arg3.Baud_rate = 1000000;
            arg3.portName = "COM3";
            arg3.binFileName = "test.bin";
            arg3.datFileName = "test.dat";

            this.btnProgram.Enabled = false;

            backgroundWorker1.RunWorkerAsync(arg3);
            #endif

            //return (r);
        }