Example #1
0
        public bool UpdateDevice(byte[] pBuf)
        {
            InteractionData tx = new InteractionData();

            tx.buff[0] = 0x03;
            tx.buff[1] = 0x55;  //主机-->设备
            InteractionData rx = DeviceInteraction(tx);

            if (rx == null || rx.CheckDataList() == false)
            {
                return(false);
            }
            HexID[0] = rx.buff[0x10];
            HexID[1] = rx.buff[0x11];
            HexID[2] = rx.buff[0x12];
            HexID[3] = rx.buff[0x13];

            tx = new InteractionData();
            rx = DeviceInteraction(tx);
            if (rx == null || rx.CheckDataList() == false)
            {
                return(false);
            }
            HexVer[0] = rx.buff[0x10];
            HexVer[1] = rx.buff[0x11];
            return(true);
        }
Example #2
0
        //public byte[] SwVer=new byte[2]{0x20,0x01};
        public bool CheckDevice()
        {
            InteractionData tx = new InteractionData();

            tx.buff[0] = 0x03;
            tx.buff[1] = 0x55;  //主机-->设备
            InteractionData rx = DeviceInteraction(tx);

            if (rx == null || rx.CheckDataList() == false)
            {
                return(false);
            }
            HexID[0] = rx.buff[0x10];
            HexID[1] = rx.buff[0x11];
            HexID[2] = rx.buff[0x12];
            HexID[3] = rx.buff[0x13];
//             if (HexID[0] != 0x01)
//                 return false;
//             if (HexID[0] != 0x04 || HexID[1] != 0x45 || HexID[2] != 0x61 || HexID[3] != 0x67)
//                 return false;
            tx = new InteractionData();
            rx = DeviceInteraction(tx);
            if (rx == null || rx.CheckDataList() == false)
            {
                return(false);
            }
            HexVer[0] = rx.buff[0x10];
            HexVer[1] = rx.buff[0x11];
            return(true);
        }
Example #3
0
        public HIDResult CANInfoDataStep(int step, out InteractionData rx)
        {
            InteractionData tx = new InteractionData();

            tx.buff[0] = 0x14;
            tx.buff[1] = 0x55;  //主机-->设备
            tx.buff[4] = 0x20;
            for (int i = 0; i < 0x10; i++)
            {
                tx.buff[i + 0x10] = CANInfo_AT[step, i];
            }
            rx = DeviceInteraction(tx);
            if (rx == null)
            {
                return(HIDResult.USBError);
            }
            else if (rx.CheckDataList() == false)
            {
                return(HIDResult.RxError);
            }
            else if (rx.buff[1] == 0x00)
            {
                return(HIDResult.OK);
            }
            else
            {
                return(HIDResult.CANErr);
            }
        }
Example #4
0
        public HIDResult CANEeprom2Step(int step, out InteractionData rx, out int rxCount)
        {
            InteractionData tx = new InteractionData();

            tx.buff[0] = 0x14;
            tx.buff[1] = 0x55;  //主机-->设备
            tx.buff[4] = 0x20;
            for (int i = 0; i < 0x10; i++)
            {
                tx.buff[i + 0x10] = CANEeprom_b[step % 3, i];
            }
            rxCount = CANEeprom_b[step % 3, 0x0f];
            if (0x01 == (step % 3))
            {
                tx.buff[0x0A + 0x10] = CANEeprom_Cmd00[step / 3];
            }
            rx = DeviceInteraction(tx);
            if (rx == null)
            {
                return(HIDResult.USBError);
            }
            else if (rx.CheckDataList() == false)
            {
                return(HIDResult.RxError);
            }
            else if (rx.buff[1] == 0x00)
            {
                return(HIDResult.OK);
            }
            else
            {
                return(HIDResult.CANErr);
            }
        }
Example #5
0
        public HIDResult EZSReadDataStep(int step, EZSMode mode, out InteractionData rx)
        {
            InteractionData tx = new InteractionData();

            tx.buff[0]    = 0x0D;
            tx.buff[1]    = 0x55; //主机-->设备
            tx.buff[0x0A] = 0x02; //cnt
            tx.buff[0x0B] = 0x6F;
//             if (mode == EZSMode.NEC)
//             {
//                 tx.buff[0x0C] = DTnec[step];
//             }
//             else if (mode == EZSMode.MOT)
//             {
//                 tx.buff[0x0C] = DTmot[step];
//             }
            tx.buff[0x0C] = (byte)step;
            byte tmp_cmd = tx.buff[0x0C];


            rx = DeviceInteraction(tx);
            if (rx == null)
            {
                return(HIDResult.USBError);
            }
            else if (rx.CheckDataList() == false)
            {
                return(HIDResult.RxError);
            }
            else if (rx.buff[0x01] == 0x01)
            {
                return(HIDResult.ReadEZSError1);
            }
            else if (rx.buff[0x01] == 0x02)
            {
                return(HIDResult.ReadEZSError2);
            }
            else if (rx.buff[0x0B] != 0x70)
            {
                return(HIDResult.ReadEZSError3);
            }
//             else if (rx.buff[0x0C] != tmp_cmd)
//             {
//                 return HIDResult.ReadEZSError4;
//             }
            else if (rx.buff[1] == 0x00)
            {
                return(HIDResult.OK);
            }
            else
            {
                return(HIDResult.ReadEZSError5);
            }
        }
