monkeyboard / Wiegand-Protocol-Library-for-Arduino

Wiegand 26 and Wiegand 34 Protocol Library for Arduino
332 stars 128 forks source link

Reversed Byte Order #37

Closed giotec closed 5 years ago

giotec commented 5 years ago

The actual card value is 12 34 56 78, however the library spits out 78 56 34 12. Is there a way to reverse the byte order within the library?

jpliew commented 5 years ago

@giotec the library does not do any translation, it just print out exactly what was captured on D1 and D0. There some reader that will reverse the data of the card. You might want to check the setting of the reader if it is BIG or LITTLE ENDIAN.

If you can't configure your reader, you can check out how to convert between the endians here https://stackoverflow.com/questions/2182002/convert-big-endian-to-little-endian-in-c-without-using-provided-func

Hope this helps.

giotec commented 5 years ago

Cheers,

The second answer in that link worked perfectly.

added #include and put __bswap_32 (wg.getCode())