예제 #1
0
        private string ShowOemData
        (
            UInt16 Offset
        )
        {
            UInt32 OemData = 0;

            UInt32 [] pOemData = null;
            UInt32    uiLength = 0;

            rfid.Constants.Result result = rfid.Constants.Result.OK;

            if (rfid.Constants.Result.OK != reader.MacReadOemData(Offset, ref OemData))
            {
                return(null);
            }

            uiLength  = (0 == (OemData & 0xFF) / 4) ? 1 : (OemData & 0xFF) / 4;
            uiLength += (uint)((0 == (OemData & 0xFF) % 4) ? 0 : 1);

            pOemData = new UInt32[uiLength];
            Array.Clear(pOemData, 0, pOemData.Length);

            pOemData[0] = OemData;
            //Offset++; //Point to  data address
            for (int i = 1; i < uiLength; i++)
            {
                result = reader.MacReadOemData((UInt16)(Offset + i), ref pOemData[i]);

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

            //return Source_OEMData.uint32ArrayToString(pOemData, 0);
            return(CGlobalFunc.uint32ArrayToString(pOemData, uiLength));
        }
예제 #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            FileStream fileStream = null;
            uint       FileCount  = 0;


            //Check fireware file
            if (m_clsOpenFileDlg.FileName == null)
            {
                ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "Please select a file.");
                return;
            }

            if (false == File.Exists(m_clsOpenFileDlg.FileName))
            {
                ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "The file doesn't exist.");
                return;
            }

            //Add by Wayne for improve FW upgrade feature for integrate M03X model, 2015-03-31
            //Check file name
            if (CGlobalFunc.CheckUpgradeFileName(m_clsOpenFileDlg.FileName) == false)
            {
                ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "Invalid upgrade file.");
                return;
            }

            uint ModelNamefromFileName = 0x0;

            if (m_clsOpenFileDlg.FileName.IndexOf("RU-824-X") != -1)
            {
                ModelNamefromFileName = 0x38323458;
            }
            else if (m_clsOpenFileDlg.FileName.IndexOf("RU-824") != -1)
            {
                ModelNamefromFileName = 0x383234;
            }
            else if (m_clsOpenFileDlg.FileName.IndexOf("RU-861") != -1)
            {
                ModelNamefromFileName = 0x383631;
            }
            else if (m_clsOpenFileDlg.FileName.IndexOf("RU00-M02-X") != -1)
            {
                ModelNamefromFileName = 0x4D303258;
            }
            else if (m_clsOpenFileDlg.FileName.IndexOf("RU00-M03-X") != -1)
            {
                ModelNamefromFileName = 0x4D303358;
            }
            //Add by Wayne for supporting M.2/R2000 module, 2016-08-01
            else if (m_clsOpenFileDlg.FileName.IndexOf("RU00-M06-X") != -1)
            {
                ModelNamefromFileName = 0x4D303658;
            }
            //End by Wayne for supporting M.2/R2000 module, 2016-08-01
            //Add by Wayne for FWUpdateTool support M07 module, 2016-12-16
            else if (m_clsOpenFileDlg.FileName.IndexOf("RU00-M07-X") != -1)
            {
                ModelNamefromFileName = 0x4D303758;
            }
            //End by Wayne for FWUpdateTool support M07 module, 2016-12-16

            if (m_Mode == DEV_MODE.AP)
            {
                //Compare model name between upgrade file name and OEM register
                if (reader.uiModelNameMAJOR != ModelNamefromFileName)
                {
                    ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "The upgrade file is incompatible with RFID module.");
                    return;
                }
            }
            //End by Wayne for improve FW upgrade feature for integrate M03X model, 2015-03-31

            //if is running update progress, cancel it.
            if (m_clsBackThread.IsBusy == true)
            {
                m_clsBackThread.CancelAsync();
                return;
            }


            //Check status
            if (DEV_MODE.NO == AskMode())
            {
                ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "Disconnected. Can't update.");
                return;
            }


            //Check file size
            if (fileStream == null)
            {
                fileStream = new FileStream(m_clsOpenFileDlg.FileName, FileMode.Open, FileAccess.Read, FileShare.None, 512, FileOptions.None);
            }
            //Mod by Wayne for improve FW upgrade feature for integrate M03X model, 2015-03-31
            //if (fileStream.Length <= 0)
            if (fileStream.Length != 204800)
            {
                ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "Incorrect file size.");
                //End by Wayne for improve FW upgrade feature for integrate M03X model, 2015-03-31
                fileStream.Close();
                return;
            }

            //Get version
            if (Result.OK != GetVersion(AskMode()))
            {
                fileStream.Close();
                return;
            }


            //if is in ap mode , change to BL mode
            if (m_Mode == DEV_MODE.AP)
            {
                if (Result.OK != m_clsInterface.API_ControlResetToBootLoader())
                {
                    ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "Turn to BL Mode unsuccessfully");
                    fileStream.Close();
                    return;
                }
                //Mod by Wayne for enable functions to fit M06 requirement, 2016-10-21
                //System.Threading.Thread.Sleep(500); //Add by Wayne for improve FW upgrade feature for integrate M03X model, 2015-03-31
                System.Threading.Thread.Sleep(1000);
                //End by Wayne for enable functions to fit M06 requirement, 2016-10-21
            }

            //Add by Wayne for improve FW upgrade feature for integrate M03X model, 2015-03-31
            //Compare model name between upgrade file name and firmware(new model only)
            if (m_clsInterface.API_UpdateGetModelName(ref MainModel) == Result.OK)
            {
                ControlItem(ENUM_ITEM_TYPE.TEXT_MODEL, String.Format("RU00-{0}{1}{2}-{3}",
                                                                     (char)((MainModel >> 24) & 0xFF),
                                                                     (char)((MainModel >> 16) & 0xFF),
                                                                     (char)((MainModel >> 8) & 0xFF),
                                                                     (char)(MainModel & 0xFF)));

                if (MainModel != ModelNamefromFileName)
                {
                    ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "Model name is inconsistent.");
                    fileStream.Close();
                    return;
                }
                uint UpdateKey = 0x0;
                if (m_clsInterface.API_UpdateGetUpdateKey(ref UpdateKey) == Result.OK)
                {
                    int    index         = m_clsOpenFileDlg.FileName.IndexOf("Key");
                    string UpdateKey_Str = Convert.ToString(UpdateKey);

                    ControlItem(ENUM_ITEM_TYPE.TEXT_KEY, String.Format("Key{0}", UpdateKey_Str.PadLeft(2, '0')));

                    if (UpdateKey_Str.PadLeft(2, '0') != m_clsOpenFileDlg.FileName.Substring(index + 3, 2))
                    {
                        ControlItem(ENUM_ITEM_TYPE.TEXT_STATUS, "Update key is inconsistent.");
                        fileStream.Close();
                        return;
                    }
                }
            }
            //End by Wayne for improve FW upgrade feature for integrate M03X model, 2015-03-31

            //initial setting
            m_fileStream  = fileStream;
            m_lFileSize   = m_fileStream.Length;
            m_uiFileCount = (FileCount == 0) ? 1 : FileCount;
            m_strFilePath = m_clsOpenFileDlg.FileName;
            m_bTestMode   = testModeToolStripMenuItem.Checked;


            //Disabel Item
            ControlItem(ENUM_ITEM_TYPE.MENU_SET_COM_PORT, false);
            ControlItem(ENUM_ITEM_TYPE.MENU_DEVICE_INTERFACE, false);
            ControlItem(ENUM_ITEM_TYPE.BTN_RELINK, false);
            ControlItem(ENUM_ITEM_TYPE.BTN_UPDATE_TEXT, "Stop");

            //Create thread
            m_clsBackThread = new BackgroundWorker( );
            m_clsBackThread.WorkerReportsProgress      = true;
            m_clsBackThread.WorkerSupportsCancellation = true;
            m_clsBackThread.DoWork             += new DoWorkEventHandler(MonitorUpdate);
            m_clsBackThread.ProgressChanged    += new ProgressChangedEventHandler(BackgroundProgress);
            m_clsBackThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundTaskCompleted);
            m_clsBackThread.RunWorkerAsync(!m_bTestMode);
        }