Пример #1
0
        private void DeviceInterface_Load(object sender, EventArgs e)
        {
            do
            {
                UInt32 uiModelNameMajor      = 0;
                string strModule             = string.Empty;
                string strModuleSub          = string.Empty;
                rfid.Constants.Result result = rfid.Constants.Result.OK;

                //Get Model Name
                result = m_clsInterface.API_MacReadOemData((ushort)((int)enumOEM_ADDR.MODEL_NAME_MAIN), ref uiModelNameMajor);
                //result = m_clsInterface.API_MacReadOemData((ushort)((int)enumOEM_ADDR.MODEL_NAME_SUB), ref uiModelNameMajor);

                if (rfid.Constants.Result.OK != result)
                {
                    btn_Update.Enabled = false;
                    break;
                }

                strModule = String.Format("RU-{0}{1}{2}",
                                          (char)((uiModelNameMajor >> 16) & 0xFF),
                                          (char)((uiModelNameMajor >> 8) & 0xFF),
                                          (char)(uiModelNameMajor & 0xFF));

                if (strModule == "RU-861")
                {
                    rBtn_USB.Checked   = true;
                    rBtn_UART.Checked  = true;
                    btn_Update.Enabled = true;
                    break;
                }

                if (strModule == "RU-824")
                {
                    rBtn_USB.Checked   = true;
                    btn_Update.Enabled = false;
                    rBtn_UART.Enabled  = false;
                    break;
                }

                UInt32 oemData = 0;
                result = m_clsInterface.API_MacReadOemData((ushort)enumOEM_ADDR.HOST_IF_SEL, ref oemData);
                if (rfid.Constants.Result.OK != result)
                {
                    btn_Update.Enabled = false;
                    break;
                }

                if (oemData == (uint)enumPORT.ENUM_PORT_USB)
                {
                    rBtn_USB.Checked  = true;
                    rBtn_UART.Checked = false;
                }
                else
                {
                    rBtn_USB.Checked  = false;
                    rBtn_UART.Checked = true;
                }
            }while(false);
        }
Пример #2
0
        private void DeviceInterface_Load(object sender, EventArgs e)
        {
            do
            {
                UInt32 uiModelNameMajor = 0;
                string strModule        = string.Empty;
                //Mod by Wayne for supporting M.2/R2000 module, 2016-08-01
                //string                strModuleSub  = string.Empty;
                rfid.Constants.Result result = rfid.Constants.Result.OK;
                UInt32 oemData = 0;

                //initial
                btn_Update.Enabled = false;
                rBtn_USB.Enabled   = false;
                rBtn_UART.Enabled  = false;
                rBtn_USB.Checked   = false;
                rBtn_UART.Checked  = false;

                result = m_clsInterface.API_MacReadOemData((ushort)enumOEM_ADDR.HOST_IF_SEL, ref oemData);
                if (rfid.Constants.Result.OK != result)
                {
                    break;
                }

                if (oemData == (uint)enumPORT.ENUM_PORT_USB)
                {
                    rBtn_USB.Checked = true;
                }
                else if (oemData == (uint)enumPORT.ENUM_PORT_UART)
                {
                    rBtn_UART.Checked = true;
                }

                //Get Model Name
                result = m_clsInterface.API_MacReadOemData((ushort)((int)enumOEM_ADDR.MODEL_NAME_MAIN), ref uiModelNameMajor);

                if (rfid.Constants.Result.OK != result)
                {
                    break;
                }

                switch (uiModelNameMajor)
                {
                //USB only
                case 0x00383234:     //824
                case 0x4D303658:     //M06
                case 0x4D303758:     //M07 //Add by Wayne for support M06 and M07 module, 2017-08-09.
                    rBtn_USB.Checked = true;
                    rBtn_USB.Enabled = true;
                    break;

                //UART only
                case 0x4D303258:     //M02
                case 0x4D303358:     //M03
                    rBtn_UART.Checked = true;
                    rBtn_UART.Enabled = true;
                    break;

                //USB and UART
                case 0x00383631:     //861
                    btn_Update.Enabled = true;
                    rBtn_USB.Enabled   = true;
                    rBtn_UART.Enabled  = true;
                    break;

                default:
                    break;
                }

                /*
                 * //Get Model Name
                 * result  = m_clsInterface.API_MacReadOemData((ushort)((int)enumOEM_ADDR.MODEL_NAME_MAIN), ref uiModelNameMajor);
                 * //result = m_clsInterface.API_MacReadOemData((ushort)((int)enumOEM_ADDR.MODEL_NAME_SUB), ref uiModelNameMajor);
                 *
                 * if (rfid.Constants.Result.OK != result)
                 * {
                 * btn_Update.Enabled = false;
                 * break;
                 * }
                 *
                 * strModule= String.Format( "RU-{0}{1}{2}",
                 *        (char)((uiModelNameMajor >> 16) & 0xFF),
                 *        (char)((uiModelNameMajor >>  8) & 0xFF),
                 *        (char)( uiModelNameMajor        & 0xFF)   );
                 *
                 * if (strModule == "RU-861")
                 * {
                 * rBtn_USB.Checked = true;
                 * rBtn_UART.Checked = true;
                 * btn_Update.Enabled = true;
                 * break;
                 * }
                 *
                 * if (strModule == "RU-824")
                 * {
                 * rBtn_USB.Checked   = true;
                 * btn_Update.Enabled = false;
                 * rBtn_UART.Enabled  = false;
                 * break;
                 * }
                 *
                 * UInt32 oemData = 0;
                 * result = m_clsInterface.API_MacReadOemData( (ushort) enumOEM_ADDR.HOST_IF_SEL, ref oemData);
                 * if (rfid.Constants.Result.OK != result)
                 * {
                 * btn_Update.Enabled = false;
                 * break;
                 * }
                 *
                 * if (oemData == (uint)enumPORT.ENUM_PORT_USB)
                 * {
                 * rBtn_USB.Checked = true;
                 * rBtn_UART.Checked = false;
                 * }
                 * else
                 * {
                 * rBtn_USB.Checked = false;
                 * rBtn_UART.Checked = true;
                 * }
                 *
                 *
                 */
            }while(false);
        }
