- Restored the 'reset' command

- Linux client: detects offline mode and blocks commands which need a connected Proxmark3 (still do to on Windows)
This commit is contained in:
edouard@lafargue.name 2009-04-27 19:56:43 +00:00
parent 0e25ae1102
commit d722c4ce78
7 changed files with 59 additions and 33 deletions

View file

@ -704,6 +704,7 @@ void UsbPacketReceived(BYTE *packet, int len)
#endif #endif
case CMD_SETUP_WRITE: case CMD_SETUP_WRITE:
case CMD_FINISH_WRITE: case CMD_FINISH_WRITE:
case CMD_HARDWARE_RESET:
USB_D_PLUS_PULLUP_OFF(); USB_D_PLUS_PULLUP_OFF();
SpinDelay(1000); SpinDelay(1000);
SpinDelay(1000); SpinDelay(1000);
@ -713,6 +714,7 @@ void UsbPacketReceived(BYTE *packet, int len)
} }
break; break;
default: default:
DbpString("unknown command"); DbpString("unknown command");
break; break;

View file

@ -10,6 +10,7 @@ int GraphBuffer[MAX_GRAPH_TRACE_LEN];
int GraphTraceLen; int GraphTraceLen;
double CursorScaleFactor; double CursorScaleFactor;
int CommandFinished; int CommandFinished;
int offline;
static char *logfilename = "proxmark3.log"; static char *logfilename = "proxmark3.log";

View file

@ -14,6 +14,7 @@ extern int GraphBuffer[MAX_GRAPH_TRACE_LEN];
extern int GraphTraceLen; extern int GraphTraceLen;
extern double CursorScaleFactor; extern double CursorScaleFactor;
extern int CommandFinished; extern int CommandFinished;
extern int offline;
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -86,8 +86,10 @@ int main(int argc, char **argv)
if (!(devh = OpenProxmark(1))) { if (!(devh = OpenProxmark(1))) {
fprintf(stderr,"PROXMARK3: NOT FOUND!\n"); fprintf(stderr,"PROXMARK3: NOT FOUND!\n");
marg.usb_present = 0; marg.usb_present = 0;
offline = 1;
} else { } else {
marg.usb_present = 1; marg.usb_present = 1;
offline = 0;
} }
pthread_create(&main_loop_t, NULL, &main_loop, &marg); pthread_create(&main_loop_t, NULL, &main_loop, &marg);

View file

@ -42,6 +42,14 @@ static void GetFromBigBuf(BYTE *dest, int bytes)
} }
} }
static void CmdReset(char *str)
{
UsbCommand c;
c.cmd = CMD_HARDWARE_RESET;
SendCommand(&c, FALSE);
}
static void CmdQuit(char *str) static void CmdQuit(char *str)
{ {
exit(0); exit(0);
@ -1829,6 +1837,8 @@ static void CmdLcd(char *str)
} }
} }
static void CmdTest(char *str) static void CmdTest(char *str)
{ {
} }
@ -1918,7 +1928,8 @@ static struct {
"lcd", CmdLcd,0, "Send command/data to LCD", "lcd", CmdLcd,0, "Send command/data to LCD",
"setlfdivisor", CmdSetDivisor,0, "Drive LF antenna at 12Mhz/(divisor+1)", "setlfdivisor", CmdSetDivisor,0, "Drive LF antenna at 12Mhz/(divisor+1)",
"sweeplf", CmdSweepLF,0, "Sweep through LF freq range and store results in buffer", "sweeplf", CmdSweepLF,0, "Sweep through LF freq range and store results in buffer",
"quit", CmdQuit,0, "quit program" "reset", CmdReset,0, "Reset the Proxmark3",
"quit", CmdQuit,1, "quit program"
}; };
@ -1933,8 +1944,10 @@ void CommandReceived(char *cmd)
PrintToScrollback("> %s", cmd); PrintToScrollback("> %s", cmd);
if(strcmp(cmd, "help")==0) { if(strcmp(cmd, "help")==0) {
if (offline) PrintToScrollback("Operating in OFFLINE mode (no device connected)");
PrintToScrollback("\r\nAvailable commands:"); PrintToScrollback("\r\nAvailable commands:");
for(i = 0; i < sizeof(CommandTable) / sizeof(CommandTable[0]); i++) { for(i = 0; i < sizeof(CommandTable) / sizeof(CommandTable[0]); i++) {
if (offline && (CommandTable[i].offline==0)) continue;
char line[256]; char line[256];
memset(line, ' ', sizeof(line)); memset(line, ' ', sizeof(line));
strcpy(line+2, CommandTable[i].name); strcpy(line+2, CommandTable[i].name);
@ -1956,6 +1969,10 @@ void CommandReceived(char *cmd)
while(*cmd == ' ') { while(*cmd == ' ') {
cmd++; cmd++;
} }
if (offline && (CommandTable[i].offline==0)) {
PrintToScrollback("Offline mode, cannot use this command.");
return;
}
(CommandTable[i].handler)(cmd); (CommandTable[i].handler)(cmd);
return; return;
} }

View file

@ -33,6 +33,7 @@ void dbp(char *str, ...)
int GraphBuffer[MAX_GRAPH_TRACE_LEN]; int GraphBuffer[MAX_GRAPH_TRACE_LEN];
int GraphTraceLen; int GraphTraceLen;
int offline; // Whether the GUI operates in Offline mode.
HPEN GreyPen, GreenPen, WhitePen, YellowPen; HPEN GreyPen, GreenPen, WhitePen, YellowPen;
HBRUSH GreenBrush, YellowBrush; HBRUSH GreenBrush, YellowBrush;

View file

@ -19,6 +19,8 @@ extern int GraphBuffer[MAX_GRAPH_TRACE_LEN];
extern int GraphTraceLen; extern int GraphTraceLen;
extern double CursorScaleFactor; extern double CursorScaleFactor;
extern int CommandFinished; extern int CommandFinished;
extern int offline; // Set to 1 if the proxmark is offline
// command.cpp // command.cpp
void CommandReceived(char *cmd); void CommandReceived(char *cmd);