Пример #1
0
        public void getSlaveExCardConfig(IntPtr sdkContext, UInt32 slaveID)
        {
            BS2CardConfig cardConfig;

            Console.WriteLine("Getting card config. reader[{0}]", slaveID);
            BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetCardConfig(sdkContext, slaveID, out cardConfig);

            if (result != BS2ErrorCode.BS_SDK_SUCCESS)
            {
                Console.WriteLine("Get card config. reader[{0}]-error[{1}].", slaveID, result);
                return;
            }
            Console.WriteLine("Get card config. reader[{0}]", slaveID);
            print(cardConfig);
        }
Пример #2
0
        public void getCardConfig(IntPtr sdkContext, UInt32 deviceID, bool isMasterDevice)
        {
            BS2CardConfig cardConfig;

            Console.WriteLine("Trying to get card configuration.");
            BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetCardConfig(sdkContext, deviceID, out cardConfig);

            if (result != BS2ErrorCode.BS_SDK_SUCCESS)
            {
                Console.WriteLine("Got error({0}).", result);
            }
            else
            {
                print(sdkContext, cardConfig);
            }
        }
Пример #3
0
        void insertCardIDWithKeypad(IntPtr sdkContext, UInt32 slaveID, byte onoff)
        {
            BS2CardConfig cardConfig;
            BS2ErrorCode  result = (BS2ErrorCode)API.BS2_GetCardConfig(sdkContext, slaveID, out cardConfig);

            if (result != BS2ErrorCode.BS_SDK_SUCCESS)
            {
                Console.WriteLine("Get card config. reader[{0}]-error[{1}].", slaveID, result);
                return;
            }

            cardConfig.cipher = onoff;

            result = (BS2ErrorCode)API.BS2_SetCardConfig(sdkContext, slaveID, ref cardConfig);
            if (result != BS2ErrorCode.BS_SDK_SUCCESS)
            {
                Console.WriteLine("Got error({0}).", result);
                return;
            }

            print(cardConfig);
        }
Пример #4
0
        public void setWiegandConfig(IntPtr sdkContext, UInt32 deviceID, bool isMasterDevice)
        {
            Console.WriteLine("Please run menu #5 \"Set predefined wiegand formats\" before running this menu.");
            BS2WiegandConfig wiegandConfig;

            BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetWiegandConfig(sdkContext, deviceID, out wiegandConfig);

            if (result != BS2ErrorCode.BS_SDK_SUCCESS)
            {
                Console.WriteLine("Got error({0}).", result);
                return;
            }
            Console.WriteLine("Select the wiegand mode for the device[0({0}:Default), 1({1}), 2({2} Supported only for BS2, BSA2, FS2)]", BS2WiegandModeEnum.BS2_WIEGAND_IN_ONLY,
                              BS2WiegandModeEnum.BS2_WIEGAND_OUT_ONLY,
                              BS2WiegandModeEnum.BS2_WIEGAND_IN_OUT);
            Console.Write("  >>>> ");
            wiegandConfig.mode = (byte)Util.GetInput();

            if (wiegandConfig.mode == (byte)BS2WiegandModeEnum.BS2_WIEGAND_OUT_ONLY || wiegandConfig.mode == (byte)BS2WiegandModeEnum.BS2_WIEGAND_IN_OUT)
            {
                Console.WriteLine("   Do you want the device to work as wiegand bypass?[Y/N]");
                Console.Write("     >>>> ");
                if (Util.IsYes())
                {
                    wiegandConfig.useWiegandBypass = 1;
                }
                else
                {
                    Console.WriteLine("   Do you want the device to use fail code?[Y/N]");
                    Console.Write("     >>>> ");
                    if (Util.IsYes())
                    {
                        wiegandConfig.useFailCode = 1;
                        Console.WriteLine("   Select the fail code type[0(0x00), 1(0xFF:Default)]");
                        byte failCodeType = (byte)Util.GetInput(1);
                        if (failCodeType == 0)
                        {
                            wiegandConfig.failCode = 0x00;
                        }
                        else
                        {
                            wiegandConfig.failCode = 0xFF;
                        }
                    }
                }
            }

            if (wiegandConfig.mode == (byte)BS2WiegandModeEnum.BS2_WIEGAND_IN_ONLY || wiegandConfig.mode == (byte)BS2WiegandModeEnum.BS2_WIEGAND_IN_OUT)
            {
                Console.WriteLine("   Please set the Wiegand Card mask for the WIEGAND INPUT. The device will accept WIEGNAD SIGNALS that matches the configured formats.");
                wiegandConfig.wiegandInputMask = InputWiegandFormatType();
            }

            Console.WriteLine("   Do you want the device to proccess CSN cards with wiegand formats?[Y/N]");
            Console.Write("     >>>> ");
            if (Util.IsYes())
            {
                BS2CardConfig cardConfig;
                result = (BS2ErrorCode)API.BS2_GetCardConfig(sdkContext, deviceID, out cardConfig);
                if (result != BS2ErrorCode.BS_SDK_SUCCESS)
                {
                    Console.WriteLine("Got error({0}).", result);
                    return;
                }

                cardConfig.useWiegandFormat = 1;

                result = (BS2ErrorCode)API.BS2_SetCardConfig(sdkContext, deviceID, ref cardConfig);
                if (result != BS2ErrorCode.BS_SDK_SUCCESS)
                {
                    Console.WriteLine("Got error({0}).", result);
                    return;
                }

                Console.WriteLine("   Please set the CSN Wiegand Card index for the device.");
                Console.WriteLine("   Select a format type. [{0}: {1}, {2}: {3}, {4}: {5}, {6}: {7}, {8}: {9}]",
                                  (ushort)BS2WiegandFormatEnum.BS2_WIEGAND_H10301_26, BS2WiegandFormatEnum.BS2_WIEGAND_H10301_26,
                                  (ushort)BS2WiegandFormatEnum.BS2_WIEGAND_H10302_37, BS2WiegandFormatEnum.BS2_WIEGAND_H10302_37,
                                  (ushort)BS2WiegandFormatEnum.BS2_WIEGAND_H10304_37, BS2WiegandFormatEnum.BS2_WIEGAND_H10304_37,
                                  (ushort)BS2WiegandFormatEnum.BS2_WIEGAND_C1000_35, BS2WiegandFormatEnum.BS2_WIEGAND_C1000_35,
                                  (ushort)BS2WiegandFormatEnum.BS2_WIEGAND_C1000_48, BS2WiegandFormatEnum.BS2_WIEGAND_C1000_48);
                wiegandConfig.wiegandCSNIndex = (byte)(Util.GetInput() + 1);
            }
            else
            {
                BS2CardConfig cardConfig;
                result = (BS2ErrorCode)API.BS2_GetCardConfig(sdkContext, deviceID, out cardConfig);
                if (result != BS2ErrorCode.BS_SDK_SUCCESS)
                {
                    Console.WriteLine("Got error({0}).", result);
                    return;
                }

                cardConfig.useWiegandFormat = 0;

                result = (BS2ErrorCode)API.BS2_SetCardConfig(sdkContext, deviceID, ref cardConfig);
                if (result != BS2ErrorCode.BS_SDK_SUCCESS)
                {
                    Console.WriteLine("Got error({0}).", result);
                    return;
                }
            }

            Console.WriteLine("   Please set the Wiegand Card mask for the DEVICE. The device will accept CARDS that matches the configured formats.");
            wiegandConfig.wiegandCardMask = InputWiegandFormatType();

            Console.WriteLine("   Enter the pulse width(µs) for the wiegand signal.(20(Min) ~ 100(Max) 40[Default]");
            Console.Write("     >>>> ");
            wiegandConfig.outPulseWidth = Util.GetInput(40);

            Console.WriteLine("   Enter the pulse interval(µs) for the wiegand signal.(200(Min) ~ 20000(Max) 10000[Default]");
            Console.Write("     >>>> ");
            wiegandConfig.outPulseInterval = Util.GetInput(10000);

            result = (BS2ErrorCode)API.BS2_SetWiegandConfig(sdkContext, deviceID, ref wiegandConfig);
            if (result != BS2ErrorCode.BS_SDK_SUCCESS)
            {
                Console.WriteLine("Got error({0}).", result);
                return;
            }
        }