Пример #3
0
//==========================Other=========================================

        /*private DEV_MODE AskMode()
         * {
         *  Result result = Result.FAILURE;
         *
         *  do
         *  {
         *      //Check BL Mode
         *      result = GetVersion(DEV_MODE.BL);
         *
         *      if ( Result.OK == result )
         *      {
         *          m_Mode = DEV_MODE.BL;
         *          break;
         *      }
         *      else if(  Result.FWUPD_CMD_IGN == result  )
         *      {
         *          m_Mode = DEV_MODE.BL_ENTER_UPDATE;
         *          break;
         *      }
         *
         *      //Check AP mode
         *      if ( Result.OK == GetVersion(DEV_MODE.AP) )
         *      {
         *          m_Mode = DEV_MODE.AP;
         *          break;
         *      }
         *
         *      m_Mode = DEV_MODE.NO;
         *
         *  }while(false);
         *
         *  return m_Mode;
         * }*/

        private void GetOEMVersion()
        {
            OEMCfgVersion      Oversion             = new OEMCfgVersion();
            OEMCfgUpdateNumber OversionUpdateNumber = new OEMCfgUpdateNumber();
            //取得OEM版號
            Result result = Result.FAILURE;

            result = m_clsInterface.API_MacGetOEMCfgVersion(ref Oversion);
            result = m_clsInterface.API_MacGetOEMCfgUpdateNumber(ref OversionUpdateNumber);

            /*ControlItem(ENUM_ITEM_TYPE.TEXT_VER, String.Format("[OEM] {0}.{1}.{2}",
             *  (char)Oversion.major,
             *  (char)Oversion.minor,
             *  (char)Oversion.release));*/
            /*textBoxOEMVersion.Text=String.Format("[OEM] {0}.{1}{2}-up{3}{4}",
             *  (char)Oversion.major,
             *  (char)Oversion.minor,
             *  (char)Oversion.release,
             *  (char)OversionUpdateNumber.major,
             *  (char)OversionUpdateNumber.minor);*/
            ReaderOEMNumber = String.Format("{0}.{1}{2}",
                                            (char)Oversion.major,
                                            (char)Oversion.minor,
                                            (char)Oversion.release);
            ControlItem(ENUM_ITEM_TYPE.TEXT_OEMVER, String.Format("[OEM]{0}.{1}{2}up{3}{4}",
                                                                  (char)Oversion.major, (char)Oversion.minor, (char)Oversion.release,
                                                                  (char)OversionUpdateNumber.major, (char)OversionUpdateNumber.minor));
            //Show device type
            ControlItem(ENUM_ITEM_TYPE.TEXT_DEVICE, rfid.clsPacket.TRANS_API_AskDevType().ToString());

            //GetModelName
            do
            {
                UInt32 uiModelNameMajor       = 0;
                UInt32 uiModelNameSub         = 0;
                string strModule              = string.Empty;
                string strModuleSub           = string.Empty;
                rfid.Constants.Result resultM = rfid.Constants.Result.OK;

                //Get Model Name
                resultM = m_clsInterface.API_MacReadOemData((ushort)((int)enumOEM_ADDR.MODEL_NAME_MAIN), ref uiModelNameMajor);
                resultM = m_clsInterface.API_MacReadOemData((ushort)((int)enumOEM_ADDR.MODEL_NAME_SUB), ref uiModelNameSub);

                /*
                 * textBoxModelName.Text = String.Format("RU-{0}{1}{2}-{3}{4}{5}{6}",
                 *                                 (char)((uiModelNameMajor >> 16) & 0xFF),
                 *                                 (char)((uiModelNameMajor >> 8) & 0xFF),
                 *                                 (char)(uiModelNameMajor & 0xFF),
                 *                                 (char)((uiModelNameSub >> 16) & 0xFF),
                 *                                 (char)((uiModelNameSub >> 8) & 0xFF),
                 *                                 (char)(uiModelNameSub & 0xFF),
                 *                                 (char)((uiModelNameSub >> 24) & 0xFF));*/

                if (uiModelNameMajor == 0x4D303258) //0x4D303258==M02X
                {
                    textBoxModelName.Text = String.Format("RU00-{0}{1}{2}-{3}{4}{5}{6}",
                                                          (char)((uiModelNameMajor >> 24) & 0xFF),
                                                          (char)((uiModelNameMajor >> 16) & 0xFF),
                                                          (char)((uiModelNameMajor >> 8) & 0xFF),
                                                          (char)(uiModelNameMajor & 0xFF),
                                                          (char)((uiModelNameSub >> 16) & 0xFF),
                                                          (char)((uiModelNameSub >> 8) & 0xFF),
                                                          (char)(uiModelNameSub & 0xFF));
                }
                else
                {
                    textBoxModelName.Text = String.Format("RU-{0}{1}{2}-{3}{4}{5}{6}",
                                                          (char)((uiModelNameMajor >> 16) & 0xFF),
                                                          (char)((uiModelNameMajor >> 8) & 0xFF),
                                                          (char)(uiModelNameMajor & 0xFF),
                                                          (char)((uiModelNameSub >> 16) & 0xFF),
                                                          (char)((uiModelNameSub >> 8) & 0xFF),
                                                          (char)(uiModelNameSub & 0xFF),
                                                          (char)((uiModelNameSub >> 24) & 0xFF));
                }
            } while (false);
        }
