mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
SendCommandOLD: cmdhw
This commit is contained in:
parent
9bd59a8d40
commit
7dbd12ad27
2 changed files with 43 additions and 49 deletions
|
@ -308,65 +308,58 @@ static void lookupChipID(uint32_t iChipID, uint32_t mem_used) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdDetectReader(const char *Cmd) {
|
static int CmdDetectReader(const char *Cmd) {
|
||||||
PacketCommandOLD c = {CMD_LISTEN_READER_FIELD, {0, 0, 0}, {{0}}};
|
uint16_t arg = 0;
|
||||||
// 'l' means LF - 125/134 kHz
|
// 'l' means LF - 125/134 kHz
|
||||||
if (*Cmd == 'l') {
|
if (*Cmd == 'l') {
|
||||||
c.arg[0] = 1;
|
arg = 1;
|
||||||
} else if (*Cmd == 'h') {
|
} else if (*Cmd == 'h') {
|
||||||
c.arg[0] = 2;
|
arg = 2;
|
||||||
} else if (*Cmd != '\0') {
|
} else if (*Cmd != '\0') {
|
||||||
PrintAndLogEx(NORMAL, "use 'detectreader' or 'detectreader l' or 'detectreader h'");
|
PrintAndLogEx(NORMAL, "use 'detectreader' or 'detectreader l' or 'detectreader h'");
|
||||||
return 0;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommandOLD(CMD_LISTEN_READER_FIELD, arg, 0, 0, NULL, 0);
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ## FPGA Control
|
// ## FPGA Control
|
||||||
static int CmdFPGAOff(const char *Cmd) {
|
static int CmdFPGAOff(const char *Cmd) {
|
||||||
(void)Cmd; // Cmd is not used so far
|
(void)Cmd; // Cmd is not used so far
|
||||||
PacketCommandOLD c = {CMD_FPGA_MAJOR_MODE_OFF, {0, 0, 0}, {{0}}};
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommandOLD(CMD_FPGA_MAJOR_MODE_OFF, 0, 0, 0, NULL, 0);
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_LCD
|
#ifdef WITH_LCD
|
||||||
static int CmdLCD(const char *Cmd) {
|
static int CmdLCD(const char *Cmd) {
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
PacketCommandOLD c = {CMD_LCD, {0, 0, 0}, {{0}}};
|
|
||||||
sscanf(Cmd, "%x %d", &i, &j);
|
sscanf(Cmd, "%x %d", &i, &j);
|
||||||
while (j--) {
|
while (j--) {
|
||||||
c.arg[0] = i & 0x1ff;
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommandOLD(CMD_LCD, i & 0x1ff, 0, 0, NULL, 0);
|
||||||
}
|
}
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdLCDReset(const char *Cmd) {
|
static int CmdLCDReset(const char *Cmd) {
|
||||||
PacketCommandOLD c = {CMD_LCD_RESET, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommandOLD(CMD_LCD_RESET, strtol(Cmd, NULL, 0), 0, 0, NULL, 0);
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int CmdReadmem(const char *Cmd) {
|
static int CmdReadmem(const char *Cmd) {
|
||||||
PacketCommandOLD c = {CMD_READ_MEM, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommandOLD(CMD_READ_MEM, strtol(Cmd, NULL, 0), 0, 0, NULL, 0);
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdReset(const char *Cmd) {
|
static int CmdReset(const char *Cmd) {
|
||||||
(void)Cmd; // Cmd is not used so far
|
(void)Cmd; // Cmd is not used so far
|
||||||
PacketCommandOLD c = {CMD_HARDWARE_RESET, {0, 0, 0}, {{0}}};
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommandOLD(CMD_HARDWARE_RESET, 0, 0, 0, NULL, 0);
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -374,35 +367,38 @@ static int CmdReset(const char *Cmd) {
|
||||||
* 600kHz.
|
* 600kHz.
|
||||||
*/
|
*/
|
||||||
static int CmdSetDivisor(const char *Cmd) {
|
static int CmdSetDivisor(const char *Cmd) {
|
||||||
PacketCommandOLD c = {CMD_SET_LF_DIVISOR, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
uint16_t arg = strtol(Cmd, NULL, 0);
|
||||||
|
|
||||||
if (c.arg[0] < 19 || c.arg[0] > 255) {
|
if (arg < 19 || arg > 255) {
|
||||||
PrintAndLogEx(NORMAL, "divisor must be between 19 and 255");
|
PrintAndLogEx(NORMAL, "divisor must be between 19 and 255");
|
||||||
return 1;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
// 12 000 000 (12Mhz)
|
// 12 000 000 (12Mhz)
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommandOLD(CMD_SET_LF_DIVISOR, arg, 0, 0, NULL, 0);
|
||||||
PrintAndLogEx(NORMAL, "Divisor set, expected %.1f KHz", ((double)12000 / (c.arg[0] + 1)));
|
PrintAndLogEx(NORMAL, "Divisor set, expected %.1f KHz", ((double)12000 / (arg + 1)));
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdSetMux(const char *Cmd) {
|
static int CmdSetMux(const char *Cmd) {
|
||||||
|
|
||||||
if (strlen(Cmd) < 5) {
|
if (strlen(Cmd) < 5) {
|
||||||
PrintAndLogEx(NORMAL, "expected: lopkd | loraw | hipkd | hiraw");
|
PrintAndLogEx(NORMAL, "expected: lopkd | loraw | hipkd | hiraw");
|
||||||
return 1;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketCommandOLD c = {CMD_SET_ADC_MUX, {0, 0, 0}, {{0}}};
|
uint16_t arg = 0;
|
||||||
|
if (strcmp(Cmd, "lopkd") == 0) arg = 0;
|
||||||
if (strcmp(Cmd, "lopkd") == 0) c.arg[0] = 0;
|
else if (strcmp(Cmd, "loraw") == 0) arg = 1;
|
||||||
else if (strcmp(Cmd, "loraw") == 0) c.arg[0] = 1;
|
else if (strcmp(Cmd, "hipkd") == 0) arg = 2;
|
||||||
else if (strcmp(Cmd, "hipkd") == 0) c.arg[0] = 2;
|
else if (strcmp(Cmd, "hiraw") == 0) arg = 3;
|
||||||
else if (strcmp(Cmd, "hiraw") == 0) c.arg[0] = 3;
|
else {
|
||||||
|
PrintAndLogEx(NORMAL, "expected: lopkd | loraw | hipkd | hiraw");
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommandOLD(CMD_SET_ADC_MUX, arg, 0, 0, NULL, 0);
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdTune(const char *Cmd) {
|
static int CmdTune(const char *Cmd) {
|
||||||
|
@ -412,7 +408,7 @@ static int CmdTune(const char *Cmd) {
|
||||||
static int CmdVersion(const char *Cmd) {
|
static int CmdVersion(const char *Cmd) {
|
||||||
(void)Cmd; // Cmd is not used so far
|
(void)Cmd; // Cmd is not used so far
|
||||||
pm3_version(true);
|
pm3_version(true);
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdStatus(const char *Cmd) {
|
static int CmdStatus(const char *Cmd) {
|
||||||
|
@ -422,7 +418,7 @@ static int CmdStatus(const char *Cmd) {
|
||||||
SendCommandOLD(CMD_STATUS, 0, 0, 0, NULL, 0);
|
SendCommandOLD(CMD_STATUS, 0, 0, 0, NULL, 0);
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1900))
|
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1900))
|
||||||
PrintAndLogEx(NORMAL, "Status command failed. USB Speed Test timed out");
|
PrintAndLogEx(NORMAL, "Status command failed. USB Speed Test timed out");
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdPing(const char *Cmd) {
|
static int CmdPing(const char *Cmd) {
|
||||||
|
@ -434,7 +430,7 @@ static int CmdPing(const char *Cmd) {
|
||||||
PrintAndLogEx(NORMAL, "Ping " _GREEN_("successful"));
|
PrintAndLogEx(NORMAL, "Ping " _GREEN_("successful"));
|
||||||
else
|
else
|
||||||
PrintAndLogEx(NORMAL, "Ping " _RED_("failed"));
|
PrintAndLogEx(NORMAL, "Ping " _RED_("failed"));
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdPingNG(const char *Cmd) {
|
static int CmdPingNG(const char *Cmd) {
|
||||||
|
@ -455,7 +451,7 @@ static int CmdPingNG(const char *Cmd) {
|
||||||
PrintAndLogEx(NORMAL, "PingNG response received, content is %s", error ? _RED_("NOT ok") : _GREEN_("ok"));
|
PrintAndLogEx(NORMAL, "PingNG response received, content is %s", error ? _RED_("NOT ok") : _GREEN_("ok"));
|
||||||
} else
|
} else
|
||||||
PrintAndLogEx(NORMAL, "PingNG response " _RED_("timeout"));
|
PrintAndLogEx(NORMAL, "PingNG response " _RED_("timeout"));
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
|
@ -481,22 +477,20 @@ static command_t CommandTable[] = {
|
||||||
static int CmdHelp(const char *Cmd) {
|
static int CmdHelp(const char *Cmd) {
|
||||||
(void)Cmd; // Cmd is not used so far
|
(void)Cmd; // Cmd is not used so far
|
||||||
CmdsHelp(CommandTable);
|
CmdsHelp(CommandTable);
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdHW(const char *Cmd) {
|
int CmdHW(const char *Cmd) {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
CmdsParse(CommandTable, Cmd);
|
return CmdsParse(CommandTable, Cmd);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pm3_version(bool verbose) {
|
void pm3_version(bool verbose) {
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
return;
|
return;
|
||||||
PacketCommandOLD c = {CMD_VERSION, {0, 0, 0}, {{0}}};
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommandOLD(CMD_VERSION, 0, 0, 0, NULL, 0);
|
||||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
|
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
|
||||||
#ifdef __WIN32
|
#ifdef __WIN32
|
||||||
PrintAndLogEx(NORMAL, "\n [ Proxmark3 RFID instrument ]\n");
|
PrintAndLogEx(NORMAL, "\n [ Proxmark3 RFID instrument ]\n");
|
||||||
|
|
|
@ -408,13 +408,13 @@ __attribute__((force_align_arg_pointer))
|
||||||
if (txBufferNGLen) { // NG packet
|
if (txBufferNGLen) { // NG packet
|
||||||
if (!uart_send(sp, (uint8_t *) &txBufferNG, txBufferNGLen)) {
|
if (!uart_send(sp, (uint8_t *) &txBufferNG, txBufferNGLen)) {
|
||||||
//counter_to_offline++;
|
//counter_to_offline++;
|
||||||
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device" _RED_("failed"));
|
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device " _RED_("failed"));
|
||||||
}
|
}
|
||||||
txBufferNGLen = 0;
|
txBufferNGLen = 0;
|
||||||
} else {
|
} else {
|
||||||
if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(PacketCommandOLD))) {
|
if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(PacketCommandOLD))) {
|
||||||
//counter_to_offline++;
|
//counter_to_offline++;
|
||||||
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device" _RED_("failed"));
|
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device " _RED_("failed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txBuffer_pending = false;
|
txBuffer_pending = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue