} //  Start18K6CRead

        bool CUST_18K6CTagRead(CSLibrary.Constants.MemoryBank bank, int offset, int count, UInt16[] data, UInt32 password, /*UInt32 retry, */ CSLibrary.Constants.SelectFlags flags)
        {
            if (count > MAX_RD_CNT)
            {
                return(false);       // too many data
            }
            Start18K6CRead((uint)bank, (uint)(offset), (uint)count, data, password, 1, flags);

            return(true);
        }
Beispiel #2
0
        void Setup18K6CWriteRegisters(CSLibrary.Constants.MemoryBank WriteBank, uint WriteOffset, uint WriteSize, UInt16[] WriteBuf, uint BufOffset)
        {
            int offset;
            int pcnt = 0;

            // Set up the tag bank register (tells where to write the data)
            MacWriteRegister(MACREGISTER.HST_TAGACC_BANK, (uint)WriteBank);

            // Set the offset
            //MacWriteRegister(MACREGISTER.HST_TAGACC_PTR, WriteOffset);
            MacWriteRegister(MACREGISTER.HST_TAGACC_PTR, 0);

            // Set up the access count register (i.e., number of words to write)
            MacWriteRegister(MACREGISTER.HST_TAGACC_CNT, WriteSize);

            // Set up the HST_TAGWRDAT_N registers.  Fill up a bank at a time.
            for (UInt32 registerBank = 0; WriteSize > 0; registerBank++)
            {
                uint value = 0;

                // Indicate which bank of tag write registers we are going to fill
                MacWriteRegister(MACREGISTER.HST_TAGWRDAT_SEL, registerBank);

                /*
                 *              MacReadRegister(MACREGISTER.MAC_ERROR, ref value);
                 *
                 *              if (value == HOSTIF_ERR_SELECTORBNDS)
                 *              {
                 *                      MacClearError();
                 *                      return;
                 *              }
                 */

                // Write the values to the bank until either the bank is full or we run out of data
                UInt16 registerAddress = (UInt16)MACREGISTER.HST_TAGWRDAT_0;
                offset = 0;

                while ((WriteSize > 0) && (offset < 16 /*RFID_NUM_TAGWRDAT_REGS_PER_BANK*/))
                {
                    // Set up the register and then write it to the MAC
                    UInt32 registerValue = (uint)(WriteBuf[BufOffset + pcnt] | ((WriteOffset + pcnt) << 16));

                    MacWriteRegister((MACREGISTER)(registerAddress), registerValue);

                    pcnt++;
                    registerAddress++;
                    offset++;
                    WriteSize--;
                }
            }
        }
        } //  Start18K6CRead

        bool CUST_18K6CTagRead(CSLibrary.Constants.MemoryBank bank, int offset, int count, UInt16[] data, UInt32 password, /*UInt32 retry, */ CSLibrary.Constants.SelectFlags flags)
        {
            const int MAX_RD_CNT = 0x20;

            int rdCycle = count / MAX_RD_CNT;
            int rdReminder = count % MAX_RD_CNT;
            int index = 0, i;

            //if (retry > 7)
            //    retry = 7;

            if (rdCycle > 0)
            {
                return(false);       // too many data
            }

            /*
             * for (index = 0; index < rdCycle; index++)
             * {
             *  for (i = 0; i < retry; i++)
             *      if (Start18K6CRead(bank, (uint)(offset + index * MAX_RD_CNT), MAX_RD_CNT, tagreadbuf, password, 1, flags) == true)
             *      {
             *          if (m_TagAccessStatus == 2)
             *          {
             *              Array.Copy(tagreadbuf, 0, data, index * MAX_RD_CNT, MAX_RD_CNT);
             *              break;
             *          }
             *      }
             *  if (i == retry)
             *      return false;
             * }
             */

            if (rdReminder > 0)
            {
                Start18K6CRead((uint)bank, (uint)(offset + index * MAX_RD_CNT), (uint)rdReminder, data, password, 1, flags);

                /*
                 *  if (Start18K6CRead(bank, (uint)(offset + index * MAX_RD_CNT), (uint)rdReminder, tagreadbuf, password, 1, flags) == true)
                 * {
                 *  if (m_TagAccessStatus == 2)
                 *  {
                 *      Array.Copy(tagreadbuf, 0, data, index * MAX_RD_CNT, rdReminder);
                 *      break;
                 *  }
                 * }*/
            }
            return(true);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bank"></param>
        /// <param name="offset"></param>
        /// <param name="count"></param>
        /// <param name="data"></param>
        /// <param name="password"></param>
        /// <param name="retry"></param>
        /// <param name="flags"></param>
        /// <returns></returns>
        private CSLibrary.Constants.Result CUST_18K6CTagWrite(
            CSLibrary.Constants.MemoryBank bank,
            UInt32 offset,
            UInt32 count,
            UInt16[] data,
            UInt32 password,
            CSLibrary.Constants.SelectFlags flags
            )
        {
            if (count > MAX_WR_CNT)
            {
                return(CSLibrary.Constants.Result.DEVICE_NOT_SUPPORT);       // too many data
            }
            MacWriteRegister(MACREGISTER.HST_TAGACC_ACCPWD, password);
            Start18K6CRequest(1, flags);
            MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG /*0xA01*/, (31 << 1) | 0x01);  // Enable write verify and set retry count
                                                                                            //MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG  /*0xA01*/, 0x1ff); // Enable write verify and set retry count
            Setup18K6CWriteRegisters(bank, offset, count, data, 0);
            _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.WRITE), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE, (UInt32)CurrentOperation);

            return(CSLibrary.Constants.Result.OK);
        }
Beispiel #5
0
        public CONFIG()
        {
            int port = 16;

            RFID_TagPopulation = 30;
            RFID_TagDelayTime  = 0;

            RFID_AntennaEnable = new bool[port];
            RFID_Antenna_Power = new uint[port];
            RFID_Antenna_Dwell = new uint[port];
            for (uint cnt = 0; cnt < port; cnt++)
            {
                RFID_Antenna_Power[cnt] = 300;

                if (cnt == 0)
                {
                    RFID_AntennaEnable[0] = true;
                    if (port == 1)
                    {
                        RFID_Antenna_Dwell[0] = 0;
                    }
                    else
                    {
                        RFID_Antenna_Dwell[0] = 2000;
                    }
                }
                else
                {
                    RFID_AntennaEnable[cnt] = false;
                    RFID_Antenna_Dwell[cnt] = 2000;
                }
            }

            RFID_OperationMode = CSLibrary.Constants.RadioOperationMode.CONTINUOUS;
            RFID_TagGroup      = new CSLibrary.Structures.TagGroup(CSLibrary.Constants.Selected.ALL, CSLibrary.Constants.Session.S0, CSLibrary.Constants.SessionTarget.A);
            RFID_Algorithm     = CSLibrary.Constants.SingulationAlgorithm.DYNAMICQ;
            RFID_Profile       = 1;

            RFID_DynamicQParms                     = new CSLibrary.Structures.DynamicQParms();
            RFID_DynamicQParms.minQValue           = 0;
            RFID_DynamicQParms.startQValue         = 6;
            RFID_DynamicQParms.maxQValue           = 15;
            RFID_DynamicQParms.toggleTarget        = 1;
            RFID_DynamicQParms.thresholdMultiplier = 4;
            RFID_DynamicQParms.retryCount          = 0;

            RFID_FixedQParms                   = new CSLibrary.Structures.FixedQParms();
            RFID_FixedQParms.qValue            = 6;
            RFID_FixedQParms.retryCount        = 0;
            RFID_FixedQParms.toggleTarget      = 1;
            RFID_FixedQParms.repeatUntilNoTags = 0;

            RFID_MBI_MultiBank1Enable = false;
            RFID_MBI_MultiBank2Enable = false;
            RFID_MBI_MultiBank1       = CSLibrary.Constants.MemoryBank.TID;
            RFID_MBI_MultiBank1Offset = 0;
            RFID_MBI_MultiBank1Count  = 2;
            RFID_MBI_MultiBank2       = CSLibrary.Constants.MemoryBank.USER;
            RFID_MBI_MultiBank2Offset = 0;
            RFID_MBI_MultiBank2Count  = 2;

            RFID_InventoryAlertSound = true;
            RFID_QOverride           = false;
            RFID_DBm = true;

            RFID_SavetoFile    = false;
            RFID_SavetoCloud   = true;
            RFID_CloudProtocol = 0;
            RFID_IPAddress     = "";

            RFID_Vibration       = false;
            RFID_VibrationTag    = false;  // false = New, true = All
            RFID_VibrationWindow = 2;      // 2 seconds
            RFID_VibrationTime   = 300;    // 500 ms

            RFID_BatteryPollingTime = 300; // 300s


            for (int cnt = 0; cnt < RFID_Shortcut.Length; cnt++)
            {
                MAINMENUSHORTCUT item = new MAINMENUSHORTCUT();

                switch (cnt)
                {
                case 0:
                    item.Function    = MAINMENUSHORTCUT.FUNCTION.INVENTORY;
                    item.DurationMin = 0;
                    item.DurationMax = 500;
                    break;

                case 1:
                    item.Function    = MAINMENUSHORTCUT.FUNCTION.BARCODE;
                    item.DurationMin = 500;
                    item.DurationMax = 10000;
                    break;
                }

                RFID_Shortcut[cnt] = item;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="bank"></param>
        /// <param name="offset"></param>
        /// <param name="count"></param>
        /// <param name="data"></param>
        /// <param name="password"></param>
        /// <param name="retry"></param>
        /// <param name="flags"></param>
        /// <returns></returns>
        private CSLibrary.Constants.Result CUST_18K6CTagWrite(
            CSLibrary.Constants.MemoryBank bank,
            UInt32 offset,
            UInt32 count,
            UInt16[] data,
            UInt32 password,
            //UInt32 retry,
            //UInt32 writeretry,
            CSLibrary.Constants.SelectFlags flags
            )
        {
            int  index;
            uint wrCycle    = (uint)(count / MAX_WR_CNT);
            uint wrReminder = (uint)(count % MAX_WR_CNT);

            CSLibrary.Constants.Result status;
            UInt32 i;

            if (wrCycle > 0)
            {
                return(CSLibrary.Constants.Result.DEVICE_NOT_SUPPORT);
            }

            //MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG, 0x1ff);
            MacWriteRegister(MACREGISTER.HST_TAGACC_ACCPWD, password);
            Start18K6CRequest(1, flags);

            //ReadReaderRegister((UInt16)MACREGISTER.HST_TAGACC_DESC_CFG);
            MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG /*0xA01*/, (31 << 1) | 0x01);  // Enable write verify and set retry count
            //MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG  /*0xA01*/, 0x1ff); // Enable write verify and set retry count

            /*			for (index = 0; index < wrCycle; index++)
             *                                  {
             *                                          Setup18K6CWriteRegisters(bank, (uint)(offset + index * MAX_WR_CNT), MAX_WR_CNT, data, (uint)(index * MAX_WR_CNT));
             *
             *                                          for (i = retry; i > 0; i--)
             *                                          {
             *                                                  // Issue the write command to the MAC
             *                                                  status = COMM_HostCommand(HST_CMD.WRITE);
             *
             *                                                  if (status != Result.OK)
             *                                                          return status;
             *
             *                                                  //MacClearError();
             *
             *                                                  if (m_TagAccessStatus == 2)
             *                                                          break;
             *
             *                                                  System.Threading.Thread.Sleep(100);
             *                                          }
             *
             *                                          if (i == 0)
             *                                                  return Result.MAX_RETRY_EXIT;
             *                                  }*/
            index = 0;
            if (wrReminder > 0)
            {
                Setup18K6CWriteRegisters(bank, (uint)(offset + index * MAX_WR_CNT), wrReminder, data, (uint)(index * MAX_WR_CNT));

                //for (i = retry; i > 0; i--)
                {
                    // Issue the write command to the MAC
                    //status = COMM_HostCommand(HST_CMD.WRITE);
                    _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.WRITE), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE, (UInt32)CurrentOperation);

                    //if (status != Result.OK)
                    //return status;

                    //MacClearError();

                    //if (m_TagAccessStatus == 2)
                    //break;

                    //System.Threading.Thread.Sleep(100);
                }

                //if (i == 0)
                //return Result.MAX_RETRY_EXIT;
            }

            return(CSLibrary.Constants.Result.OK);
        }