renamed std_read -> stdread

This commit is contained in:
tharexde 2020-10-31 14:53:52 +01:00
parent 35a671d592
commit 098ca87c81
6 changed files with 19 additions and 31 deletions

View file

@ -1126,8 +1126,8 @@ static void PacketReceived(PacketCommandNG *packet) {
em4x50_sim();
break;
}
case CMD_LF_EM4X50_STD_READ: {
em4x50_std_read();
case CMD_LF_EM4X50_STDREAD: {
em4x50_stdread();
break;
}
case CMD_LF_EM4X50_ESET: {

View file

@ -122,22 +122,6 @@ static void em4x50_setup_sim(void) {
AT91C_BASE_PIOA->PIO_ODR = GPIO_SSC_CLK;
}
static void emlGetMem(uint32_t *words, size_t nowords) {
// read <nowords> words from emulator memory
uint8_t *em4x50_mem = BigBuf_get_EM_addr();
for (int i = 0; i < EM4X50_NO_WORDS; i++) {
for (int j = 0; j < 4; j++)
words[i] |= (em4x50_mem[4 * i + j]) << ((3 - j) * 8);
// lsb is needed (given format is msb)
words[i] = reflect32(words[i]);
}
}
// functions for "reader" use case
static bool get_signalproperties(void) {
@ -1346,6 +1330,7 @@ void em4x50_restore(em4x50_data_t *etd) {
int res = 0;
int start_word = 0;
uint8_t status = 0;
uint8_t *em4x50_mem = BigBuf_get_EM_addr();
uint32_t addresses = 0x00001F01; // from fwr = 1 to lwr = 31 (0x1F)
uint32_t words_client[EM4X50_NO_WORDS] = {0x0};
uint32_t words_read[EM4X50_NO_WORDS] = {0x0};
@ -1353,8 +1338,9 @@ void em4x50_restore(em4x50_data_t *etd) {
em4x50_setup_read();
// read data from emulator memory
emlGetMem(words_client, EM4X50_NO_WORDS);
for (int i = 0; i < EM4X50_NO_WORDS; i++)
words_client[i] = reflect32(bytes_to_num(em4x50_mem + (i * 4), 4));
// set gHigh and gLow
if (get_signalproperties() && find_em4x50_tag()) {
@ -1403,12 +1389,14 @@ void em4x50_sim(void) {
// simulate uploaded data in emulator memory
// (currently only a one-way communication is possible)
uint8_t *em4x50_mem = BigBuf_get_EM_addr();
uint32_t words[EM4X50_NO_WORDS] = {0x0};
em4x50_setup_sim();
// read data from emulator memory
emlGetMem(words, EM4X50_NO_WORDS);
for (int i = 0; i < EM4X50_NO_WORDS; i++)
words[i] = reflect32(bytes_to_num(em4x50_mem + (i * 4), 4));
// extract control data
int fwr = words[CONFIG_BLOCK] & 0xFF; // first word read
@ -1437,7 +1425,7 @@ void em4x50_sim(void) {
reply_ng(CMD_LF_EM4X50_SIM, 1, 0, 0);
}
void em4x50_std_read(void) {
void em4x50_stdread(void) {
// reads data that tag transmits "voluntarily" -> standard read mode
@ -1452,5 +1440,5 @@ void em4x50_std_read(void) {
LOW(GPIO_SSC_DOUT);
lf_finalize();
reply_ng(CMD_LF_EM4X50_STD_READ, now, (uint8_t *)words, 4 * now);
reply_ng(CMD_LF_EM4X50_STDREAD, now, (uint8_t *)words, 4 * now);
}

View file

@ -30,6 +30,6 @@ void em4x50_reset(void);
void em4x50_watch(void);
void em4x50_restore(em4x50_data_t *etd);
void em4x50_sim(void);
void em4x50_std_read(void);
void em4x50_stdread(void);
#endif /* EM4X50_H */

View file

@ -663,7 +663,7 @@ static command_t CommandTable[] = {
{"4x50_watch", CmdEM4x50Watch, IfPm3EM4x50, "read EM4x50 continously"},
{"4x50_restore",CmdEM4x50Restore, IfPm3EM4x50, "restore EM4x50 dump to tag"},
{"4x50_sim", CmdEM4x50Sim, IfPm3EM4x50, "simulate single EM4x50 word (uid)"},
{"4x50_std_read",CmdEM4x50StdRead, IfPm3EM4x50, "show standard read mode data of EM4x50 tag"},
{"4x50_stdread",CmdEM4x50StdRead, IfPm3EM4x50, "show standard read mode data of EM4x50 tag"},
{"4x50_eload", CmdEM4x50ELoad, IfPm3EM4x50, "load a binary dump into emulator memory"},
{"4x50_esave", CmdEM4x50ESave, IfPm3EM4x50, "save emulator memory to file"},
{NULL, NULL, NULL, NULL}

View file

@ -175,7 +175,7 @@ static int usage_lf_em4x50_sim(void) {
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
}
static int usage_lf_em4x50_std_read(void) {
static int usage_lf_em4x50_stdread(void) {
PrintAndLogEx(NORMAL, "Show standard read mode data of EM4x50 tag. Tag must be on antenna.");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Usage: lf em 4x50_std_read [h]");
@ -1168,7 +1168,7 @@ int CmdEM4x50StdRead(const char *Cmd) {
switch (tolower(param_getchar(Cmd, cmdp))) {
case 'h':
return usage_lf_em4x50_std_read();
return usage_lf_em4x50_stdread();
default:
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
@ -1178,12 +1178,12 @@ int CmdEM4x50StdRead(const char *Cmd) {
}
if (errors)
return usage_lf_em4x50_std_read();
return usage_lf_em4x50_stdread();
// start
clearCommandBuffer();
SendCommandNG(CMD_LF_EM4X50_STD_READ, 0, 0);
if (!WaitForResponseTimeout(CMD_LF_EM4X50_STD_READ, &resp, TIMEOUT)) {
SendCommandNG(CMD_LF_EM4X50_STDREAD, 0, 0);
if (!WaitForResponseTimeout(CMD_LF_EM4X50_STDREAD, &resp, TIMEOUT)) {
PrintAndLogEx(WARNING, "Timeout while waiting for reply.");
return PM3_ETIMEOUT;
}

View file

@ -514,7 +514,7 @@ typedef struct {
#define CMD_LF_EM4X50_WATCH 0x0248
#define CMD_LF_EM4X50_RESTORE 0x0249
#define CMD_LF_EM4X50_SIM 0x0250
#define CMD_LF_EM4X50_STD_READ 0x0251
#define CMD_LF_EM4X50_STDREAD 0x0251
#define CMD_LF_EM4X50_ESET 0x0252
// Sampling configuration for LF reader/sniffer
#define CMD_LF_SAMPLING_SET_CONFIG 0x021D