我们如何关闭智能卡读卡器蜂鸣器?

时间:2016-07-18 09:24:12

标签: nfc smartcard-reader

我是智能卡读卡器的新手。我买了一台ACR1252u,卡在禁用蜂鸣器和导致。我试过这段代码: https://the--semicolon.blogspot.it/p/this-is-simple-way-to-restart-your.html?showComment=1468833507200

  public void turnOffBuzzer()
        {
                retCode = Card.SCardConnect(hContext, readername, Card.SCARD_SHARE_SHARED, Card.SCARD_PROTOCOL_T0 | Card.SCARD_PROTOCOL_T1, ref hCard, ref Protocol);
                byte data=  0x00 ;
                byte[] control = new byte[] { 0xE0, 0x00, 0x00, 0x28, 0x01 };
                uint value = BitConverter.ToUInt32(control, 0);
                byte receivedBytes = new byte();
                int pcbBytesReturned = 0;
                long status = Card.SCardControl(hCard, value, ref data, 1,ref receivedBytes , 1, ref  pcbBytesReturned);
                MessageBox.Show(status.ToString());
        }

但状态给我1而不是0

2 个答案:

答案 0 :(得分:0)

嗯,我发现它是如何工作的!

关闭蜂鸣器:

 retCode = Card.SCardConnect(hContext, readername, Card.SCARD_SHARE_SHARED,
                  Card.SCARD_PROTOCOL_T0 | Card.SCARD_PROTOCOL_T1, ref hCard, ref Protocol);

            Byte[] setBuzzerLoud = new Byte[6];
            setBuzzerLoud[0] = 0xE0;
            setBuzzerLoud[1] = 0x00;
            setBuzzerLoud[2] = 0x00;
            setBuzzerLoud[3] = 0x21;
            setBuzzerLoud[4] = 0x01;
            setBuzzerLoud[5] = 0x77;
            uint pcBytesReturned = 0;
            Byte[] RecieveBuff = new Byte[64];
            uint controlcode = 3225264;
            int status = Card.SCardControl(hCard, controlcode, ref setBuzzerLoud[0], 6, ref RecieveBuff[0], RecieveBuff.Length, ref pcBytesReturned);

            MessageBox.Show(status.ToString());

关闭led:

  retCode = Card.SCardConnect(hContext, readername, Card.SCARD_SHARE_SHARED,
               Card.SCARD_PROTOCOL_T0 | Card.SCARD_PROTOCOL_T1, ref hCard, ref Protocol);

            Byte[] setLEDOFF = new Byte[6];
            setLEDOFF[0] = 0xE0;
            setLEDOFF[1] = 0x00;
            setLEDOFF[2] = 0x00;
            setLEDOFF[3] = 0x21;
            setLEDOFF[4] = 0x01;
            setLEDOFF[5] = 0x79;
            uint pcBytesReturned = 0;
            Byte[] RecieveBuff = new Byte[64];
            uint controlcode = 3225264;
            int status = Card.SCardControl(hCard, controlcode, ref setLEDOFF[0], 6, ref RecieveBuff[0], RecieveBuff.Length, ref pcBytesReturned);

            MessageBox.Show(status.ToString());

关闭RF:

 retCode = Card.SCardConnect(hContext, readername, Card.SCARD_SHARE_SHARED,
             Card.SCARD_PROTOCOL_T0 | Card.SCARD_PROTOCOL_T1, ref hCard, ref Protocol);

            Byte[] setRFOff = new Byte[6];
            setRFOff[0] = 0xE0;
            setRFOff[1] = 0x00;
            setRFOff[2] = 0x00;
            setRFOff[3] = 0x23;
            setRFOff[4] = 0x01;
            setRFOff[5] = 0x80;
            uint pcBytesReturned = 0;
            Byte[] RecieveBuff = new Byte[64];
            uint controlcode = 3225264;
            int status = Card.SCardControl(hCard, controlcode, ref setRFOff[0], 6, ref RecieveBuff[0], RecieveBuff.Length, ref pcBytesReturned);

            MessageBox.Show(status.ToString());

有趣的是控制代码,我调试了链接中提到的c ++代码,为这个智能卡读卡器找到它:

DWORD controlcode = SCARD_CTL_CODE(3500);

转义码写于第41/77页。

SCARD_CTL_CODE(3500)

唯一的问题是如何在没有读卡器上的rfid的情况下关闭设置。我还发现了一篇文章,讨论如何更改usb参数中的一些注册表项,我也会尝试它。任何能帮助我的人我都会很高兴。

完成! 享受

答案 1 :(得分:0)

如果要在阅读器附近没有任何rfid标签的情况下发送一些ScardControl命令,则可以尝试在Card.SCardConnect函数中使用“ Card.SCARD_SHARE_DIRECT”。