monkeyboard / Wiegand-Protocol-Library-for-Arduino

Wiegand 26 and Wiegand 34 Protocol Library for Arduino
323 stars 131 forks source link

Missing one bit in serial number #24

Closed Thiagodcfarias closed 6 years ago

Thiagodcfarias commented 6 years ago

Hi, i can get the serial number of my RFID using the example in this library. However, i´m missing the first bit of serial number and i don´t know how to fix it.

My RFID uses 34 bits, 32 for serial number and 2 for parity, but when i code "Serial.print(wg.getCode(),BIN);" i recieve just 31 bits :(

jpliew commented 6 years ago

@Thiagodcfarias could you run the example code and paste the full result here please?

Thiagodcfarias commented 6 years ago

Hi, the code:

include

WIEGAND wg;

void setup() { Serial.begin(9600);
wg.begin(); }

void loop() { if(wg.available()) { Serial.print("Wiegand HEX = "); Serial.print(wg.getCode(),HEX); Serial.print(", DECIMAL = "); Serial.print(wg.getCode(),BIN); Serial.print(", BINARIO = "); Serial.print(wg.getCode()); Serial.print(", Type W"); Serial.println(wg.getWiegandType());
} }

the result: Wiegand HEX = 51D85DFA, DECIMAL = 1010001110110000101110111111010, BINARIO = 1373134330, Type W32

Thiagodcfarias commented 6 years ago

So, if the RFID´s serial number starts with 0, the translation to 10´base is equal to the number of my RFID card, in the other hand, the numbers are different when starts with 1. Because of that, i think that we just can see the numbers through a window

jpliew commented 6 years ago

@Thiagodcfarias there is nothing wrong with your result. The HEX, BIN and DECIMAL results are identical.

Serial.print() binary will not print any leading 0.