Skip to main content
Arduino

Return to Question

added 16 characters in body
Source Link

An implementation function from the nice little Wiegand library YetAnotherArduinoWiegandLibrary prints a hexadecimal representation of a facility # & card # (8-bit facility #, 16-bit card #) — 24 bits of a 26-bit stream that comes across the wire.

Example encoded 24-bit number: 7111097 (decimal). Hex equivalent: 6C81B9. The 6C portion is the facility # (decimal: 108). 81B9 is card # (decimal 33209).

This function from the library's example usage serial prints the hexadecimal format of the number:

void receivedData(uint8_t* data, uint8_t bits, const char* message) {
 Serial.print(message);
 Serial.print(bits);
 Serial.print("bits / ");
 //Print value in HEX
 uint8_t bytes = (bits+7)/8;
 for (int i=0; i<bytes; i++) {
 Serial.print(data[i] >> 4, 16); //1st, 3rd, 5th hex digit
 Serial.print(data[i] & 0xF, 16); //2nd, 4th, 6th hex digit
 }
 Serial.println();
}

What I've tried to do unsuccessfully so far is to loop over the bits to also serial print the two decimal formatted numbers (facility:card) in the final output form: 108:33209

An implementation function from the nice little Wiegand library YetAnotherArduinoWiegandLibrary prints a hexadecimal representation of a facility # & card # (8-bit facility #, 16-bit card #) — 24 bits of a 26-bit stream that comes across the wire.

Example encoded 24-bit number: 7111097 (decimal). Hex equivalent: 6C81B9. The 6C portion is the facility # (decimal: 108). 81B9 is card # (decimal 33209).

This function from the library's example usage serial prints the hexadecimal format of the number:

void receivedData(uint8_t* data, uint8_t bits, const char* message) {
 Serial.print(message);
 Serial.print(bits);
 Serial.print("bits / ");
 //Print value in HEX
 uint8_t bytes = (bits+7)/8;
 for (int i=0; i<bytes; i++) {
 Serial.print(data[i] >> 4, 16); //1st, 3rd, 5th hex digit
 Serial.print(data[i] & 0xF, 16); //2nd, 4th, 6th hex digit
 }
 Serial.println();
}

What I've tried to do unsuccessfully so far is to loop over the bits to also serial print the two decimal formatted numbers in the final output form: 108:33209

An implementation function from the nice little Wiegand library YetAnotherArduinoWiegandLibrary prints a hexadecimal representation of a facility # & card # (8-bit facility #, 16-bit card #) — 24 bits of a 26-bit stream that comes across the wire.

Example encoded 24-bit number: 7111097 (decimal). Hex equivalent: 6C81B9. The 6C portion is the facility # (decimal: 108). 81B9 is card # (decimal 33209).

This function from the library's example usage serial prints the hexadecimal format of the number:

void receivedData(uint8_t* data, uint8_t bits, const char* message) {
 Serial.print(message);
 Serial.print(bits);
 Serial.print("bits / ");
 //Print value in HEX
 uint8_t bytes = (bits+7)/8;
 for (int i=0; i<bytes; i++) {
 Serial.print(data[i] >> 4, 16); //1st, 3rd, 5th hex digit
 Serial.print(data[i] & 0xF, 16); //2nd, 4th, 6th hex digit
 }
 Serial.println();
}

What I've tried to do unsuccessfully so far is to loop over the bits to also serial print the two decimal formatted numbers (facility:card) in the final output form: 108:33209

edited tags
Link
Source Link

Print 2 numbers stored in 24-bits in decimal format

An implementation function from the nice little Wiegand library YetAnotherArduinoWiegandLibrary prints a hexadecimal representation of a facility # & card # (8-bit facility #, 16-bit card #) — 24 bits of a 26-bit stream that comes across the wire.

Example encoded 24-bit number: 7111097 (decimal). Hex equivalent: 6C81B9. The 6C portion is the facility # (decimal: 108). 81B9 is card # (decimal 33209).

This function from the library's example usage serial prints the hexadecimal format of the number:

void receivedData(uint8_t* data, uint8_t bits, const char* message) {
 Serial.print(message);
 Serial.print(bits);
 Serial.print("bits / ");
 //Print value in HEX
 uint8_t bytes = (bits+7)/8;
 for (int i=0; i<bytes; i++) {
 Serial.print(data[i] >> 4, 16); //1st, 3rd, 5th hex digit
 Serial.print(data[i] & 0xF, 16); //2nd, 4th, 6th hex digit
 }
 Serial.println();
}

What I've tried to do unsuccessfully so far is to loop over the bits to also serial print the two decimal formatted numbers in the final output form: 108:33209

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /