mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-22 22:23:38 -07:00
minor fixes regaring the newly released patches from the pm3 community
plus removed old comments in cmdmain.c
This commit is contained in:
parent
a501c82b19
commit
d3499d369d
7 changed files with 256 additions and 300 deletions
|
@ -169,13 +169,11 @@ int AvgAdc(int ch) // was static - merlok
|
||||||
|
|
||||||
void MeasureAntennaTuning(void)
|
void MeasureAntennaTuning(void)
|
||||||
{
|
{
|
||||||
uint8_t *dest = (uint8_t *)BigBuf + FREE_BUFFER_OFFSET;
|
uint8_t LF_Results[256];
|
||||||
int i, adcval = 0, peak = 0, peakv = 0, peakf = 0; //ptr = 0
|
int i, adcval = 0, peak = 0, peakv = 0, peakf = 0; //ptr = 0
|
||||||
int vLf125 = 0, vLf134 = 0, vHf = 0; // in mV
|
int vLf125 = 0, vLf134 = 0, vHf = 0; // in mV
|
||||||
|
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
DbpString("Measuring antenna characteristics, please wait...");
|
|
||||||
memset(dest,0,FREE_BUFFER_SIZE);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sweeps the useful LF range of the proxmark from
|
* Sweeps the useful LF range of the proxmark from
|
||||||
|
@ -188,7 +186,7 @@ void MeasureAntennaTuning(void)
|
||||||
|
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
|
||||||
for (i=255; i>19; i--) {
|
for (i=255; i>=19; i--) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, i);
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, i);
|
||||||
SpinDelay(20);
|
SpinDelay(20);
|
||||||
|
@ -198,15 +196,17 @@ void MeasureAntennaTuning(void)
|
||||||
if (i==95) vLf125 = adcval; // voltage at 125Khz
|
if (i==95) vLf125 = adcval; // voltage at 125Khz
|
||||||
if (i==89) vLf134 = adcval; // voltage at 134Khz
|
if (i==89) vLf134 = adcval; // voltage at 134Khz
|
||||||
|
|
||||||
dest[i] = adcval>>8; // scale int to fit in byte for graphing purposes
|
LF_Results[i] = adcval>>8; // scale int to fit in byte for graphing purposes
|
||||||
if(dest[i] > peak) {
|
if(LF_Results[i] > peak) {
|
||||||
peakv = adcval;
|
peakv = adcval;
|
||||||
peak = dest[i];
|
peak = LF_Results[i];
|
||||||
peakf = i;
|
peakf = i;
|
||||||
//ptr = i;
|
//ptr = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i=18; i >= 0; i--) LF_Results[i] = 0;
|
||||||
|
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
// Let the FPGA drive the high-frequency antenna around 13.56 MHz.
|
// Let the FPGA drive the high-frequency antenna around 13.56 MHz.
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
|
@ -216,14 +216,7 @@ void MeasureAntennaTuning(void)
|
||||||
// can measure voltages up to 33000 mV
|
// can measure voltages up to 33000 mV
|
||||||
vHf = (33000 * AvgAdc(ADC_CHAN_HF)) >> 10;
|
vHf = (33000 * AvgAdc(ADC_CHAN_HF)) >> 10;
|
||||||
|
|
||||||
// c.cmd = CMD_MEASURED_ANTENNA_TUNING;
|
cmd_send(CMD_MEASURED_ANTENNA_TUNING,vLf125|(vLf134<<16),vHf,peakf|(peakv<<16),LF_Results,256);
|
||||||
// c.arg[0] = (vLf125 << 0) | (vLf134 << 16);
|
|
||||||
// c.arg[1] = vHf;
|
|
||||||
// c.arg[2] = peakf | (peakv << 16);
|
|
||||||
|
|
||||||
DbpString("Measuring complete, sending report back to host");
|
|
||||||
cmd_send(CMD_MEASURED_ANTENNA_TUNING,vLf125|(vLf134<<16),vHf,peakf|(peakv<<16),0,0);
|
|
||||||
// UsbSendPacket((uint8_t *)&c, sizeof(c));
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LED_A_OFF();
|
LED_A_OFF();
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
|
|
|
@ -1714,7 +1714,7 @@ int ReaderReceive(uint8_t *receivedAnswer, uint8_t *parity)
|
||||||
* fills the uid pointer unless NULL
|
* fills the uid pointer unless NULL
|
||||||
* fills resp_data unless NULL */
|
* fills resp_data unless NULL */
|
||||||
int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, uint32_t* cuid_ptr) {
|
int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, uint32_t* cuid_ptr) {
|
||||||
uint8_t halt[] = { 0x50 }; // HALT
|
//uint8_t halt[] = { 0x50 }; // HALT
|
||||||
uint8_t wupa[] = { 0x52 }; // WAKE-UP
|
uint8_t wupa[] = { 0x52 }; // WAKE-UP
|
||||||
//uint8_t reqa[] = { 0x26 }; // REQUEST A
|
//uint8_t reqa[] = { 0x26 }; // REQUEST A
|
||||||
uint8_t sel_all[] = { 0x93,0x20 };
|
uint8_t sel_all[] = { 0x93,0x20 };
|
||||||
|
@ -1725,19 +1725,18 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
|
||||||
|
|
||||||
byte_t uid_resp[4];
|
byte_t uid_resp[4];
|
||||||
size_t uid_resp_len;
|
size_t uid_resp_len;
|
||||||
|
|
||||||
uint8_t sak = 0x04; // cascade uid
|
uint8_t sak = 0x04; // cascade uid
|
||||||
int cascade_level = 0;
|
int cascade_level = 0;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
ReaderTransmit(halt,sizeof(halt), NULL);
|
// test for the SKYLANDERS TOY.
|
||||||
|
//ReaderTransmit(halt,sizeof(halt), NULL);
|
||||||
|
|
||||||
// Broadcast for a card, WUPA (0x52) will force response from all cards in the field
|
// Broadcast for a card, WUPA (0x52) will force response from all cards in the field
|
||||||
ReaderTransmitBitsPar(wupa,7,0, NULL);
|
ReaderTransmitBitsPar(wupa,7,0, NULL);
|
||||||
|
|
||||||
// Receive the ATQA
|
// Receive the ATQA
|
||||||
if(!ReaderReceive(resp, resp_par)) return 0;
|
if(!ReaderReceive(resp, resp_par)) return 0;
|
||||||
// Dbprintf("atqa: %02x %02x",resp[0],resp[1]);
|
|
||||||
|
|
||||||
if(p_hi14a_card) {
|
if(p_hi14a_card) {
|
||||||
memcpy(p_hi14a_card->atqa, resp, 2);
|
memcpy(p_hi14a_card->atqa, resp, 2);
|
||||||
|
@ -1794,7 +1793,6 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
|
||||||
}
|
}
|
||||||
uid_resp_len = 4;
|
uid_resp_len = 4;
|
||||||
|
|
||||||
|
|
||||||
// calculate crypto UID. Always use last 4 Bytes.
|
// calculate crypto UID. Always use last 4 Bytes.
|
||||||
if(cuid_ptr) {
|
if(cuid_ptr) {
|
||||||
*cuid_ptr = bytes_to_num(uid_resp, 4);
|
*cuid_ptr = bytes_to_num(uid_resp, 4);
|
||||||
|
@ -1811,17 +1809,11 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
|
||||||
if (!ReaderReceive(resp, resp_par)) return 0;
|
if (!ReaderReceive(resp, resp_par)) return 0;
|
||||||
sak = resp[0];
|
sak = resp[0];
|
||||||
|
|
||||||
//Dbprintf("SAK: %02x",resp[0]);
|
|
||||||
|
|
||||||
// Test if more parts of the uid are comming
|
// Test if more parts of the uid are coming
|
||||||
if ((sak & 0x04) /* && uid_resp[0] == 0x88 */) {
|
if ((sak & 0x04) /* && uid_resp[0] == 0x88 */) {
|
||||||
// Remove first byte, 0x88 is not an UID byte, it CT, see page 3 of:
|
// Remove first byte, 0x88 is not an UID byte, it CT, see page 3 of:
|
||||||
// http://www.nxp.com/documents/application_note/AN10927.pdf
|
// http://www.nxp.com/documents/application_note/AN10927.pdf
|
||||||
// This was earlier:
|
|
||||||
//memcpy(uid_resp, uid_resp + 1, 3);
|
|
||||||
// But memcpy should not be used for overlapping arrays,
|
|
||||||
// and memmove appears to not be available in the arm build.
|
|
||||||
// Therefore:
|
|
||||||
uid_resp[0] = uid_resp[1];
|
uid_resp[0] = uid_resp[1];
|
||||||
uid_resp[1] = uid_resp[2];
|
uid_resp[1] = uid_resp[2];
|
||||||
uid_resp[2] = uid_resp[3];
|
uid_resp[2] = uid_resp[3];
|
||||||
|
@ -1852,7 +1844,7 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
|
||||||
AppendCrc14443a(rats, 2);
|
AppendCrc14443a(rats, 2);
|
||||||
ReaderTransmit(rats, sizeof(rats), NULL);
|
ReaderTransmit(rats, sizeof(rats), NULL);
|
||||||
|
|
||||||
if (!(len = ReaderReceive(resp,resp_par))) return 0;
|
if (!(len = ReaderReceive(resp, resp_par))) return 2;
|
||||||
|
|
||||||
if(p_hi14a_card) {
|
if(p_hi14a_card) {
|
||||||
memcpy(p_hi14a_card->ats, resp, sizeof(p_hi14a_card->ats));
|
memcpy(p_hi14a_card->ats, resp, sizeof(p_hi14a_card->ats));
|
||||||
|
|
|
@ -477,20 +477,52 @@ int CmdSamples(const char *Cmd)
|
||||||
}
|
}
|
||||||
int CmdTuneSamples(const char *Cmd)
|
int CmdTuneSamples(const char *Cmd)
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int timeout = 0;
|
||||||
int n = 255;
|
printf("\nMeasuring antenna characteristics, please wait...");
|
||||||
uint8_t got[255] = {0x00};
|
|
||||||
|
|
||||||
PrintAndLog("Reading %d samples\n", n);
|
UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING};
|
||||||
GetFromBigBuf(got,n,7256); // armsrc/apps.h: #define FREE_BUFFER_OFFSET 7256
|
SendCommand(&c);
|
||||||
WaitForResponse(CMD_ACK,NULL);
|
|
||||||
for (int j = 0; j < n; j++) {
|
UsbCommand resp;
|
||||||
GraphBuffer[cnt++] = ((int)got[j]) - 128;
|
while(!WaitForResponseTimeout(CMD_MEASURED_ANTENNA_TUNING,&resp,1000)) {
|
||||||
|
timeout++;
|
||||||
|
printf(".");
|
||||||
|
if (timeout > 7) {
|
||||||
|
PrintAndLog("\nNo response from Proxmark. Aborting...");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int peakv, peakf;
|
||||||
|
int vLf125, vLf134, vHf;
|
||||||
|
vLf125 = resp.arg[0] & 0xffff;
|
||||||
|
vLf134 = resp.arg[0] >> 16;
|
||||||
|
vHf = resp.arg[1] & 0xffff;;
|
||||||
|
peakf = resp.arg[2] & 0xffff;
|
||||||
|
peakv = resp.arg[2] >> 16;
|
||||||
|
PrintAndLog("");
|
||||||
|
PrintAndLog("# LF antenna: %5.2f V @ 125.00 kHz", vLf125/1000.0);
|
||||||
|
PrintAndLog("# LF antenna: %5.2f V @ 134.00 kHz", vLf134/1000.0);
|
||||||
|
PrintAndLog("# LF optimal: %5.2f V @%9.2f kHz", peakv/1000.0, 12000.0/(peakf+1));
|
||||||
|
PrintAndLog("# HF antenna: %5.2f V @ 13.56 MHz", vHf/1000.0);
|
||||||
|
if (peakv<2000)
|
||||||
|
PrintAndLog("# Your LF antenna is unusable.");
|
||||||
|
else if (peakv<10000)
|
||||||
|
PrintAndLog("# Your LF antenna is marginal.");
|
||||||
|
if (vHf<2000)
|
||||||
|
PrintAndLog("# Your HF antenna is unusable.");
|
||||||
|
else if (vHf<5000)
|
||||||
|
PrintAndLog("# Your HF antenna is marginal.");
|
||||||
|
|
||||||
|
for (int i = 0; i < 256; i++) {
|
||||||
|
GraphBuffer[i] = resp.d.asBytes[i] - 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLog("Done! Divisor 89 is 134khz, 95 is 125khz.\n");
|
PrintAndLog("Done! Divisor 89 is 134khz, 95 is 125khz.\n");
|
||||||
GraphTraceLen = n;
|
PrintAndLog("\n");
|
||||||
RepaintGraphWindow();
|
GraphTraceLen = 256;
|
||||||
|
ShowGraphWindow();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,11 @@ int CmdHF14AList(const char *Cmd)
|
||||||
ShowWaitCycles = true;
|
ShowWaitCycles = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t trace[TRACE_BUFFER_SIZE];
|
// for the time being. Need better Bigbuf handling.
|
||||||
GetFromBigBuf(trace,TRACE_BUFFER_SIZE,0);
|
#define TRACE_SIZE 3000
|
||||||
|
|
||||||
|
uint8_t trace[TRACE_SIZE];
|
||||||
|
GetFromBigBuf(trace, TRACE_SIZE, 0);
|
||||||
WaitForResponse(CMD_ACK,NULL);
|
WaitForResponse(CMD_ACK,NULL);
|
||||||
|
|
||||||
PrintAndLog("Recorded Activity");
|
PrintAndLog("Recorded Activity");
|
||||||
|
@ -67,7 +70,9 @@ int CmdHF14AList(const char *Cmd)
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
if( tracepos >= TRACE_BUFFER_SIZE) break;
|
if(tracepos >= TRACE_SIZE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
timestamp = *((uint32_t *)(trace + tracepos));
|
timestamp = *((uint32_t *)(trace + tracepos));
|
||||||
if(tracepos == 0) {
|
if(tracepos == 0) {
|
||||||
|
@ -88,8 +93,9 @@ int CmdHF14AList(const char *Cmd)
|
||||||
|
|
||||||
parity_len = (data_len-1)/8 + 1;
|
parity_len = (data_len-1)/8 + 1;
|
||||||
|
|
||||||
|
if (tracepos + data_len + parity_len >= TRACE_SIZE) {
|
||||||
if (tracepos + data_len + parity_len >= TRACE_BUFFER_SIZE) { break; }
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t *frame = trace + tracepos;
|
uint8_t *frame = trace + tracepos;
|
||||||
tracepos += data_len;
|
tracepos += data_len;
|
||||||
|
@ -126,6 +132,7 @@ int CmdHF14AList(const char *Cmd)
|
||||||
} else {
|
} else {
|
||||||
sprintf(crc, "");
|
sprintf(crc, "");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EndOfTransmissionTimestamp = timestamp + duration;
|
EndOfTransmissionTimestamp = timestamp + duration;
|
||||||
|
|
||||||
|
@ -137,6 +144,7 @@ int CmdHF14AList(const char *Cmd)
|
||||||
crc);
|
crc);
|
||||||
|
|
||||||
bool next_isResponse = *((uint16_t *)(trace + tracepos + 6)) & 0x8000;
|
bool next_isResponse = *((uint16_t *)(trace + tracepos + 6)) & 0x8000;
|
||||||
|
|
||||||
if (ShowWaitCycles && !isResponse && next_isResponse) {
|
if (ShowWaitCycles && !isResponse && next_isResponse) {
|
||||||
uint32_t next_timestamp = *((uint32_t *)(trace + tracepos));
|
uint32_t next_timestamp = *((uint32_t *)(trace + tracepos));
|
||||||
if (next_timestamp != 0x44444444) {
|
if (next_timestamp != 0x44444444) {
|
||||||
|
@ -147,8 +155,9 @@ int CmdHF14AList(const char *Cmd)
|
||||||
(next_timestamp - EndOfTransmissionTimestamp));
|
(next_timestamp - EndOfTransmissionTimestamp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,24 +168,28 @@ void iso14a_set_timeout(uint32_t timeout) {
|
||||||
|
|
||||||
int CmdHF14AReader(const char *Cmd)
|
int CmdHF14AReader(const char *Cmd)
|
||||||
{
|
{
|
||||||
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}};
|
//UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}};
|
||||||
|
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT , 0, 0}};
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
|
|
||||||
UsbCommand resp;
|
UsbCommand resp;
|
||||||
WaitForResponse(CMD_ACK,&resp);
|
WaitForResponse(CMD_ACK,&resp);
|
||||||
|
|
||||||
iso14a_card_select_t *card = (iso14a_card_select_t *)resp.d.asBytes;
|
iso14a_card_select_t card;
|
||||||
|
memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t));
|
||||||
|
|
||||||
if(resp.arg[0] == 0) {
|
uint64_t select_status = resp.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS
|
||||||
|
|
||||||
|
if(select_status == 0) {
|
||||||
PrintAndLog("iso14443a card select failed");
|
PrintAndLog("iso14443a card select failed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLog("ATQA : %02x %02x", card->atqa[0], card->atqa[1]);
|
PrintAndLog("ATQA : %02x %02x", card.atqa[1], card.atqa[0]);
|
||||||
PrintAndLog(" UID : %s", sprint_hex(card->uid, card->uidlen));
|
PrintAndLog(" UID : %s", sprint_hex(card.uid, card.uidlen));
|
||||||
PrintAndLog(" SAK : %02x [%d]", card->sak, resp.arg[0]);
|
PrintAndLog(" SAK : %02x [%d]", card.sak, resp.arg[0]);
|
||||||
|
|
||||||
switch (card->sak) {
|
switch (card.sak) {
|
||||||
case 0x00: PrintAndLog("TYPE : NXP MIFARE Ultralight | Ultralight C"); break;
|
case 0x00: PrintAndLog("TYPE : NXP MIFARE Ultralight | Ultralight C"); break;
|
||||||
case 0x01: PrintAndLog("TYPE : NXP TNP3xxx Activision Game Appliance"); break;
|
case 0x01: PrintAndLog("TYPE : NXP TNP3xxx Activision Game Appliance"); break;
|
||||||
case 0x04: PrintAndLog("TYPE : NXP MIFARE (various !DESFire !DESFire EV1)"); break;
|
case 0x04: PrintAndLog("TYPE : NXP MIFARE (various !DESFire !DESFire EV1)"); break;
|
||||||
|
@ -193,67 +206,107 @@ int CmdHF14AReader(const char *Cmd)
|
||||||
case 0x98: PrintAndLog("TYPE : Gemplus MPCOS"); break;
|
case 0x98: PrintAndLog("TYPE : Gemplus MPCOS"); break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
if(resp.arg[0] == 1) {
|
|
||||||
|
|
||||||
|
// try to request ATS even if tag claims not to support it
|
||||||
|
if (select_status == 2) {
|
||||||
|
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
|
||||||
|
c.arg[0] = ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT;
|
||||||
|
c.arg[1] = 2;
|
||||||
|
c.arg[2] = 0;
|
||||||
|
memcpy(c.d.asBytes, rats, 2);
|
||||||
|
SendCommand(&c);
|
||||||
|
WaitForResponse(CMD_ACK,&resp);
|
||||||
|
|
||||||
|
memcpy(&card.ats, resp.d.asBytes, resp.arg[0]);
|
||||||
|
card.ats_len = resp.arg[0]; // note: ats_len includes CRC Bytes
|
||||||
|
}
|
||||||
|
|
||||||
|
// disconnect
|
||||||
|
c.arg[0] = 0;
|
||||||
|
c.arg[1] = 0;
|
||||||
|
c.arg[2] = 0;
|
||||||
|
SendCommand(&c);
|
||||||
|
|
||||||
|
|
||||||
|
if(card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes
|
||||||
bool ta1 = 0, tb1 = 0, tc1 = 0;
|
bool ta1 = 0, tb1 = 0, tc1 = 0;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
PrintAndLog(" ATS : %s", sprint_hex(card->ats, card->ats_len));
|
if (select_status == 2) {
|
||||||
if (card->ats_len > 0) {
|
PrintAndLog("SAK incorrectly claims that card doesn't support RATS");
|
||||||
PrintAndLog(" - TL : length is %d bytes", card->ats[0]);
|
|
||||||
}
|
}
|
||||||
if (card->ats_len > 1) {
|
PrintAndLog(" ATS : %s", sprint_hex(card.ats, card.ats_len));
|
||||||
ta1 = (card->ats[1] & 0x10) == 0x10;
|
PrintAndLog(" - TL : length is %d bytes", card.ats[0]);
|
||||||
tb1 = (card->ats[1] & 0x20) == 0x20;
|
if (card.ats[0] != card.ats_len - 2) {
|
||||||
tc1 = (card->ats[1] & 0x40) == 0x40;
|
PrintAndLog("ATS may be corrupted. Length of ATS (%d bytes incl. 2 Bytes CRC) doesn't match TL", card.ats_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (card.ats[0] > 1) { // there is a format byte (T0)
|
||||||
|
ta1 = (card.ats[1] & 0x10) == 0x10;
|
||||||
|
tb1 = (card.ats[1] & 0x20) == 0x20;
|
||||||
|
tc1 = (card.ats[1] & 0x40) == 0x40;
|
||||||
|
int16_t fsci = card.ats[1] & 0x0f;
|
||||||
PrintAndLog(" - T0 : TA1 is%s present, TB1 is%s present, "
|
PrintAndLog(" - T0 : TA1 is%s present, TB1 is%s present, "
|
||||||
"TC1 is%s present, FSCI is %d",
|
"TC1 is%s present, FSCI is %d (FSC = %ld)",
|
||||||
(ta1 ? "" : " NOT"), (tb1 ? "" : " NOT"), (tc1 ? "" : " NOT"),
|
(ta1 ? "" : " NOT"), (tb1 ? "" : " NOT"), (tc1 ? "" : " NOT"),
|
||||||
(card->ats[1] & 0x0f));
|
fsci,
|
||||||
|
fsci < 5 ? (fsci - 2) * 8 :
|
||||||
|
fsci < 8 ? (fsci - 3) * 32 :
|
||||||
|
fsci == 8 ? 256 :
|
||||||
|
-1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
pos = 2;
|
pos = 2;
|
||||||
if (ta1 && card->ats_len > pos) {
|
if (ta1) {
|
||||||
char dr[16], ds[16];
|
char dr[16], ds[16];
|
||||||
dr[0] = ds[0] = '\0';
|
dr[0] = ds[0] = '\0';
|
||||||
if (card->ats[pos] & 0x10) strcat(ds, "2, ");
|
if (card.ats[pos] & 0x10) strcat(ds, "2, ");
|
||||||
if (card->ats[pos] & 0x20) strcat(ds, "4, ");
|
if (card.ats[pos] & 0x20) strcat(ds, "4, ");
|
||||||
if (card->ats[pos] & 0x40) strcat(ds, "8, ");
|
if (card.ats[pos] & 0x40) strcat(ds, "8, ");
|
||||||
if (card->ats[pos] & 0x01) strcat(dr, "2, ");
|
if (card.ats[pos] & 0x01) strcat(dr, "2, ");
|
||||||
if (card->ats[pos] & 0x02) strcat(dr, "4, ");
|
if (card.ats[pos] & 0x02) strcat(dr, "4, ");
|
||||||
if (card->ats[pos] & 0x04) strcat(dr, "8, ");
|
if (card.ats[pos] & 0x04) strcat(dr, "8, ");
|
||||||
if (strlen(ds) != 0) ds[strlen(ds) - 2] = '\0';
|
if (strlen(ds) != 0) ds[strlen(ds) - 2] = '\0';
|
||||||
if (strlen(dr) != 0) dr[strlen(dr) - 2] = '\0';
|
if (strlen(dr) != 0) dr[strlen(dr) - 2] = '\0';
|
||||||
PrintAndLog(" - TA1 : different divisors are%s supported, "
|
PrintAndLog(" - TA1 : different divisors are%s supported, "
|
||||||
"DR: [%s], DS: [%s]",
|
"DR: [%s], DS: [%s]",
|
||||||
(card->ats[pos] & 0x80 ? " NOT" : ""), dr, ds);
|
(card.ats[pos] & 0x80 ? " NOT" : ""), dr, ds);
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
if (tb1 && card->ats_len > pos) {
|
if (tb1) {
|
||||||
PrintAndLog(" - TB1 : SFGI = %d, FWI = %d",
|
uint32_t sfgi = card.ats[pos] & 0x0F;
|
||||||
(card->ats[pos] & 0x08),
|
uint32_t fwi = card.ats[pos] >> 4;
|
||||||
(card->ats[pos] & 0x80) >> 4);
|
PrintAndLog(" - TB1 : SFGI = %d (SFGT = %s%ld/fc), FWI = %d (FWT = %ld/fc)",
|
||||||
|
(sfgi),
|
||||||
|
sfgi ? "" : "(not needed) ",
|
||||||
|
sfgi ? (1 << 12) << sfgi : 0,
|
||||||
|
fwi,
|
||||||
|
(1 << 12) << fwi
|
||||||
|
);
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
if (tc1 && card->ats_len > pos) {
|
if (tc1) {
|
||||||
PrintAndLog(" - TC1 : NAD is%s supported, CID is%s supported",
|
PrintAndLog(" - TC1 : NAD is%s supported, CID is%s supported",
|
||||||
(card->ats[pos] & 0x01) ? "" : " NOT",
|
(card.ats[pos] & 0x01) ? "" : " NOT",
|
||||||
(card->ats[pos] & 0x02) ? "" : " NOT");
|
(card.ats[pos] & 0x02) ? "" : " NOT");
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
if (card->ats_len > pos) {
|
if (card.ats[0] > pos) {
|
||||||
char *tip = "";
|
char *tip = "";
|
||||||
if (card->ats_len - pos > 7) {
|
if (card.ats[0] - pos >= 7) {
|
||||||
if (memcmp(card->ats + pos, "\xC1\x05\x2F\x2F\x01\xBC\xD6", 7) == 0) {
|
if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x01\xBC\xD6", 7) == 0) {
|
||||||
tip = "-> MIFARE Plus X 2K or 4K";
|
tip = "-> MIFARE Plus X 2K or 4K";
|
||||||
} else if (memcmp(card->ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) {
|
} else if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) {
|
||||||
tip = "-> MIFARE Plus S 2K or 4K";
|
tip = "-> MIFARE Plus S 2K or 4K";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrintAndLog(" - HB : %s%s", sprint_hex(card->ats + pos, card->ats_len - pos - 2), tip);
|
PrintAndLog(" - HB : %s%s", sprint_hex(card.ats + pos, card.ats[0] - pos), tip);
|
||||||
if (card->ats[pos] == 0xC1) {
|
if (card.ats[pos] == 0xC1) {
|
||||||
PrintAndLog(" c1 -> Mifare or (multiple) virtual cards of various type");
|
PrintAndLog(" c1 -> Mifare or (multiple) virtual cards of various type");
|
||||||
PrintAndLog(" %02x -> Length is %d bytes",
|
PrintAndLog(" %02x -> Length is %d bytes",
|
||||||
card->ats[pos + 1], card->ats[pos + 1]);
|
card.ats[pos + 1], card.ats[pos + 1]);
|
||||||
switch (card->ats[pos + 2] & 0xf0) {
|
switch (card.ats[pos + 2] & 0xf0) {
|
||||||
case 0x10:
|
case 0x10:
|
||||||
PrintAndLog(" 1x -> MIFARE DESFire");
|
PrintAndLog(" 1x -> MIFARE DESFire");
|
||||||
break;
|
break;
|
||||||
|
@ -261,7 +314,7 @@ int CmdHF14AReader(const char *Cmd)
|
||||||
PrintAndLog(" 2x -> MIFARE Plus");
|
PrintAndLog(" 2x -> MIFARE Plus");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (card->ats[pos + 2] & 0x0f) {
|
switch (card.ats[pos + 2] & 0x0f) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
PrintAndLog(" x0 -> <1 kByte");
|
PrintAndLog(" x0 -> <1 kByte");
|
||||||
break;
|
break;
|
||||||
|
@ -278,7 +331,7 @@ int CmdHF14AReader(const char *Cmd)
|
||||||
PrintAndLog(" x0 -> 8 kByte");
|
PrintAndLog(" x0 -> 8 kByte");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (card->ats[pos + 3] & 0xf0) {
|
switch (card.ats[pos + 3] & 0xf0) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
PrintAndLog(" 0x -> Engineering sample");
|
PrintAndLog(" 0x -> Engineering sample");
|
||||||
break;
|
break;
|
||||||
|
@ -286,7 +339,7 @@ int CmdHF14AReader(const char *Cmd)
|
||||||
PrintAndLog(" 2x -> Released");
|
PrintAndLog(" 2x -> Released");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (card->ats[pos + 3] & 0x0f) {
|
switch (card.ats[pos + 3] & 0x0f) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
PrintAndLog(" x0 -> Generation 1");
|
PrintAndLog(" x0 -> Generation 1");
|
||||||
break;
|
break;
|
||||||
|
@ -297,7 +350,7 @@ int CmdHF14AReader(const char *Cmd)
|
||||||
PrintAndLog(" x2 -> Generation 3");
|
PrintAndLog(" x2 -> Generation 3");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (card->ats[pos + 4] & 0x0f) {
|
switch (card.ats[pos + 4] & 0x0f) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
PrintAndLog(" x0 -> Only VCSL supported");
|
PrintAndLog(" x0 -> Only VCSL supported");
|
||||||
break;
|
break;
|
||||||
|
@ -311,10 +364,10 @@ int CmdHF14AReader(const char *Cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLog("proprietary non iso14443a-4 card found, RATS not supported");
|
PrintAndLog("proprietary non iso14443-4 card found, RATS not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.arg[0];
|
return select_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect ISO14443 Type A UIDs
|
// Collect ISO14443 Type A UIDs
|
||||||
|
@ -336,20 +389,17 @@ int CmdHF14ACUIDs(const char *Cmd)
|
||||||
UsbCommand resp;
|
UsbCommand resp;
|
||||||
WaitForResponse(CMD_ACK,&resp);
|
WaitForResponse(CMD_ACK,&resp);
|
||||||
|
|
||||||
uint8_t *uid = resp.d.asBytes;
|
iso14a_card_select_t *card = (iso14a_card_select_t *) resp.d.asBytes;
|
||||||
iso14a_card_select_t *card = (iso14a_card_select_t *)(uid + 12);
|
|
||||||
|
|
||||||
// check if command failed
|
// check if command failed
|
||||||
if (resp.arg[0] == 0) {
|
if (resp.arg[0] == 0) {
|
||||||
PrintAndLog("Card select failed.");
|
PrintAndLog("Card select failed.");
|
||||||
} else {
|
} else {
|
||||||
// check if UID is 4 bytes
|
char uid_string[20];
|
||||||
if ((card->atqa[1] & 0xC0) == 0) {
|
for (uint16_t i = 0; i < card->uidlen; i++) {
|
||||||
PrintAndLog("%02X%02X%02X%02X",
|
sprintf(&uid_string[2*i], "%02X", card->uid[i]);
|
||||||
*uid, *(uid + 1), *(uid + 2), *(uid + 3));
|
|
||||||
} else {
|
|
||||||
PrintAndLog("UID longer than 4 bytes");
|
|
||||||
}
|
}
|
||||||
|
PrintAndLog("%s", uid_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrintAndLog("End: %u", time(NULL));
|
PrintAndLog("End: %u", time(NULL));
|
||||||
|
|
|
@ -159,7 +159,8 @@ int CmdHF14AMfURdBl(const char *Cmd){
|
||||||
PrintAndLog("isOk:%02x data:%s", isOK, sprint_hex(data, 4));
|
PrintAndLog("isOk:%02x data:%s", isOK, sprint_hex(data, 4));
|
||||||
else
|
else
|
||||||
PrintAndLog("isOk:%02x", isOK);
|
PrintAndLog("isOk:%02x", isOK);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
PrintAndLog("Command execute timeout");
|
PrintAndLog("Command execute timeout");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -171,7 +172,7 @@ int CmdHF14AMfURdBl(const char *Cmd){
|
||||||
int CmdHF14AMfURdCard(const char *Cmd){
|
int CmdHF14AMfURdCard(const char *Cmd){
|
||||||
int i;
|
int i;
|
||||||
uint8_t BlockNo = 0;
|
uint8_t BlockNo = 0;
|
||||||
int Pages=16;
|
int pages=16;
|
||||||
uint8_t *lockbytes_t=NULL;
|
uint8_t *lockbytes_t=NULL;
|
||||||
uint8_t lockbytes[2]={0x00};
|
uint8_t lockbytes[2]={0x00};
|
||||||
bool bit[16]={0x00};
|
bool bit[16]={0x00};
|
||||||
|
@ -191,7 +192,7 @@ int CmdHF14AMfURdCard(const char *Cmd){
|
||||||
PrintAndLog("Dumping Ultralight Card Data...");
|
PrintAndLog("Dumping Ultralight Card Data...");
|
||||||
}
|
}
|
||||||
PrintAndLog("Attempting to Read Ultralight... ");
|
PrintAndLog("Attempting to Read Ultralight... ");
|
||||||
UsbCommand c = {CMD_MIFAREU_READCARD, {BlockNo, Pages}};
|
UsbCommand c = {CMD_MIFAREU_READCARD, {BlockNo, pages}};
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
UsbCommand resp;
|
UsbCommand resp;
|
||||||
|
|
||||||
|
@ -231,7 +232,7 @@ int CmdHF14AMfURdCard(const char *Cmd){
|
||||||
PrintAndLog(" OneTimePad :%s ", sprint_hex(data + 3*4, 4));
|
PrintAndLog(" OneTimePad :%s ", sprint_hex(data + 3*4, 4));
|
||||||
PrintAndLog("");
|
PrintAndLog("");
|
||||||
|
|
||||||
for (i = 0; i < Pages; i++) {
|
for (i = 0; i < pages; i++) {
|
||||||
switch(i){
|
switch(i){
|
||||||
case 2:
|
case 2:
|
||||||
//process lock bytes
|
//process lock bytes
|
||||||
|
@ -634,7 +635,7 @@ int CmdHF14AMfUCRdCard(const char *Cmd){
|
||||||
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
|
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
|
||||||
isOK = resp.arg[0] & 0xff;
|
isOK = resp.arg[0] & 0xff;
|
||||||
data = resp.d.asBytes;
|
data = resp.d.asBytes;
|
||||||
//Pages=sizeof(data)/sizeof(data[0]);
|
|
||||||
PrintAndLog("isOk:%02x", isOK);
|
PrintAndLog("isOk:%02x", isOK);
|
||||||
if (isOK)
|
if (isOK)
|
||||||
for (i = 0; i < Pages; i++) {
|
for (i = 0; i < Pages; i++) {
|
||||||
|
@ -1145,7 +1146,6 @@ static command_t CommandTable[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
int CmdHFMFUltra(const char *Cmd){
|
int CmdHFMFUltra(const char *Cmd){
|
||||||
// flush
|
|
||||||
WaitForResponseTimeout(CMD_ACK,NULL,100);
|
WaitForResponseTimeout(CMD_ACK,NULL,100);
|
||||||
CmdsParse(CommandTable, Cmd);
|
CmdsParse(CommandTable, Cmd);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -391,23 +391,7 @@ int CmdSetMux(const char *Cmd)
|
||||||
|
|
||||||
int CmdTune(const char *Cmd)
|
int CmdTune(const char *Cmd)
|
||||||
{
|
{
|
||||||
UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING};
|
return CmdTuneSamples(Cmd);
|
||||||
SendCommand(&c);
|
|
||||||
|
|
||||||
char cmdp = param_getchar(Cmd, 0);
|
|
||||||
if (cmdp == 'h' || cmdp == 'H') {
|
|
||||||
PrintAndLog("Usage: hw tune <p>");
|
|
||||||
PrintAndLog("");
|
|
||||||
PrintAndLog(" sample: hw tune");
|
|
||||||
PrintAndLog(" hw tune p");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( cmdp == 'p' || cmdp == 'P'){
|
|
||||||
ShowGraphWindow();
|
|
||||||
CmdTuneSamples("");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdVersion(const char *Cmd)
|
int CmdVersion(const char *Cmd)
|
||||||
|
|
103
client/cmdmain.c
103
client/cmdmain.c
|
@ -26,15 +26,8 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "cmdscript.h"
|
#include "cmdscript.h"
|
||||||
|
|
||||||
int delta125[2];
|
|
||||||
int delta134[2];
|
|
||||||
int deltahf[2];
|
|
||||||
int deltaReset = 0;
|
|
||||||
|
|
||||||
unsigned int current_command = CMD_UNKNOWN;
|
unsigned int current_command = CMD_UNKNOWN;
|
||||||
//unsigned int received_command = CMD_UNKNOWN;
|
|
||||||
//UsbCommand current_response;
|
|
||||||
//UsbCommand current_response_user;
|
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
static int CmdQuit(const char *Cmd);
|
static int CmdQuit(const char *Cmd);
|
||||||
|
@ -140,21 +133,17 @@ bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeou
|
||||||
|
|
||||||
UsbCommand resp;
|
UsbCommand resp;
|
||||||
|
|
||||||
if (response == NULL) {
|
if (response == NULL)
|
||||||
|
|
||||||
response = &resp;
|
response = &resp;
|
||||||
}
|
|
||||||
|
|
||||||
// Wait until the command is received
|
// Wait until the command is received
|
||||||
for(size_t dm_seconds=0; dm_seconds < ms_timeout/10; dm_seconds++) {
|
for(size_t dm_seconds=0; dm_seconds < ms_timeout/10; dm_seconds++) {
|
||||||
|
|
||||||
while(getCommand(response))
|
while(getCommand(response)) {
|
||||||
{
|
|
||||||
if(response->cmd == cmd){
|
if(response->cmd == cmd){
|
||||||
//We got what we expected
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
msleep(10); // XXX ugh
|
msleep(10); // XXX ugh
|
||||||
if (dm_seconds == 200) { // Two seconds elapsed
|
if (dm_seconds == 200) { // Two seconds elapsed
|
||||||
|
@ -183,18 +172,6 @@ void CommandReceived(char *Cmd) {
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void UsbCommandReceived(UsbCommand *UC)
|
void UsbCommandReceived(UsbCommand *UC)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
// Debug
|
|
||||||
printf("UsbCommand length[len=%zd]\n",sizeof(UsbCommand));
|
|
||||||
printf(" cmd[len=%zd]: %"llx"\n",sizeof(UC->cmd),UC->cmd);
|
|
||||||
printf(" arg0[len=%zd]: %"llx"\n",sizeof(UC->arg[0]),UC->arg[0]);
|
|
||||||
printf(" arg1[len=%zd]: %"llx"\n",sizeof(UC->arg[1]),UC->arg[1]);
|
|
||||||
printf(" arg2[len=%zd]: %"llx"\n",sizeof(UC->arg[2]),UC->arg[2]);
|
|
||||||
printf(" data[len=%zd]: %02x%02x%02x...\n",sizeof(UC->d.asBytes),UC->d.asBytes[0],UC->d.asBytes[1],UC->d.asBytes[2]);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// printf("%s(%x) current cmd = %x\n", __FUNCTION__, c->cmd, current_command);
|
|
||||||
// If we recognize a response, return to avoid further processing
|
|
||||||
switch(UC->cmd) {
|
switch(UC->cmd) {
|
||||||
// First check if we are handling a debug message
|
// First check if we are handling a debug message
|
||||||
case CMD_DEBUG_PRINT_STRING: {
|
case CMD_DEBUG_PRINT_STRING: {
|
||||||
|
@ -210,87 +187,15 @@ void UsbCommandReceived(UsbCommand *UC)
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case CMD_MEASURED_ANTENNA_TUNING: {
|
|
||||||
int peakv, peakf;
|
|
||||||
int vLf125, vLf134, vHf;
|
|
||||||
vLf125 = UC->arg[0] & 0xffff;
|
|
||||||
vLf134 = UC->arg[0] >> 16;
|
|
||||||
vHf = UC->arg[1] & 0xffff;;
|
|
||||||
peakf = UC->arg[2] & 0xffff;
|
|
||||||
peakv = UC->arg[2] >> 16;
|
|
||||||
|
|
||||||
//Reset delta trigger every 3:d time
|
|
||||||
|
|
||||||
if ( deltaReset == 4){
|
|
||||||
delta125[0] = vLf125;
|
|
||||||
delta134[0] = vLf134;
|
|
||||||
deltahf[0] = vHf;
|
|
||||||
} else if ( deltaReset == 2){
|
|
||||||
delta125[1] = vLf125;
|
|
||||||
delta134[1] = vLf134;
|
|
||||||
deltahf[1] = vHf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( deltaReset == 0){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintAndLog("");
|
|
||||||
PrintAndLog("# LF antenna: %5.2f V @ 125.00 kHz", vLf125/1000.0);
|
|
||||||
PrintAndLog("# LF antenna: %5.2f V @ 134.00 kHz", vLf134/1000.0);
|
|
||||||
PrintAndLog("# LF optimal: %5.2f V @ %9.2f kHz", peakv/1000.0, 12000.0/(peakf+1));
|
|
||||||
PrintAndLog("# HF antenna: %5.2f V @ 13.56 MHz", vHf/1000.0);
|
|
||||||
if (peakv<2000)
|
|
||||||
PrintAndLog("# Your LF antenna is unusable.");
|
|
||||||
else if (peakv<10000)
|
|
||||||
PrintAndLog("# Your LF antenna is marginal.");
|
|
||||||
if (vHf<2000)
|
|
||||||
PrintAndLog("# Your HF antenna is unusable.");
|
|
||||||
else if (vHf<5000)
|
|
||||||
PrintAndLog("# Your HF antenna is marginal.");
|
|
||||||
}
|
|
||||||
|
|
||||||
deltaReset = (deltaReset == 0) ? 4 : deltaReset>>1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K: {
|
case CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K: {
|
||||||
// printf("received samples: ");
|
|
||||||
// print_hex(UC->d.asBytes,512);
|
|
||||||
sample_buf_len += UC->arg[1];
|
sample_buf_len += UC->arg[1];
|
||||||
// printf("samples: %zd offset: %d\n",sample_buf_len,UC->arg[0]);
|
|
||||||
memcpy(sample_buf+(UC->arg[0]),UC->d.asBytes,UC->arg[1]);
|
memcpy(sample_buf+(UC->arg[0]),UC->d.asBytes,UC->arg[1]);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
default:
|
||||||
// case CMD_ACK: {
|
|
||||||
// PrintAndLog("Receive ACK\n");
|
|
||||||
// } break;
|
|
||||||
|
|
||||||
default: {
|
|
||||||
// Maybe it's a response
|
|
||||||
/*
|
|
||||||
switch(current_command) {
|
|
||||||
case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: {
|
|
||||||
if (UC->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {
|
|
||||||
PrintAndLog("unrecognized command %08x\n", UC->cmd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// int i;
|
|
||||||
PrintAndLog("received samples %d\n",UC->arg[0]);
|
|
||||||
memcpy(sample_buf+UC->arg[0],UC->d.asBytes,48);
|
|
||||||
sample_buf_len += 48;
|
|
||||||
// for(i=0; i<48; i++) sample_buf[i] = UC->d.asBytes[i];
|
|
||||||
//received_command = UC->cmd;
|
|
||||||
} break;
|
|
||||||
|
|
||||||
default: {
|
|
||||||
} break;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
storeCommand(UC);
|
storeCommand(UC);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue