韦根RFID阅读器VS USB RFID阅读器Raspberry PI [英] Wiegand RFID reader VS USB RFID reader Raspberry PI

查看:123
本文介绍了韦根RFID阅读器VS USB RFID阅读器Raspberry PI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个运行python代码的Raspberry Pis检索RFID标签的序列号.一个具有RFID读取器,该读取器具有连接到GPIO引脚的Wiegand接口,另一个具有RFID读取器,其行为类似于通过USB连接的键盘.但是,当扫描相同的RFID标签时,两个阅读器会得到不同的编号.

I have two Raspberry Pis running python code to retrieve the serial number of an RFID tag. One has an RFID reader with a Wiegand interface hooked to GPIO pins and other has an RFID reader that behaves like a keyboard connected over USB. However, I get different numbers from the two reader when scanning the same RFID tag.

例如,对于一个标签,我从带有Wiegand阅读器的Raspberry Pi中获得了57924897,从带有USB键盘阅读器的Raspberry Pi中获得了0004591983.

For example, for one tag, I get 57924897 from the Raspberry Pi with the Wiegand reader and 0004591983 from the Raspberry Pi with the USB keyboard reader.

有人可以解释其中的区别吗?两位读者阅读的相同吗?还是他们只是读取一些不同的参数?

Can sombody explain the difference? Are both readers reading the same? Or are they just reading some different parameter?

推荐答案

看这两个值,看来您没有正确地从Wiegand界面读取和转换该值.

Looking at those two values, it seems that you do not properly read and convert the value from the Wiegand interface.

USB键盘读取器以10位十进制形式读取序列号.韦根读取器通常将序列号中继为26位值(1个奇偶校验位+ 8位站点代码+ 16位标签ID + 1个奇偶校验位).

The USB keyboard reader reads the serial number in 10 digit decimal form. A Wiegand reader typically trunkaes the serial number into a 26 bit value (1 parity bit + 8 bit site code + 16 bit tag ID + 1 parity bit).

因此,让我们看一下您获得的两个值:

So let's look at the two values that you get:

+--------------+------------+-------------+-----------------------------------------+
| READER       | DECIMAL    | HEXADECIMAL | BINARY                                  |
+--------------+------------+-------------+-----------------------------------------+
| USB keyboard | 0004591983 | 0046116F    | 0000 0000 0100 0110 0001 0001 0110 1111 |
| Wiegand      |   57924897 | 373DD21     | 1 1011 1001 1110 1110 1001 0000 1       |
+--------------+------------+-------------+-----------------------------------------+

仔细查看这两个值的二进制表示形式,您会发现它们彼此相关:

When you take a close look at the binary representation of those two values, you will see that they correlate with each other:

USB keyboard: 0000 0000 0100 0110 0001 0001 0110 1111
Wiegand:              1 1011 1001 1110 1110 1001 0000 1

因此,Wiegand值似乎与从USB键盘读取器获得的取反值匹配:

So it seems as if the Wiegand value matches the inverted value obtained from the USB keyboard reader:

USB keyboard: 0000 0000 0100 0110 0001 0001 0110 1111
NOT(Wiegand):         0 0100 0110 0001 0001 0110 1111 0

因此,韦根接口的反转值(逻辑非)与USB读取器读取的值匹配.

So the inverted value (logical NOT) from the Wiegand interface matches the value read by the USB reader.

接下来,让我们看一下两个奇偶校验位. Wiegand界面上的数据通常看起来像:

Next, let's look at the two parity bits. The data over the Wiegand interface typically looks like:

b0  b1  b2  b3  b4  b5  b6  b7  b8  b9  b10 b11 b12 b13 b14 b15 b16 b17 b18 b19 b20 b21 b22 b23 b24 b25
PE  D23 D22 D21 D20 D19 D18 D17 D16 D15 D14 D13 D12 D11 D10 D9  D8  D7  D6  D5  D4  D3  D2  D1  D0  PO

第一行是通过韦根导线到达时被编号的位.第二行是与接收器需要解释的位相同的位,其中PE(b0)是D23..D12(b1..b12)上的偶数奇偶校验位,PO(b25)是D11..D0(b13..b24)上的奇数奇偶校验位和D23..D0是表示无符号整数的数据位.

The first line being the bits numbered as they arrive over the Wiegand wires. The second line being the same bits as they need to be interpreted by the receiver, where PE (b0) is an even parity bit over D23..D12 (b1..b12), PO (b25) is an odd parity bit over D11..D0 (b13..b24), and D23..D0 are the data bits representing an unsigned integer number.

因此,查看您的电话号码,您会收到:

So looking at your number, you would have received:

PE  D23 D22 D21 D20 D19 D18 D17 D16 D15 D14 D13 D12 D11 D10 D9  D8  D7  D6  D5  D4  D3  D2  D1  D0  PO
0   0   1   0   0   0   1   1   0   0   0   0   1   0   0   0   1   0   1   1   0   1   1   1   1   0

如果检查奇偶校验位PEPO,则会得到:

If we check the parity bits PE and PO, we get:

PE D23........D12
0  0100 0110 0001

包含4个(1),因此可以满足奇偶校验.

contains 4 ones (1), hence even parity is met.

D21.........D0 PO
0001 0110 1111 0

包含7个(1),因此满足奇数奇偶校验.

contains 7 ones (1), hence odd parity is met.

因此,综上所述,从Wiegand界面读取的代码无法正确处理Wiegand数据格式.首先,它不对奇偶校验位进行修整,其次,它读取极性错误的位(零是一,一是零).

So, to summarize the above, your code reading from the Wiegand interface does not properly handle the Wiegand data format. First, it does not trim the parity bits and second, it reads the bits with wrong polarity (zeros are ones and ones are zeros).

为了从Wiegand读取器中获取正确的编号,您要么必须修复要从Wiegand界面读取的代码(以固定极性,否则要跳过数据值的第一位和最后一位,奇偶校验位).或者,您可以获取当前获得的值,将其取反,然后去掉低位和高位.在C语言中,看起来像这样:

In order to get the correct number from the Wiegand reader, you either have to fix you code for reading from the Wiegand interface (to fix polarity, to skip the first and the last bit from the data value, and to possibly check the parity bits). Or you can take the value that you currently get, invert that value, and strip the lower and upper bits. In C, that would look something like this:

int unsigned currentWiegandValue = ...;
int unsigned newWiegandValue = ((~currentWiegandValue) >> 1) & 0x0FFFFFF;

这篇关于韦根RFID阅读器VS USB RFID阅读器Raspberry PI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