mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 15:26:13 +08:00
deleted test functions, clean up
This commit is contained in:
parent
473d89342b
commit
78d1e09595
|
@ -1172,10 +1172,6 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
em4x50_chk((uint8_t *)packet->data.asBytes);
|
em4x50_chk((uint8_t *)packet->data.asBytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_LF_EM4X50_TEST: {
|
|
||||||
em4x50_test((em4x50_test_t *)packet->data.asBytes);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_EM4x70
|
#ifdef WITH_EM4x70
|
||||||
|
|
134
armsrc/em4x50.c
134
armsrc/em4x50.c
|
@ -70,37 +70,12 @@ bool gLogin = false;
|
||||||
// to be able to identfiy it
|
// to be able to identfiy it
|
||||||
bool gWritePasswordProcess = false;
|
bool gWritePasswordProcess = false;
|
||||||
|
|
||||||
static int em4x50_sim_send_listen_window(uint32_t *tag);
|
|
||||||
|
|
||||||
void catch_samples(void);
|
|
||||||
|
|
||||||
// do nothing for <period> using timer0
|
// do nothing for <period> using timer0
|
||||||
static void wait_timer(uint32_t period) {
|
static void wait_timer(uint32_t period) {
|
||||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG;
|
AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG;
|
||||||
while (AT91C_BASE_TC0->TC_CV < period);
|
while (AT91C_BASE_TC0->TC_CV < period);
|
||||||
}
|
}
|
||||||
|
|
||||||
void catch_samples(void) {
|
|
||||||
|
|
||||||
uint8_t sample = 0;
|
|
||||||
|
|
||||||
if (EM4X50_MAX_NO_SAMPLES > CARD_MEMORY_SIZE) {
|
|
||||||
Dbprintf("exeeded emulator memory size");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t *em4x50_sample_buffer = BigBuf_get_addr();
|
|
||||||
|
|
||||||
memcpy(em4x50_sample_buffer, &gHigh, 1);
|
|
||||||
memcpy(em4x50_sample_buffer + 1, &gLow, 1);
|
|
||||||
|
|
||||||
for (int i = 2; i < EM4X50_MAX_NO_SAMPLES + 2; i++) {
|
|
||||||
sample = AT91C_BASE_SSC->SSC_RHR;
|
|
||||||
memcpy(em4x50_sample_buffer + i, &sample, 1);
|
|
||||||
wait_timer(T0); // 8µs delay
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract and check parities
|
// extract and check parities
|
||||||
// return result of parity check and extracted plain data
|
// return result of parity check and extracted plain data
|
||||||
static bool extract_parities(uint64_t word, uint32_t *data) {
|
static bool extract_parities(uint64_t word, uint32_t *data) {
|
||||||
|
@ -387,7 +362,7 @@ static void em4x50_reader_send_byte(uint8_t byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send byte followed by its (equal) parity bit
|
// send byte followed by its (even) parity bit
|
||||||
static void em4x50_reader_send_byte_with_parity(uint8_t byte) {
|
static void em4x50_reader_send_byte_with_parity(uint8_t byte) {
|
||||||
int parity = 0, bit = 0;
|
int parity = 0, bit = 0;
|
||||||
|
|
||||||
|
@ -537,8 +512,6 @@ static bool check_ack(bool bliw) {
|
||||||
|
|
||||||
if (check_pulse_length(get_pulse_length(), 2 * EM4X50_T_TAG_FULL_PERIOD)) {
|
if (check_pulse_length(get_pulse_length(), 2 * EM4X50_T_TAG_FULL_PERIOD)) {
|
||||||
|
|
||||||
//catch_samples();
|
|
||||||
|
|
||||||
// The received signal is either ACK or NAK.
|
// The received signal is either ACK or NAK.
|
||||||
|
|
||||||
if (check_pulse_length(get_pulse_length(), 2 * EM4X50_T_TAG_FULL_PERIOD)) {
|
if (check_pulse_length(get_pulse_length(), 2 * EM4X50_T_TAG_FULL_PERIOD)) {
|
||||||
|
@ -1245,7 +1218,7 @@ static void wait_cycles(int maxperiods) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// read single bit while simulating
|
// read single bit in simulation mode
|
||||||
static int em4x50_sim_read_bit(void) {
|
static int em4x50_sim_read_bit(void) {
|
||||||
|
|
||||||
int cycles = 0;
|
int cycles = 0;
|
||||||
|
@ -1292,7 +1265,7 @@ static int em4x50_sim_read_bit(void) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read byte in while simulation either with or without parity check (even)
|
// read byte in simulation mode either with or without parity check (even)
|
||||||
static bool em4x50_sim_read_byte(uint8_t *byte, bool paritycheck) {
|
static bool em4x50_sim_read_byte(uint8_t *byte, bool paritycheck) {
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
@ -1318,7 +1291,7 @@ static bool em4x50_sim_read_byte(uint8_t *byte, bool paritycheck) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read complete word while simulating
|
// read complete word in simulation mode
|
||||||
static bool em4x50_sim_read_word(uint32_t *word) {
|
static bool em4x50_sim_read_word(uint32_t *word) {
|
||||||
|
|
||||||
uint8_t stop_bit = 0;
|
uint8_t stop_bit = 0;
|
||||||
|
@ -1379,7 +1352,7 @@ static int check_rm_request(uint32_t *tag) {
|
||||||
return (bit != PM3_ETIMEOUT) ? PM3_SUCCESS : PM3_ETIMEOUT;
|
return (bit != PM3_ETIMEOUT) ? PM3_SUCCESS : PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send single listen window while simulating
|
// send single listen window in simulation mode
|
||||||
static int em4x50_sim_send_listen_window(uint32_t *tag) {
|
static int em4x50_sim_send_listen_window(uint32_t *tag) {
|
||||||
|
|
||||||
SHORT_COIL();
|
SHORT_COIL();
|
||||||
|
@ -1454,7 +1427,7 @@ static void em4x50_sim_send_nak(void) {
|
||||||
OPEN_COIL();
|
OPEN_COIL();
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard read mode process (simulation mode)
|
// standard read mode process (simulation mode)
|
||||||
static int em4x50_sim_handle_standard_read_command(uint32_t *tag) {
|
static int em4x50_sim_handle_standard_read_command(uint32_t *tag) {
|
||||||
|
|
||||||
int command = 0;
|
int command = 0;
|
||||||
|
@ -1560,13 +1533,10 @@ static int em4x50_sim_handle_login_command(uint32_t *tag) {
|
||||||
uint32_t password = 0;
|
uint32_t password = 0;
|
||||||
bool pwd = em4x50_sim_read_word(&password);
|
bool pwd = em4x50_sim_read_word(&password);
|
||||||
|
|
||||||
// signal that reader sent the password
|
|
||||||
LED_D_ON();
|
|
||||||
|
|
||||||
// processing pause time (corresponds to a "1" bit)
|
// processing pause time (corresponds to a "1" bit)
|
||||||
em4x50_sim_send_bit(1);
|
em4x50_sim_send_bit(1);
|
||||||
|
|
||||||
// empirically determined delay (to be examined seperately)
|
// empirically determined delay (to be checked in detail)
|
||||||
wait_cycles(1);
|
wait_cycles(1);
|
||||||
|
|
||||||
if (pwd && (password == reflect32(tag[EM4X50_DEVICE_PASSWORD]))) {
|
if (pwd && (password == reflect32(tag[EM4X50_DEVICE_PASSWORD]))) {
|
||||||
|
@ -1593,7 +1563,7 @@ static int em4x50_sim_handle_reset_command(uint32_t *tag) {
|
||||||
gLogin = false;
|
gLogin = false;
|
||||||
LED_A_OFF();
|
LED_A_OFF();
|
||||||
|
|
||||||
// wait for tinit
|
// wait for initialization (tinit)
|
||||||
wait_cycles(EM4X50_T_TAG_TINIT);
|
wait_cycles(EM4X50_T_TAG_TINIT);
|
||||||
|
|
||||||
// continue with standard read mode
|
// continue with standard read mode
|
||||||
|
@ -1681,7 +1651,7 @@ static int em4x50_sim_handle_write_command(uint32_t *tag) {
|
||||||
|
|
||||||
// EEPROM write time
|
// EEPROM write time
|
||||||
// strange: need some sort of 'waveform correction', otherwise ack signal
|
// strange: need some sort of 'waveform correction', otherwise ack signal
|
||||||
// will not be detected; sending a single "1" as last "bit"" of Twee
|
// will not be detected; sending a single "1" as last "bit" of Twee
|
||||||
// seems to solve the problem
|
// seems to solve the problem
|
||||||
wait_cycles(EM4X50_T_TAG_TWEE - EM4X50_T_TAG_FULL_PERIOD);
|
wait_cycles(EM4X50_T_TAG_TWEE - EM4X50_T_TAG_FULL_PERIOD);
|
||||||
em4x50_sim_send_bit(1);
|
em4x50_sim_send_bit(1);
|
||||||
|
@ -1775,7 +1745,6 @@ static int em4x50_sim_handle_writepwd_command(uint32_t *tag) {
|
||||||
// LED A -> operations that require authentication are possible
|
// LED A -> operations that require authentication are possible
|
||||||
// LED B -> standard read mode is active
|
// LED B -> standard read mode is active
|
||||||
// LED C -> command has been transmitted by reader
|
// LED C -> command has been transmitted by reader
|
||||||
// LED D -> password has been caught from reader
|
|
||||||
void em4x50_sim(uint32_t *password) {
|
void em4x50_sim(uint32_t *password) {
|
||||||
|
|
||||||
int command = PM3_ENODATA;
|
int command = PM3_ENODATA;
|
||||||
|
@ -1858,88 +1827,3 @@ void em4x50_sim(uint32_t *password) {
|
||||||
lf_finalize();
|
lf_finalize();
|
||||||
reply_ng(CMD_LF_EM4X50_SIM, command, NULL, 0);
|
reply_ng(CMD_LF_EM4X50_SIM, command, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void em4x50_test(em4x50_test_t *ett) {
|
|
||||||
|
|
||||||
int status = 0;
|
|
||||||
|
|
||||||
// set field on or off
|
|
||||||
if (ett->field != -1) {
|
|
||||||
em4x50_setup_read();
|
|
||||||
if (ett->field == 1) {
|
|
||||||
LED_A_ON();
|
|
||||||
} else {
|
|
||||||
HIGH(GPIO_SSC_DOUT);
|
|
||||||
LED_A_OFF();
|
|
||||||
}
|
|
||||||
status = ett->field;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check field status
|
|
||||||
if (ett->check_field) {
|
|
||||||
em4x50_setup_sim();
|
|
||||||
bool field_on = false;
|
|
||||||
while (BUTTON_PRESS() == false) {
|
|
||||||
|
|
||||||
if (!(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK)) {
|
|
||||||
if (field_on == false) {
|
|
||||||
Dbprintf("field on");
|
|
||||||
field_on = true;
|
|
||||||
}
|
|
||||||
} else if (AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK){
|
|
||||||
if (field_on == true) {
|
|
||||||
Dbprintf("field off");
|
|
||||||
field_on = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
status = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// timing values
|
|
||||||
if (ett->cycles != 0) {
|
|
||||||
uint32_t tval = 0;
|
|
||||||
uint32_t tvalhigh[ett->cycles];
|
|
||||||
uint32_t tvallow[ett->cycles];
|
|
||||||
|
|
||||||
em4x50_setup_sim();
|
|
||||||
while (AT91C_BASE_TC0->TC_CV > 0);
|
|
||||||
|
|
||||||
for (int t = 0; t < ett->cycles; t++) {
|
|
||||||
|
|
||||||
// field on -> high value
|
|
||||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG;
|
|
||||||
tval = AT91C_BASE_TC0->TC_CV;
|
|
||||||
while (!(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK));
|
|
||||||
tvalhigh[t] = AT91C_BASE_TC0->TC_CV - tval;
|
|
||||||
|
|
||||||
// filed off -> zero value
|
|
||||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG;
|
|
||||||
tval = AT91C_BASE_TC0->TC_CV;
|
|
||||||
while (AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK);
|
|
||||||
tvallow[t] = AT91C_BASE_TC0->TC_CV - tval;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int t = 0; t < ett->cycles; t++) {
|
|
||||||
Dbprintf("%03i %li %li", t, tvallow[t], tvalhigh[t]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// perform reset
|
|
||||||
if (ett->reset) {
|
|
||||||
em4x50_setup_read();
|
|
||||||
|
|
||||||
status = PM3_EFAILED;
|
|
||||||
if (get_signalproperties() && find_em4x50_tag()) {
|
|
||||||
|
|
||||||
if (reset() == PM3_SUCCESS) {
|
|
||||||
status = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lf_finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
reply_ng(CMD_LF_EM4X50_TEST, status, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
|
@ -22,6 +22,5 @@ void em4x50_login(uint32_t *password);
|
||||||
void em4x50_sim(uint32_t *password);
|
void em4x50_sim(uint32_t *password);
|
||||||
void em4x50_reader(void);
|
void em4x50_reader(void);
|
||||||
void em4x50_chk(uint8_t *filename);
|
void em4x50_chk(uint8_t *filename);
|
||||||
void em4x50_test(em4x50_test_t *ett);
|
|
||||||
|
|
||||||
#endif /* EM4X50_H */
|
#endif /* EM4X50_H */
|
||||||
|
|
|
@ -23,86 +23,6 @@
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static void write_gnuplot_config_file(int gHigh, int gLow) {
|
|
||||||
|
|
||||||
const char *fn = "../data/data.gnu";
|
|
||||||
FILE *fp = NULL;
|
|
||||||
|
|
||||||
if ((fp = fopen(fn, "w+")) == false) {
|
|
||||||
PrintAndLogEx(WARNING, "Fail, open file %s", fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp, "set term qt size 1400, 350 enhanced\n");
|
|
||||||
fprintf(fp, "set border 31 front linecolor rgb 'dark-grey' linewidth 1.000 dashtype solid\n");
|
|
||||||
fprintf(fp, "set xtics 0, 1 textcolor rgb 'dark-grey'\n");
|
|
||||||
fprintf(fp, "set ytics 0, 64 textcolor rgb 'dark-grey'\n");
|
|
||||||
fprintf(fp, "set title 'EM4x50 signal (amplitude vs time)'\n");
|
|
||||||
fprintf(fp, "set title font ',14' textcolor rgb 'white'\n");
|
|
||||||
fprintf(fp, "set xlabel 'time / ms'\n");
|
|
||||||
fprintf(fp, "set xlabel font ',12' textcolor rgb 'dark-grey'\n");
|
|
||||||
fprintf(fp, "set ylabel 'amplitude'\n");
|
|
||||||
fprintf(fp, "set ylabel font ',12' textcolor rgb 'dark-grey'\n");
|
|
||||||
fprintf(fp, "set key textcolor 'green'\n");
|
|
||||||
fprintf(fp, "set grid\n");
|
|
||||||
fprintf(fp, "#set time textcolor 'dark-grey'\n");
|
|
||||||
fprintf(fp, "plot [0:][-50:300] '../data/data.dat' u ($1/1000):2 w l linecolor 'green' title '500/4', '../data/data.dat' u ($1/1000):3 w l linecolor 'yellow' title 'gHigh = %i', '../data/data.dat' u ($1/1000):4 w l linecolor 'yellow' title 'gLow = %i'\n", gHigh, gLow);
|
|
||||||
fprintf(fp, "pause -1\n");
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void get_samples(void) {
|
|
||||||
|
|
||||||
int gHigh = 0, gLow = 0;
|
|
||||||
const char *fn = "../data/data.dat";
|
|
||||||
FILE *fp = NULL;
|
|
||||||
|
|
||||||
// download from BigBuf memory
|
|
||||||
uint8_t data[EM4X50_MAX_NO_SAMPLES + 2] = {0x0};
|
|
||||||
if (GetFromDevice(BIG_BUF, data, EM4X50_MAX_NO_SAMPLES + 2, 0, NULL, 0, NULL, 2500, false) == false) {
|
|
||||||
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fp = fopen(fn, "w+")) == false) {
|
|
||||||
PrintAndLogEx(WARNING, "Fail, open file %s", fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
gHigh = data[0];
|
|
||||||
gLow = data[1];
|
|
||||||
for (int i = 2; i < EM4X50_MAX_NO_SAMPLES + 2; i++) {
|
|
||||||
fprintf(fp, "%i %i %i %i\n", (i - 2) * 8, data[i], gHigh, gLow);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
write_gnuplot_config_file(gHigh, gLow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
static void get_time_samples(void) {
|
|
||||||
|
|
||||||
const char *fn = "../data/data.dat";
|
|
||||||
FILE *fp = NULL;
|
|
||||||
|
|
||||||
// download from BigBuf memory
|
|
||||||
uint32_t data[EM4X50_MAX_TIME_SAMPLES] = {0x0};
|
|
||||||
if (GetFromDevice(BIG_BUF, (uint8_t *)data, EM4X50_MAX_TIME_SAMPLES, 0, NULL, 0, NULL, 2500, false) == false) {
|
|
||||||
PrintAndLogEx(WARNING, "Fail, transfer from device time-out");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fp = fopen(fn, "w+")) == false) {
|
|
||||||
PrintAndLogEx(WARNING, "Fail, open file %s", fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < EM4X50_MAX_TIME_SAMPLES; i++) {
|
|
||||||
PrintAndLogEx(INFO, "%i %"PRIu32"", i, data[i]);
|
|
||||||
fprintf(fp, "%i %"PRIu32"\n", i, data[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void prepare_result(const uint8_t *data, int fwr, int lwr, em4x50_word_t *words) {
|
static void prepare_result(const uint8_t *data, int fwr, int lwr, em4x50_word_t *words) {
|
||||||
|
|
||||||
// restructure received result in "em4x50_word_t" structure
|
// restructure received result in "em4x50_word_t" structure
|
||||||
|
@ -423,8 +343,6 @@ int CmdEM4x50Login(const char *Cmd) {
|
||||||
else
|
else
|
||||||
PrintAndLogEx(FAILED, "Login " _RED_("failed"));
|
PrintAndLogEx(FAILED, "Login " _RED_("failed"));
|
||||||
|
|
||||||
get_samples();
|
|
||||||
|
|
||||||
return resp.status;
|
return resp.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1275,81 +1193,6 @@ int CmdEM4x50Sim(const char *Cmd) {
|
||||||
return resp.status;
|
return resp.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdEM4x50Test(const char *Cmd) {
|
|
||||||
CLIParserContext *ctx;
|
|
||||||
CLIParserInit(&ctx, "lf em 4x50 test",
|
|
||||||
"perform EM4x50 tests.",
|
|
||||||
"lf em 4x50 test --field on -> reader field on\n"
|
|
||||||
"lf em 4x50 test --field off -> reader field off\n"
|
|
||||||
"lf em 4x50 test --check -> check on/off status of reader field\n"
|
|
||||||
"lf em 4x50 test --cycles 100 -> measure time of 100 field cycles\n"
|
|
||||||
"lf em 4x50 test --reset -> intitiate reset command\n"
|
|
||||||
);
|
|
||||||
|
|
||||||
void *argtable[] = {
|
|
||||||
arg_param_begin,
|
|
||||||
arg_str0(NULL, "field", "on/off", "field on/off"),
|
|
||||||
arg_lit0(NULL, "check", "check if field is on or off"),
|
|
||||||
arg_int0(NULL, "cycles", "<dec>", "number of field cycles"),
|
|
||||||
arg_lit0(NULL, "reset", "initiates a manual reset command"),
|
|
||||||
arg_param_end
|
|
||||||
};
|
|
||||||
|
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
|
||||||
|
|
||||||
// option: field
|
|
||||||
int slen = 0;
|
|
||||||
char format[3] = {0};
|
|
||||||
CLIParamStrToBuf(arg_get_str(ctx, 1), (uint8_t *)format, sizeof(format), &slen);
|
|
||||||
em4x50_test_t ett = {.field = -1};
|
|
||||||
if (slen != 0) {
|
|
||||||
if (strcmp(format, "on") == 0) {
|
|
||||||
ett.field = 1;
|
|
||||||
} else if (strcmp(format, "off") == 0) {
|
|
||||||
ett.field = 0;
|
|
||||||
} else {
|
|
||||||
PrintAndLogEx(INFO, "Unknown option for --field: %s", format);
|
|
||||||
return PM3_ESOFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// option: check_field
|
|
||||||
ett.check_field = arg_get_lit(ctx, 2);
|
|
||||||
// option: cycles
|
|
||||||
ett.cycles = arg_get_int_def(ctx, 3, 0);
|
|
||||||
// option: reset
|
|
||||||
ett.reset = arg_get_lit(ctx, 4);
|
|
||||||
|
|
||||||
CLIParserFree(ctx);
|
|
||||||
|
|
||||||
// start
|
|
||||||
clearCommandBuffer();
|
|
||||||
PacketResponseNG resp;
|
|
||||||
SendCommandNG(CMD_LF_EM4X50_TEST, (uint8_t *)&ett, sizeof(ett));
|
|
||||||
WaitForResponse(CMD_LF_EM4X50_TEST, &resp);
|
|
||||||
|
|
||||||
// print response
|
|
||||||
if (resp.status == 1) {
|
|
||||||
if (ett.field == 1)
|
|
||||||
PrintAndLogEx(SUCCESS, "Field switched " _GREEN_("on"));
|
|
||||||
if (ett.check_field == 1)
|
|
||||||
PrintAndLogEx(SUCCESS, "Field status evaluated");
|
|
||||||
if (ett.reset == 1)
|
|
||||||
PrintAndLogEx(SUCCESS, "reset command " _GREEN_("ok"));
|
|
||||||
} else if (resp.status == 0) {
|
|
||||||
if (ett.field == 1)
|
|
||||||
PrintAndLogEx(SUCCESS, "Field switched " _GREEN_("off"));
|
|
||||||
if (ett.reset == 1)
|
|
||||||
PrintAndLogEx(SUCCESS, "reset command " _GREEN_("failed"));
|
|
||||||
} else if (resp.status == -1) {
|
|
||||||
PrintAndLogEx(INFO, "Nothing done");
|
|
||||||
} else {
|
|
||||||
PrintAndLogEx(FAILED, "Test call " _RED_("failed"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
{"help", CmdHelp, AlwaysAvailable, "This help"},
|
||||||
{"brute", CmdEM4x50Brute, IfPm3EM4x50, "guess password of EM4x50"},
|
{"brute", CmdEM4x50Brute, IfPm3EM4x50, "guess password of EM4x50"},
|
||||||
|
@ -1367,7 +1210,6 @@ static command_t CommandTable[] = {
|
||||||
{"eload", CmdEM4x50ELoad, IfPm3EM4x50, "upload dump of EM4x50 to emulator memory"},
|
{"eload", CmdEM4x50ELoad, IfPm3EM4x50, "upload dump of EM4x50 to emulator memory"},
|
||||||
{"esave", CmdEM4x50ESave, IfPm3EM4x50, "save emulator memory to file"},
|
{"esave", CmdEM4x50ESave, IfPm3EM4x50, "save emulator memory to file"},
|
||||||
{"eview", CmdEM4x50EView, IfPm3EM4x50, "view EM4x50 content in emulator memory"},
|
{"eview", CmdEM4x50EView, IfPm3EM4x50, "view EM4x50 content in emulator memory"},
|
||||||
{"test", CmdEM4x50Test, IfPm3EM4x50, "perform EM4x50 tests"},
|
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,5 @@ int CmdEM4x50ELoad(const char *Cmd);
|
||||||
int CmdEM4x50ESave(const char *Cmd);
|
int CmdEM4x50ESave(const char *Cmd);
|
||||||
int CmdEM4x50Chk(const char *Cmd);
|
int CmdEM4x50Chk(const char *Cmd);
|
||||||
int CmdEM4x50EView(const char *Cmd);
|
int CmdEM4x50EView(const char *Cmd);
|
||||||
int CmdEM4x50Test(const char *Cmd);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,8 +36,6 @@
|
||||||
// misc
|
// misc
|
||||||
#define TIMEOUT 2000
|
#define TIMEOUT 2000
|
||||||
#define DUMP_FILESIZE 136
|
#define DUMP_FILESIZE 136
|
||||||
#define EM4X50_MAX_NO_SAMPLES 1000
|
|
||||||
#define EM4X50_MAX_TIME_SAMPLES 1000
|
|
||||||
|
|
||||||
#define BYTES2UINT32(x) ((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | (x[3]))
|
#define BYTES2UINT32(x) ((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | (x[3]))
|
||||||
|
|
||||||
|
@ -50,13 +48,6 @@ typedef struct {
|
||||||
uint32_t addresses;
|
uint32_t addresses;
|
||||||
} PACKED em4x50_data_t;
|
} PACKED em4x50_data_t;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
bool check_field;
|
|
||||||
bool reset;
|
|
||||||
int field;
|
|
||||||
int cycles;
|
|
||||||
} PACKED em4x50_test_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t byte[4];
|
uint8_t byte[4];
|
||||||
} PACKED em4x50_word_t;
|
} PACKED em4x50_word_t;
|
||||||
|
|
|
@ -516,7 +516,6 @@ typedef struct {
|
||||||
#define CMD_LF_EM4X50_READER 0x0251
|
#define CMD_LF_EM4X50_READER 0x0251
|
||||||
#define CMD_LF_EM4X50_ESET 0x0252
|
#define CMD_LF_EM4X50_ESET 0x0252
|
||||||
#define CMD_LF_EM4X50_CHK 0x0253
|
#define CMD_LF_EM4X50_CHK 0x0253
|
||||||
#define CMD_LF_EM4X50_TEST 0x0254
|
|
||||||
#define CMD_LF_EM4X70_INFO 0x0260
|
#define CMD_LF_EM4X70_INFO 0x0260
|
||||||
#define CMD_LF_EM4X70_WRITE 0x0261
|
#define CMD_LF_EM4X70_WRITE 0x0261
|
||||||
#define CMD_LF_EM4X70_UNLOCK 0x0262
|
#define CMD_LF_EM4X70_UNLOCK 0x0262
|
||||||
|
|
Loading…
Reference in a new issue