memset(pre, 0x00, sizeof(pre));
// format start bit
+ pre[79] = 1;
// Get 26 wiegand from FacilityCode, CardNumber
- uint8_t wiegand[26];
+ uint8_t wiegand[24];
+ memset(wiegand, 0x00, sizeof(wiegand));
num_to_bytebits(fc, 8, wiegand);
num_to_bytebits(cn, 16, wiegand+8);
// add wiegand parity bits (dest, source, len)
- wiegand_add_parity(pre+71, wiegand, 26);
-
+ wiegand_add_parity(pre+80, wiegand, 24);
+
// add paritybits (bitsource, dest, sourcelen, paritylen, parityType (odd, even,)
addParity(pre+8, pyramidBits+8, 112, 8, 1);
uint32_t crc = CRC8Maxim(csBuff, 13);
num_to_bytebits(crc, 8, pyramidBits+120);
+
return 1;
}
-/*
-9 - 00001001
-33278 - 1000000111111110
- 10000100110000001
-000101010101010101010101082602
-*/
int CmdPyramidRead(const char *Cmd) {
// read lf silently
CmdLFRead("s");
uint32_t facilitycode=0, cardnumber=0, fc = 0, cn = 0;
- uint8_t bits[128];
- uint8_t *bs = bits;
- memset(bs, 0x00, sizeof(bits));
+ uint8_t bs[129];
+ memset(bs, 0x00, sizeof(bs));
//Pyramid - compat mode, FSK2a, data rate 50, 4 data blocks
uint32_t blocks[5] = {T55x7_MODULATION_FSK2a | T55x7_BITRATE_RF_50 | 4<<T55x7_MAXBLOCK_SHIFT, 0, 0, 0, 0};
}
char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t breaks) {
+
// make sure we don't go beyond our char array memory
- int max_len;
+ size_t in_index = 0, out_index = 0;
+ int max_len;
if (breaks==0)
max_len = ( len > MAX_BIN_BREAK_LENGTH ) ? MAX_BIN_BREAK_LENGTH : len;
else
memset(buf, 0x00, sizeof(buf));
char *tmp = buf;
- size_t in_index = 0;
// loop through the out_index to make sure we don't go too far
- for (size_t out_index=0; out_index < max_len-2; out_index++) {
+ for (out_index=0; out_index < max_len-2; out_index++) {
// set character
sprintf(tmp++, "%u", (unsigned int) data[in_index]);
// check if a line break is needed and we have room to print it in our array
// increment and print line break
out_index++;
sprintf(tmp++, "%s","\n");
- }
+ }
in_index++;
}
-
+ // last char.
+ sprintf(tmp++, "%u", (unsigned int) data[in_index]);
return buf;
}