Esempio n. 1
0
        private bool ReadBypassRegsiter(ushort address, out ushort data, bool print)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;

            data = ushort.MaxValue;

            /* Bypass Register Read */
            try
            {
                result = Reader.MacBypassReadRegister(address, out data);
            }
            catch (Exception)
            {
                StatusUpdate("Read Bypass Register Exception", TextUpdateType.Error);
                return(false);
            }

            if (result == rfid.Constants.Result.OK)
            {
                StatusUpdate(print, string.Format("Read Bypass [{0:X4}] = {1:X4}", address, data), TextUpdateType.Success);
            }
            else
            {
                StatusUpdate(print, string.Format("Read Bypass Fail [{0}] [{1:X4}] ", result, address), TextUpdateType.Error);
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        private bool GetMacError(out uint errorCode, out uint lastErrorCode)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;

            errorCode     = uint.MaxValue;
            lastErrorCode = uint.MaxValue;

            /* MacGetError */
            try
            {
                result = Reader.MacGetError(out errorCode, out lastErrorCode);
            }
            catch (Exception)
            {
                StatusUpdate("GetMacError Exception", TextUpdateType.Error);
                return(false);
            }

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

            return(true);
        }
Esempio n. 3
0
        private bool WriteOemRegsiter(ushort address, uint data, bool print)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;

            /* Oem Register Write */
            try
            {
                result = Reader.MacWriteOemData(address, data);
            }
            catch (Exception)
            {
                StatusUpdate("Write OEM Register Exception", TextUpdateType.Error);
                return(false);
            }

            if (result == rfid.Constants.Result.OK)
            {
                StatusUpdate(print, string.Format("Write OEM [{0:X4}] = {1:X8}", address, data), TextUpdateType.Success);
            }
            else
            {
                StatusUpdate(print, string.Format("Write OEM Fail [{0}]", result), TextUpdateType.Error);
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        private bool ReadOemRegsiter(ushort address, out uint data, bool print)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;

            uint OemData = 0;

            data = uint.MaxValue;

            /* OEM Register Read */
            try
            {
                result = Reader.MacReadOemData(address, ref OemData);
            }
            catch (Exception)
            {
                StatusUpdate("Read OEM Register Exception", TextUpdateType.Error);
                return(false);
            }

            if (result == rfid.Constants.Result.OK)
            {
                data = OemData;
                StatusUpdate(print, string.Format("Read OEM [{0:X4}] = {1:X8}", address, data), TextUpdateType.Success);
            }
            else
            {
                StatusUpdate(print, string.Format("Read OEM Fail [{0}] [{1:X4}]", result, address), TextUpdateType.Error);
                return(false);
            }

            return(true);
        }
        private void RestoreDefaultButton_Click(object sender, EventArgs e)
        {
            this.antennaList.Clear();

            this.antennaList.AddRange(Source_AntennaList.DEFAULT_ANTENNA_LIST);

            rfid.Constants.Result result =
                this.antennaList.store(LakeChabotReader.MANAGED_ACCESS, this.reader.ReaderHandle);

            if (rfid.Constants.Result.OK != result)
            {
                Console.WriteLine("Error {0} while setting default antenna configurations");
            }

            // Magic numbers - argh - just adding this for 'uniformity'
            // so that everything on the panel

            //Antenna Sense threshold
            globalSenseThresholdVal = 0xFFFFF;
            rfid.Constants.Result status = rfid.Constants.Result.OK;

            try
            {
                status = reader.API_AntennaPortSetSenseThreshold(globalSenseThresholdVal);
            }
            catch (Exception)
            {
                status = rfid.Constants.Result.RADIO_FAILURE;

                globalSenseThreshold.Text = "UNKNOWN";

                return;
            }

            this.updateThreshold();



            //RfPowerThreshold
            UInt32 oem_rf_threshold = 0;

            numericUpDownRfPowerThreshold.Value = 0x0000001E;
            oem_rf_threshold = (UInt32)numericUpDownRfPowerThreshold.Value;

            //clark not sure. Wait firmware support this function.
            //status = reader.MacWriteOemData( (ushort) enumOEM_ADDR.ENUM_OEM_ADDR_RF_REVPWR_THRESHOLD,
            //                                          oem_rf_threshold                               );


            view.Refresh();
        }
