fix: high and low variable should now contain raw hex.

This commit is contained in:
iceman1001 2017-10-29 11:20:10 +01:00
commit bc131dd105
3 changed files with 96 additions and 91 deletions

View file

@ -614,7 +614,8 @@ void UsbPacketReceived(uint8_t *packet, int len) {
CopyIOtoT55x7(c->arg[0], c->arg[1]);
break;
case CMD_EM410X_DEMOD: {
uint32_t high, low;
uint32_t high;
uint64_t low;
CmdEM410xdemod(c->arg[0], &high, &low, 1);
break;
}

View file

@ -89,7 +89,7 @@ void CmdASKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream);
void CmdHIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol);
void CmdAWIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol); // Realtime demodulation mode for AWID26
void CmdEM410xdemod(int findone, uint32_t *high, uint32_t *low, int ledcontrol);
void CmdEM410xdemod(int findone, uint32_t *high, uint64_t *low, int ledcontrol);
void CmdIOdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol);
void CopyIOtoT55x7(uint32_t hi, uint32_t lo); // Clone an ioProx card to T5557/T5567
void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT); // Clone an HID card to T5557/T5567

View file

@ -634,7 +634,7 @@ void CmdHIDsimTAGEx( uint32_t hi, uint32_t lo, int ledcontrol, int numcycles) {
}
void CmdHIDsimTAG( uint32_t hi, uint32_t lo, int ledcontrol) {
void CmdHIDsimTAG( hi, lo, ledcontrol, -1);
void CmdHIDsimTAGEx( hi, lo, ledcontrol, -1);
}
// prepare a waveform pattern in the buffer based on the ID given then
@ -815,7 +815,7 @@ void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
}
// loop to get raw HID waveform then FSK demodulate the TAG ID from it
void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol) {
void CmdHIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol) {
uint8_t *dest = BigBuf_get_addr();
size_t size = 0;
uint32_t hi2 = 0, hi = 0, lo = 0;
@ -842,10 +842,10 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol) {
// go over previously decoded manchester data and decode into usable tag ID
if (hi2 != 0){ //extra large HID tags 88/192 bits
Dbprintf("TAG ID: %x%08x%08x (%d)",
(unsigned int) hi2,
(unsigned int) hi,
(unsigned int) lo,
(unsigned int) (lo>>1) & 0xFFFF
hi2,
hi,
lo,
(lo >> 1) & 0xFFFF
);
} else { //standard HID tags 44/96 bits
uint8_t bitlen = 0;
@ -857,7 +857,7 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol) {
lo2=(((hi & 31) << 12) | (lo>>20)); //get bits 21-37 to check for format len bit
uint8_t idx3 = 1;
while (lo2 > 1){ //find last bit set to 1 (format len bit)
lo2=lo2 >> 1;
lo2 >>= 1;
idx3++;
}
bitlen = idx3 + 19;
@ -890,12 +890,13 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol) {
}
}
Dbprintf("TAG ID: %x%08x (%d) - Format Len: %dbit - FC: %d - Card: %d",
(unsigned int) hi,
(unsigned int) lo,
(unsigned int) (lo>>1) & 0xFFFF,
(unsigned int) bitlen,
(unsigned int) fc,
(unsigned int) cardnum);
hi,
lo,
(lo >> 1) & 0xFFFF,
bitlen,
fc,
cardnum
);
}
if (findone){
if (ledcontrol) LED_A_OFF();
@ -914,12 +915,16 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol) {
// loop to get raw HID waveform then FSK demodulate the TAG ID from it
void CmdAWIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol) {
uint8_t *dest = BigBuf_get_addr();
size_t size;
//big enough to catch 2 sequences of largest format
size_t size = 12800; //50 * 128 * 2;
int idx = 0, dummyIdx = 0;
//clear read buffer
BigBuf_Clear_keep_EM();
// Configure to go in 125Khz listen mode
LFSetupFPGAForADC(95, true);
while(!BUTTON_PRESS() && !usb_poll_validate_length()) {
@ -929,7 +934,7 @@ void CmdAWIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol)
DoAcquisition_default(-1, true);
// FSK demodulator
size = 50*128*2; //big enough to catch 2 sequences of largest format
idx = detectAWID(dest, &size, &dummyIdx);
if (idx <= 0 || size != 96) continue;
@ -991,8 +996,8 @@ void CmdAWIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol)
}
if (findone){
if (ledcontrol) LED_A_OFF();
*high = hi;
*low = lo;
*high = rawHi;
*low = rawLo;
break;
}
// reset
@ -1004,16 +1009,16 @@ void CmdAWIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol)
if (ledcontrol) LED_A_OFF();
}
void CmdEM410xdemod(int findone, uint32_t *high, uint32_t *low, int ledcontrol) {
void CmdEM410xdemod(int findone, uint32_t *high, uint64_t *low, int ledcontrol) {
uint8_t *dest = BigBuf_get_addr();
size_t size = 0, idx = 0;
int clk = 0, invert = 0, errCnt = 0, maxErr = 20;
uint32_t hi = 0;
uint64_t lo = 0;
//clear read buffer
BigBuf_Clear_keep_EM();
// Configure to go in 125Khz listen mode
LFSetupFPGAForADC(95, true);
while(!BUTTON_PRESS() && !usb_poll_validate_length()) {
@ -1066,15 +1071,14 @@ void CmdEM410xdemod(int findone, uint32_t *high, uint32_t *low, int ledcontrol)
}
void CmdIOdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol) {
uint8_t *dest = BigBuf_get_addr();
int dummyIdx = 0;
int idx = 0;
int dummyIdx = 0, idx = 0;
uint32_t code = 0, code2 = 0;
uint8_t version = 0;
uint8_t facilitycode = 0;
uint16_t number = 0;
uint8_t crc = 0;
uint16_t calccrc = 0;
uint8_t version = 0, facilitycode = 0, crc = 0;
uint16_t number = 0, calccrc = 0;
size_t size = BigBuf_max_traceLen();
BigBuf_Clear_keep_EM();
@ -1137,8 +1141,8 @@ void CmdIOdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol) {
// if we're only looking for one tag
if (findone){
if (ledcontrol) LED_A_OFF();
*high = hi;
*low = lo;
*high = code;
*low = code2;
break;
}
code = code2 = 0;