Example #6
0
        public HIDResult CANWrite4Step(int step, out InteractionData rx)
        {
            InteractionData tx = new InteractionData();

            tx.buff[0] = 0x14;
            tx.buff[1] = 0x55;  //主机-->设备
            tx.buff[4] = 0x20;
            for (int i = 0; i < 0x10; i++)
            {
                tx.buff[i + 0x10] = CANwr_d[step % 2, i];
            }
            if (step % 2 == 1)
            {
                for (int i = 0; i < 0x08; i++)
                {
                    tx.buff[i + 0x13] = DTwr[0x08 * DTwrIndex + i];//DATAwr[k][i];
                }
                tx.buff[0x12] = (byte)DTwrIndex;
                DTwrIndex++;
            }
            rx = DeviceInteraction(tx);
            if (rx == null)
            {
                return(HIDResult.USBError);
            }
            else if (rx.CheckDataList() == false)
            {
                return(HIDResult.RxError);
            }
            else if (rx.buff[1] == 0x00)
            {
                return(HIDResult.OK);
            }
            else if (rx.buff[1] == 0x03)
            {
                return(HIDResult.CANWriteWait);
            }
            else
            {
                return(HIDResult.CANErr);
            }
        }
        public bool Check_mima()
        {
            InteractionData tx = new InteractionData();

            tx.buff[0] = 0x03;
            tx.buff[1] = 0x55;  //主机-->设备
            InteractionData rx = DeviceInteraction(tx);

            if (rx == null || rx.CheckDataList() == false)
            {
                return(false);
            }
            KEY[0] = 0x02;
            KEY[1] = 0x58;
            KEY[2] = 0xBE;
            KEY[3] = 0x24;
//             KEY[4] = 0x8A;
//             KEY[5] = 0x95;
//             KEY[6] = 0x60;
//             KEY[7] = 0x3D;

            KEY[4] = (byte)(HexID[0] - 0x77);
            KEY[5] = (byte)(HexID[1] - 0x55);
            KEY[6] = (byte)(HexID[2] - 0x33);
            KEY[7] = (byte)(HexID[3] - 0x11);

            HOP[0] = rx.buff[0x14];
            HOP[1] = rx.buff[0x15];
            HOP[2] = rx.buff[0x16];
            HOP[3] = rx.buff[0x17];

            DECRYPT();
            if ((HOP[0x02] == rx.buff[0x18]) && (HOP[3] == rx.buff[0x19]))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Attention!\r\n After performing the procedure of reading the password key becomes disabled! Need to overwrite it! Continue?", "Waring", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;
            }
            textBox4.Text = "";
            textBox3.Text = "";
            textBox2.Text = "";
            textBox1.Text = "";
            WFGlobal.WaitMS(5);
            button1.Enabled      = false;
            button2.Enabled      = false;
            progressBar1.Visible = true;
            progressBar1.Value   = 0;
            if (HIDDevice.TheHIDDevice.Check_mima() == false)
            {
                MessageBox.Show("Authorization information error!!", "Error");
                progressBar1.Visible = false;
                button1.Enabled      = true;
                button2.Enabled      = true;
                return;
            }
            progressBar1.Value = 33;
            WFGlobal.WaitMS(5);
            toolStripStatusLabel2.Text = "读取中......";
            PSWrd = false;
            InteractionData tx = new InteractionData();

            tx.buff[0] = 0x0c;
            tx.buff[1] = 0x55;  //主机-->设备
            InteractionData rx = HIDDevice.TheHIDDevice.DeviceInteraction(tx);

            if (rx == null)
            {
                toolStripStatusLabel2.Text      = "USB Error!!";
                toolStripStatusLabel2.ForeColor = System.Drawing.Color.Red;
            }
            else if (rx.CheckDataList() == false)
            {
                toolStripStatusLabel2.Text      = "Reciece Error!!";
                toolStripStatusLabel2.ForeColor = System.Drawing.Color.Red;
            }
            else if (rx.buff[1] == 0x03)
            {
                toolStripStatusLabel2.Text      = "Get PSW Error 3 !!";
                toolStripStatusLabel2.ForeColor = System.Drawing.Color.Red;
            }
            else if (rx.buff[1] != 0x00)
            {
                toolStripStatusLabel2.Text      = "Get PSW Error 1 !!";
                toolStripStatusLabel2.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                progressBar1.Value = 66;
                WFGlobal.WaitMS(5);
                tx         = new InteractionData();
                tx.buff[0] = 0x01;
                tx.buff[1] = 0xaa;      //主机<--设备
                tx.buff[4] = 0x20;
                rx         = HIDDevice.TheHIDDevice.DeviceInteraction(tx);
                if (rx == null)
                {
                    toolStripStatusLabel2.Text      = "USB Error!!";
                    toolStripStatusLabel2.ForeColor = System.Drawing.Color.Red;
                }
                else if (rx.CheckDataList() == false)
                {
                    toolStripStatusLabel2.Text      = "Reciece Error!!";
                    toolStripStatusLabel2.ForeColor = System.Drawing.Color.Red;
                }
                else if (rx.buff[1] != 0x01)
                {
                    toolStripStatusLabel2.Text      = "Get PSW Error 2 !!";
                    toolStripStatusLabel2.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    toolStripStatusLabel2.Text = "读取成功!!";

                    toolStripStatusLabel2.ForeColor = System.Drawing.Color.Green;
                    byte[] BufPassWord = new byte[0x18];
                    for (int i = 0; i < 0x18; i++)
                    {
                        BufPassWord[i] = rx.buff[i + 0x10];
                    }
                    for (int i = 0; i < 0x18; i++)
                    {
                        PSWpub[i] = BufPassWord[i];
                    }
                    //
                    //PSW
                    PSWpub[0x00] = BufPassWord[0x07];
                    PSWpub[0x01] = BufPassWord[0x0F];
                    PSWpub[0x02] = BufPassWord[0x00];
                    PSWpub[0x03] = BufPassWord[0x01];
                    PSWpub[0x04] = BufPassWord[0x02];
                    PSWpub[0x05] = BufPassWord[0x03];
                    PSWpub[0x06] = BufPassWord[0x04];
                    PSWpub[0x07] = BufPassWord[0x05];
                    PSWpub[0x08] = BufPassWord[0x06];
                    //SSID
                    PSWpub[0x09] = BufPassWord[0x0B];
                    PSWpub[0x0A] = BufPassWord[0x0C];
                    PSWpub[0x0B] = BufPassWord[0x0D];
                    PSWpub[0x0C] = BufPassWord[0x0E];
                    //HASH
                    PSWpub[0x0D] = BufPassWord[0x0A];
                    PSWpub[0x0E] = BufPassWord[0x09];
                    PSWpub[0x0F] = BufPassWord[0x08];
                    PSWpub[0x10] = BufPassWord[0x17];
                    PSWpub[0x11] = BufPassWord[0x16];
                    PSWpub[0x12] = BufPassWord[0x15];
                    PSWpub[0x13] = BufPassWord[0x14];
                    PSWpub[0x14] = BufPassWord[0x13];
                    //OTHERS
                    PSWpub[0x15] = BufPassWord[0x12];
                    PSWpub[0x16] = BufPassWord[0x11];
                    PSWpub[0x17] = BufPassWord[0x10];

                    textBox4.Text      = WFNetLib.Strings.StringsFunction.byteToHexStr(PSWpub, 0x0d, 8, " "); //HASH
                    textBox3.Text      = WFNetLib.Strings.StringsFunction.byteToHexStr(PSWpub, 0x01, 8, " "); //PSD
                    textBox1.Text      = WFNetLib.Strings.StringsFunction.byteToHexStr(PSWpub, 0x09, 4, " "); //serial
                    textBox2.Text      = (BufPassWord[0x0B] & 0x07).ToString();                               //key
                    PSWrd              = true;
                    progressBar1.Value = 100;
                    MessageBox.Show("Read PSW OK!!");
                }
            }
            progressBar1.Visible = false;
            button1.Enabled      = true;
            button2.Enabled      = true;
        }