Esempio n. 6
0
        private void TemperatureBTN_Click(object sender, EventArgs e)
        {
            //uint data = uint.MaxValue;
            int data = int.MaxValue;

            //data = Convert.ToUInt16(textBoxTemperature.Text);

            rfid.Constants.Result result = Result.NOT_INITIALIZED;

            result = LakeChabotReader.MANAGED_ACCESS.API_ControlSetPowerState(0);
            if (result != rfid.Constants.Result.OK)
            {
                ShowErrMsg("Control Set Power State unsuccessfully!");
                return;
            }

            //LakeChabotReader.MANAGED_ACCESS.API_TestTurnCarrierWaveOff();
            result = LakeChabotReader.MANAGED_ACCESS.API_TestTurnCarrierWaveOff();
            if (result != rfid.Constants.Result.OK)
            {
                ShowErrMsg("Test Turn Carrier Wave Off unsuccessfully!");
                return;
            }

            //result = m_reader.MacReadRegister(0x0b0a, out data);
            result = m_reader.MacReadRegisterGetTempature(0x0b0a, out data);
            if (result != rfid.Constants.Result.OK)
            {
                ShowErrMsg("Get Temperature unsuccessfully!");
                return;
            }

            /*
             * if (data < 0)
             * {
             *  //textBoxTemperature.Text = "-"+Convert.ToString(data) + " ℃"; //not sure
             *  textBoxTemperature.Text = Convert.ToString(data+1) + " ℃";
             *
             * }
             * else
             * {
             *  textBoxTemperature.Text = Convert.ToString(data) + " ℃";
             * }
             */

            textBoxTemperature.Text = Convert.ToString(data) + " ℃";
            //string val = Convert.ToString(data, 16);
            //int num = Convert.ToInt32(val, 16);

            //textBoxTemperature.Text = Convert.ToString(data)+" ℃";
        }