Пример #4
0
//===========================Back Ground==========================================
        private void MonitorUpdate(object sender, DoWorkEventArgs e)
        {
            MacBootLoaderVersion Version = new MacBootLoaderVersion();
            string strFilePath           = textFilePath.Text;

            Result result = Result.FAILURE;
            //Updatedata           strcData;
            int iLast = 0;
            int i;


#if _TRACE_OUT_PUT
            m_clsInterface.PrintMagToTxt("--MonitorUpdate---");
#endif

            //ControlItem(ENUM_ITEM_TYPE.TEXT_VER, "");

            //Clear buffer
            //Mod by Wayne for implement high baud rate function, 2015-06-05
            rfid.clsPacket.Mid_API_ClearBuffer();
            //rfid.clsPacket.TRANS_API_ClearBuffer();
            //End by Wayne for implement high baud rate function, 2015-06-05

            //Compare OEMFile VersionNumber with Reader OEMVersionNumber
            if (sLine != ReaderOEMNumber)
            {
                ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, string.Format(" Write OEMCfg file failure."));
                //m_clsBackThread.ReportProgress(0);
                ControlItem(ENUM_ITEM_TYPE.PROG_SET_MAX, (int)m_lFileSize);
                ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
                ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));

                MessageBox.Show(string.Format("The browser file is invalid for this product.", result.ToString()),
                                " ",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            else//Write OEM File to the device
            {
                //ControlItem(ENUM_ITEM_TYPE.PROG_SET_MAX, (int)m_lFileSize);
                ControlItem(ENUM_ITEM_TYPE.PROG_SET_MAX, 100);
                ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
                ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));
                //rfid.Constants.Result status;
                OEMPercentageFlag = false;
                StreamReader OEMReader = new StreamReader(m_fileStream);
                iRealReadCountOEM = (int)m_lFileSize;
                while ((addLine = OEMReader.ReadLine()) != null)
                {
                    iRealReadCountOEM = iRealReadCountOEM - (addLine.Length + 2);
                    if (addLine.Contains("0x"))
                    {
                        if (OEMPercentageFlag == false)
                        {
                            iRealReadCountOEMBtnHalf = iRealReadCountOEM + 23;//BtnHalf=Total-TopHalf
                            iRealReadCountOEMBtnHalf = iRealReadCountOEMBtnHalf / 23;
                            OEMPercentage            = Convert.ToInt16(Math.Ceiling((100.0 / iRealReadCountOEMBtnHalf)));
                            OEMPercentageFlag        = true;
                        }

                        iLast = iLast + (int)OEMPercentage;
                        if (iLast > 100)
                        {
                            i = 100 - (iLast - (int)OEMPercentage);
                            if (i > 0)
                            {
                                OEMPercentage = i;
                            }
                        }

                        OEMLine  = addLine.Split(',');
                        addLine  = OEMLine[0].Trim();
                        dataLine = OEMLine[1].Trim();
                        string[] SusaddLine = addLine.Split('x');
                        addLine    = SusaddLine[1].Trim();
                        OEMAddress = UInt16.Parse(addLine, System.Globalization.NumberStyles.HexNumber);
                        string[] SusdataLine = dataLine.Split('x');
                        dataLine = SusdataLine[1].Trim();
                        OEMData  = UInt32.Parse(dataLine, System.Globalization.NumberStyles.HexNumber);
                        switch (m_clsInterface.API_MacWriteOemData(OEMAddress, OEMData))
                        {
                        case rfid.Constants.Result.OK:
                            switch (m_clsInterface.API_MacReadOemData(OEMAddress, ref checkOEMData))
                            {
                            case rfid.Constants.Result.OK:
                                if (OEMData != checkOEMData)        //Compare Error
                                {
                                    MessageBox.Show("Write OEMData Failure.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
                                    ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));
                                    return;
                                }
                                m_clsBackThread.ReportProgress((int)OEMPercentage);
                                UpdateOEMCfgCompleteFlag = true;
                                break;

                            case rfid.Constants.Result.INVALID_PARAMETER:
                                UpdateOEMCfgCompleteFlag = false;
                                MessageBox.Show("Invalid Parameter.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
                                ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));
                                return;

                            case rfid.Constants.Result.FAILURE:
                                //Get error
                                result = m_clsInterface.API_MacGetError(ref uiCurError, ref uiLastError);
                                if (result == rfid.Constants.Result.OK)
                                {
                                    MessageBox.Show(string.Format("Error Code: 0x{0:X3}", uiCurError), " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    UpdateOEMCfgCompleteFlag = false;
                                    ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
                                    ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));
                                    return;
                                }
                                UpdateOEMCfgCompleteFlag = false;
                                ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
                                ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));
                                break;
                            }
                            break;

                        case rfid.Constants.Result.INVALID_PARAMETER:
                            MessageBox.Show(string.Format("Write OEM Address(h): 0x{0} Fail [INVALID_PARAMETER]", addLine), " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            UpdateOEMCfgCompleteFlag = false;
                            ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
                            ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));
                            return;

                        case rfid.Constants.Result.FAILURE:
                            //Get error
                            result = m_clsInterface.API_MacGetError(ref uiCurError, ref uiLastError);
                            if (result == rfid.Constants.Result.OK)
                            {
                                MessageBox.Show(string.Format("Error Code: 0x{0:X3}", uiCurError), " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                UpdateOEMCfgCompleteFlag = false;
                                ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
                                ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));
                                return;
                            }
                            UpdateOEMCfgCompleteFlag = false;
                            ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
                            ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));
                            break;
                        }
                    }
                }

                //m_lFileSize = m_lFileSize - 40;
                //m_clsBackThread.ReportProgress(40);
                //for (int filesize = 0; filesize<(int)m_lFileSize; filesize = filesize + 40)
                //{
                //Increase progress bar
                //m_clsBackThread.ReportProgress((int)m_lFileSize);
                //m_clsBackThread.ReportProgress(filesize);
                //}
                //System.Threading.Thread.Sleep(10);
            }
            //m_clsBackThread.ReportProgress(100);
            ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "Update progress finished.");
            MessageBox.Show("Update OEMCfg successfully.");
            //initial Progress Bar
            ControlItem(ENUM_ITEM_TYPE.PROG_SET_MAX, 100);
            ControlItem(ENUM_ITEM_TYPE.PROG_CLEAR, null);
            ControlItem(ENUM_ITEM_TYPE.LABEL_PERCENT_TEXT, string.Format("{0}%", 0));
            m_clsInterface.API_ControlSoftReset();
//            OpenDevice();
//            Connect();
//            GetOEMVersion();
        }