Example #9
0
        void Renew()
        {
            if (HIDDevice.TheHIDDevice == null)
            {
                MessageBox.Show("请连接设备");
                return;
            }
            if (MessageBox.Show("是否要擦除?", "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                return;
            this.Enabled = false;
            progressBar1.Visible = true;
            progressBar1.Value = 0;            
            if (HIDDevice.TheHIDDevice.Check_mima() == false)
            {
                MessageBox.Show("Authorization information error!!", "Error");
                this.Enabled = true;
                progressBar1.Visible = false;
                return;
            }
            progressBar1.Value = 50;
            toolStripStatusLabel6.Text = "擦除中......";
            toolStripStatusLabel6.ForeColor = System.Drawing.Color.Green;
            WFGlobal.WaitMS(5); 
            InteractionData tx = new InteractionData();
            if (radioButton1.Checked)
                tx.buff[0] = 0x0A;
//             else if (radioButton2.Checked)
//                 tx.buff[0] = 0x0B;
            else if (radioButton3.Checked)
                tx.buff[0] = 0x12;
            else
            {
                toolStripStatusLabel6.Text = "No Options!!";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Red;
                return;
            }
            tx.buff[1] = 0x55;	//主机-->设备
//             tx.buff[8] = HIDDevice.SwVer[1];//L
//             tx.buff[9] = HIDDevice.SwVer[0];//H
            InteractionData rx = HIDDevice.TheHIDDevice.DeviceInteraction(tx);
            if (rx == null)
            {
                toolStripStatusLabel6.Text = "USB Error!!";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Red;
            }
            else if (rx.CheckDataList() == false)
            {
                toolStripStatusLabel6.Text = "Reciece Error!!";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Red;
            }
            else if (rx.buff[1] != 0)
            {
                toolStripStatusLabel6.Text = "擦除错误!!";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                toolStripStatusLabel6.Text = "擦除成功";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Green;
                progressBar1.Value = 100;
                MessageBox.Show("擦除成功!!");
            }
            this.Enabled = true;
            progressBar1.Visible = false;
        }
Example #10
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            if (HIDDevice.TheHIDDevice == null)
            {
                MessageBox.Show("请连接设备");
                return;
            }
            textBox4.Text = "";
            textBox5.Text = "";
            textBox6.Text = "";
            textBox7.Text = "";
            textBox9.Text = "";
            textBox10.Text = "";
            textBox11.Text = "";
            if (HIDDevice.TheHIDDevice.Check_mima() == false)
            {
                MessageBox.Show("Authorization information error!!","Error");
                return;
            }
            toolStripStatusLabel6.Text = "读取中......";
            toolStripStatusLabel6.ForeColor = System.Drawing.Color.Green;
            WFGlobal.WaitMS(5);
            InteractionData tx = new InteractionData();
            if (radioButton1.Checked)
                tx.buff[0] = 0x08;
//             else if (radioButton2.Checked)
//                 tx.buff[0] = 0x09;
            else if (radioButton3.Checked)
                tx.buff[0] = 0x10;
            else
            {
                toolStripStatusLabel6.Text = "No Options!!";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Red;
                return;
            }
            tx.buff[1] = 0x55;	//主机-->设备
//             tx.buff[8] = HIDDevice.SwVer[1];//L
//             tx.buff[9] = HIDDevice.SwVer[0];//H
            InteractionData rx = HIDDevice.TheHIDDevice.DeviceInteraction(tx);
            if (rx == null)
            {
                toolStripStatusLabel6.Text = "USB Error!!";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Red;
            }
            else if (rx.CheckDataList() == false)
            {
                toolStripStatusLabel6.Text = "Reciece Error!!";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Red;
            }
            else if (rx.buff[1] != 0)
            {
                toolStripStatusLabel6.Text = "读取错误!!";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                toolStripStatusLabel6.Text = "读取成功";
                toolStripStatusLabel6.ForeColor = System.Drawing.Color.Green;
                if (0x55 == rx.buff[0x10])
                {
                    textBox4.Text = (rx.buff[0x15] & 0x07).ToString();//key
                    //rx.buff[0x15] = (byte)(rx.buff[0x15] & 0xF8);
                    textBox5.Text = WFNetLib.Strings.StringsFunction.byteToHexStr(rx.buff, 0x15, 4, " ");//serial                    
                    byte[] CvtIn = new byte[3];
                    CvtIn[0] = rx.buff[0x14];//0x2F;
                    CvtIn[1] = rx.buff[0x13];//0x1F;
                    CvtIn[2] = rx.buff[0x12];//0x7F;
                    textBox11.Text = WFNetLib.Strings.StringsFunction.byteToHexStr(CvtIn, " ");//counts    
                    int lift = rx.buff[0x14] * 32 * 128 + rx.buff[0x13] * 128 + rx.buff[0x12];
                    textBox7.Text = lift.ToString();
                }
                else
                {
                    textBox5.Text = "";
                    textBox4.Text = "";
                    textBox11.Text = "";
                }
                if (0x55 == rx.buff[0x20])
                {
                    textBox6.Text = WFNetLib.Strings.StringsFunction.byteToHexStr(rx.buff, 0x25, 2, " ");//Status
                    textBox10.Text = rx.buff[0x23].ToString("X2");//Ver.Soft
                    textBox9.Text = WFNetLib.Strings.StringsFunction.byteToHexStr(rx.buff, 0x33, 6, " ");//Remark
                }
                else
                {
                    textBox6.Text = "";
                    textBox10.Text = "";
                    textBox9.Text = "";
                }
            }
        }