Esempio n. 7
0
        private bool ReadOemRegsiter(ushort address, out uint[] pData, uint count, out uint readCount, bool print)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;

            pData = new uint[count];
            uint requestedCount = count;

            readCount = 0;

            Array.Clear(pData, 0, pData.Length);

            /* OEM Register Read */
            try
            {
                //clark 2011.3.23. Only Transfer one data at one tme.
                for (int i = 0; i < count; i++)
                {
                    result = Reader.MacReadOemData(address, ref pData[i]);

                    if (result != Result.OK)
                    {
                        break;
                    }
                }
            }
            catch (Exception)
            {
                StatusUpdate("Read OEM Register Exception", TextUpdateType.Error);
                return(false);
            }

            if ((result == rfid.Constants.Result.INVALID_PARAMETER) && (count > 0))
            {
                result = rfid.Constants.Result.OK;
            }

            if (result == rfid.Constants.Result.OK)
            {
                readCount = count;
                StatusUpdate(print, string.Format("Read OEM Register Block [{0:X4}] ({1}/{2}) ", address, readCount, requestedCount), TextUpdateType.Success);
            }
            else
            {
                StatusUpdate(print, string.Format("Read OEM Register Block Fail [{0}] [{1:X4}]", result, address), TextUpdateType.Error);
                return(false);
            }

            return(true);
        }
        private void importButton_Click(object sender, EventArgs e)
        {
            Cursor priorCursor = null;

            RFID_Explorer.mainForm.CommonDialogSupport dlg =
                new mainForm.CommonDialogSupport(mainForm.CommonDialogSupport.DialogType.OpenAntenna);

            if (dlg.ShowDialog( ) == DialogResult.OK)
            {
                try
                {
                    this.Capture   = true;
                    priorCursor    = Cursor.Current;
                    Cursor.Current = Cursors.WaitCursor;
                    try
                    {
                        Source_AntennaList loadedAntennaList =
                            RFID_Explorer.ExcelExport.ImportAntennaConfig(this.reader, dlg.FileName);

                        rfid.Constants.Result result =
                            loadedAntennaList.store(LakeChabotReader.MANAGED_ACCESS, this.reader.ReaderHandle);

                        if (rfid.Constants.Result.OK != result)
                        {
                            throw new Exception(result.ToString( ));
                        }

                        this.antennaList.Clear( );
                        this.antennaList.AddRange(loadedAntennaList);

                        view.Refresh( );
                    }
                    catch (Exception e2)
                    {
                        MessageBox.Show(String.Format("Error importing antenna settings.\n\nThe import file contains this.errors and cannot be used until corrected.\n\n{0}", e2.Message), "Invalid import file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                finally
                {
                    if (priorCursor != null)
                    {
                        Cursor.Current = priorCursor;
                    }
                    this.Capture = false;
                }
            }
        }
Esempio n. 9
0
        private bool ReadMacRegsiterBank(ushort address, ushort bank, out uint data, bool print)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;
            RegisterInfo          registerInfo;

            data = uint.MaxValue;

            if (!GetMacRegsiterInfo(address, out registerInfo))
            {
                return(false);
            }

            if (registerInfo.type != RegisterType.BANKED)
            {
                StatusUpdate("Read Mac Register Bank (Not Banked)", TextUpdateType.Error);
                return(false);
            }

            /* Mac Bank Register Read */
            try
            {
                result = Reader.MacReadBankedRegister(address, bank, out data);
            }
            catch (Exception)
            {
                StatusUpdate("Read Mac Register Bank Exception", TextUpdateType.Error);
                return(false);
            }

            if (result == rfid.Constants.Result.OK)
            {
                StatusUpdate(print, string.Format("Read Mac Register Bank [{0:X4}][{1:X2}] = {2:X8}", address, bank, data), TextUpdateType.Success);
            }
            else
            {
                StatusUpdate(print, string.Format("Read Mac Register Bank Fail [{0}] [{1:X4}] ", result, address), TextUpdateType.Error);
                return(false);
            }

            /* Restore Original Selector */
            if (!WriteMacRegsiter(registerInfo.selectorAddress, registerInfo.currentSelector, false))
            {
                StatusUpdate("Read Mac Register Bank (Write Original Selector)", TextUpdateType.Error);
                return(false);
            }

            return(true);
        }
Esempio n. 10
0
        private bool GetMacRegsiterInfo(ushort address, out RegisterInfo registerInfo)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;
            registerInfo = new RegisterInfo();

            /* Mac Register Info Read */
            try
            {
                result = Reader.MacReadRegisterInfo(address, out registerInfo);
            }
            catch (Exception)
            {
                StatusUpdate("Get Mac Register Info Exception", TextUpdateType.Error);
                return(false);
            }

            return(true);
        }
Esempio n. 11
0
        private bool WriteMacRegsiterBank(ushort address, ushort bank, uint data, bool print)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;
            uint errorCode;
            uint lastErrorCode;

            if (!ClearMacError())
            {
                return(false);
            }

            /* Mac Register Bank Write */
            try
            {
                result = Reader.MacWriteBankedRegister(address, bank, data);
            }
            catch (Exception)
            {
                StatusUpdate("Write Mac Register Bank Exception", TextUpdateType.Error);
                return(false);
            }

            if (!GetMacError(out errorCode, out lastErrorCode))
            {
                return(false);
            }

            if ((result == rfid.Constants.Result.OK) && (errorCode == 0))
            {
                StatusUpdate(print, string.Format("Write Mac Register Bank [{0:X4}][{1:X2}] = {2:X8}", address, bank, data), TextUpdateType.Success);
            }
            else if (errorCode != 0)
            {
                StatusUpdate(print, string.Format("Write Mac Register Bank Fail (MacErr:{0:X4}) [{1:X4}][{2:X2}] = {3:X8}", errorCode, address, bank, data), TextUpdateType.Error);
                return(false);
            }
            else
            {
                StatusUpdate(print, string.Format("Write Mac Register Bank Fail [{0}]", result), TextUpdateType.Error);
                return(false);
            }

            return(true);
        }
        private void updateThreshold( )
        {
            rfid.Constants.Result status = rfid.Constants.Result.OK;

            try
            {
                status = reader.API_AntennaPortGetSenseThreshold(ref globalSenseThresholdVal);
            }
            catch (Exception)
            {
                status = rfid.Constants.Result.RADIO_FAILURE;

                globalSenseThreshold.Text = "UNKNOWN";

                return;
            }

            globalSenseThreshold.Text = globalSenseThresholdVal.ToString( );

            globalSenseThreshold.Refresh( );
        }
Esempio n. 13
0
        private bool ClearMacError()
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;

            /* MacClearError */
            try
            {
                result = Reader.MacClearError();
            }
            catch (Exception)
            {
                StatusUpdate("MacClearError Exception", TextUpdateType.Error);
                return(false);
            }

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

            return(true);
        }
Esempio n. 14
0
        private bool ReadMacRegsiter(ushort address, out uint data)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;

            data = uint.MaxValue;

            /* Mac Register Read */
            try
            {
                result = Reader.MacReadRegister(address, out data);
            }
            catch (Exception)
            {
                StatusUpdate("Read Mac Register Exception", TextUpdateType.Error);
                return(false);
            }

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

            return(true);
        }
Esempio n. 15
0
        // TODO : Move to locator & communicator class

        static LakeChabotReader( )
        {
            try
            {
                LakeChabotReader.MANAGED_ACCESS = new rfid.Linkage( );
            }
            catch ( Exception e )
            {
                throw e;  // TODO: more resolution of error e.g. missing dll
            }

            if (rfid.Constants.Result.OK != LakeChabotReader.MANAGED_ACCESS.API_Startup(LakeChabotReader.LIBRARY_VERSION, LakeChabotReader.LIBRARY_MODE))
            {
                throw new rfidException( rfidErrorCode.LibraryFailedToInitialize );
            }

            LakeChabotReader.LIBRARY_Result = rfid.Constants.Result.OK;

            // Track keyed by cookie ~ allow ( later ) to open and close radios
            // dynamically during application execution - currently ALL OPEN

            rfid.Structures.RadioEnumeration radioEnum = new rfid.Structures.RadioEnumeration( );


            //clark 2011.05.20 Show Tracer no matter the device is disconneced.
            //                 Let user to set comport.  
            LakeChabotReader.MANAGED_ACCESS.API_RetrieveAttachedRadiosList(radioEnum, 0);
            //if
            //(
            //    rfid.Constants.Result.OK !=
            //    LakeChabotReader.MANAGED_ACCESS.API_RetrieveAttachedRadiosList(radioEnum, 0)
            //)
            //{
            //    throw new rfidException( rfidErrorCode.LibraryFailedToInitialize );
            //}

            LakeChabotReader.LOCATED_READERS =
                new Dictionary<UInt32, rfid.Structures.RadioInformation>( );

            foreach ( rfid.Structures.RadioInformation radioInfo in radioEnum.radioInfo )
            {
                //clark 2011.3.23 not sure
                uint uiUniqueId = BitConverter.ToUInt32( radioInfo.uniqueId, 0);
                LakeChabotReader.LOCATED_READERS.Add(uiUniqueId, radioInfo);
                //LakeChabotReader.LOCATED_READERS.Add(radioInfo.cookie, radioInfo);
            }

            LakeChabotReader.OPENED_READERS =
                new Dictionary<UInt32, rfid.Structures.RadioInformation>( );

            try
            {
                new PerformanceCounter( "Processor", "% Processor Time", "_Total", "." );
            }
            catch ( Exception ) { }
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
        private bool ReadMacRegsiter(ushort address, out uint data, bool print)
        {
            rfid.Constants.Result result = Result.NOT_INITIALIZED;
            RegisterInfo          registerInfo;
            string infoString = "Unknown";

            data = uint.MaxValue;

            if (!GetMacRegsiterInfo(address, out registerInfo))
            {
                return(false);
            }

            string accessTypeString;

            switch (registerInfo.accessType)
            {
            case RegisterProtectionType.READ_WRITE:
                accessTypeString = "";
                break;

            case RegisterProtectionType.READ_ONLY:
                accessTypeString = " RO";
                break;

            case RegisterProtectionType.WRITE_ONLY:
                accessTypeString = " WO";
                break;

            default:
                accessTypeString = " NA";
                break;
            }

            switch (registerInfo.type)
            {
            case RegisterType.NORMAL:
                infoString = string.Format("Normal{0}", accessTypeString);
                break;

            case RegisterType.BANKED:
                infoString = string.Format("Banked{0} Sel:{1:X4}", accessTypeString, registerInfo.selectorAddress);
                break;

            case RegisterType.SELECTOR:
                infoString = string.Format("Selector{0} Size:{1}", accessTypeString, registerInfo.bankSize);
                break;

            case RegisterType.RESERVED:
                infoString = string.Format("Reserved");
                break;
            }

            /* Mac Register Read */
            try
            {
                result = Reader.MacReadRegister(address, out data);
                if (result != Result.OK)
                {
                    data = 0;
                }
            }
            catch (Exception)
            {
                StatusUpdate("Read Mac Register Exception", TextUpdateType.Error);
                return(false);
            }

            if (result == rfid.Constants.Result.OK)
            {
                if (registerInfo.type == RegisterType.BANKED)
                {
                    StatusUpdate(print, string.Format("Read Mac [{0:X4}][{1:X2}] = {2:X8} ({3})", address, registerInfo.currentSelector, data, infoString), TextUpdateType.Success);
                }
                else
                {
                    StatusUpdate(print, string.Format("Read Mac [{0:X4}] = {1:X8} ({2})", address, data, infoString), TextUpdateType.Success);
                }
            }
            else if (registerInfo.accessType == RegisterProtectionType.WRITE_ONLY)
            {
                StatusUpdate(print, string.Format("Read Mac [{0:X4}] ({1})", address, infoString), TextUpdateType.Success);
            }
            else if (registerInfo.type == RegisterType.RESERVED)
            {
                StatusUpdate(print, string.Format("Read Mac [{0:X4}] ({1})", address, infoString), TextUpdateType.Success);
            }
            else
            {
                StatusUpdate(print, string.Format("Read Mac Fail [{0}] [{1:X4}] ", result, address), TextUpdateType.Error);
                return(false);
            }

            return(true);
        }