mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
CHG: rename of global variable
CHG: adjusted outputs.
This commit is contained in:
parent
2e3308b257
commit
2aa9372534
3 changed files with 36 additions and 40 deletions
|
@ -46,9 +46,9 @@ struct receiver_arg {
|
||||||
|
|
||||||
void SendCommand(UsbCommand *c) {
|
void SendCommand(UsbCommand *c) {
|
||||||
#if 0
|
#if 0
|
||||||
pthread_mutex_lock(&print_lock);
|
//pthread_mutex_lock(&print_lock);
|
||||||
PrintAndLogEx(NORMAL, "Sending %d bytes\n", sizeof(UsbCommand));
|
PrintAndLogEx(NORMAL, "Sending %d bytes\n", sizeof(UsbCommand));
|
||||||
pthread_mutex_unlock(&print_lock);
|
//pthread_mutex_unlock(&print_lock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (offline) {
|
if (offline) {
|
||||||
|
@ -79,6 +79,7 @@ static void showBanner(void){
|
||||||
printf("\nKeep iceman fork alive with a donation! https://paypal.me/iceman1001/");
|
printf("\nKeep iceman fork alive with a donation! https://paypal.me/iceman1001/");
|
||||||
printf("\nMONERO: 43mNJLpgBVaTvyZmX9ajcohpvVkaRy1kbZPm8tqAb7itZgfuYecgkRF36rXrKFUkwEGeZedPsASRxgv4HPBHvJwyJdyvQuP");
|
printf("\nMONERO: 43mNJLpgBVaTvyZmX9ajcohpvVkaRy1kbZPm8tqAb7itZgfuYecgkRF36rXrKFUkwEGeZedPsASRxgv4HPBHvJwyJdyvQuP");
|
||||||
printf("\n\n\n");
|
printf("\n\n\n");
|
||||||
|
fflush(NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -174,6 +175,8 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
|
||||||
FILE *sf = NULL;
|
FILE *sf = NULL;
|
||||||
char script_cmd_buf[256] = {0x00}; // iceman, needs lua script the same file_path_buffer as the rest
|
char script_cmd_buf[256] = {0x00}; // iceman, needs lua script the same file_path_buffer as the rest
|
||||||
|
|
||||||
|
PrintAndLogEx(SUCCESS, "ISATTY/STDIN_FILENO == %s\n", (stdinOnPipe)?"true":"false");
|
||||||
|
|
||||||
if (usb_present) {
|
if (usb_present) {
|
||||||
rarg.run = 1;
|
rarg.run = 1;
|
||||||
pthread_create(&reader_thread, NULL, &uart_receiver, &rarg);
|
pthread_create(&reader_thread, NULL, &uart_receiver, &rarg);
|
||||||
|
@ -185,19 +188,16 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (script_cmds_file) {
|
if (script_cmds_file) {
|
||||||
sf = fopen(script_cmds_file, "r");
|
|
||||||
|
|
||||||
if (sf) {
|
sf = fopen(script_cmds_file, "r");
|
||||||
pthread_mutex_lock(&print_lock);
|
if (sf)
|
||||||
PrintAndLogEx(SUCCESS, "executing commands from file: %s\n", script_cmds_file);
|
PrintAndLogEx(SUCCESS, "executing commands from file: %s\n", script_cmds_file);
|
||||||
pthread_mutex_unlock(&print_lock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
read_history(".history");
|
read_history(".history");
|
||||||
|
|
||||||
// loops every time enter is pressed...
|
// loops every time enter is pressed...
|
||||||
while(1) {
|
while (1) {
|
||||||
|
|
||||||
// this should hook up the PM3 again.
|
// this should hook up the PM3 again.
|
||||||
if (offline) {
|
if (offline) {
|
||||||
|
@ -220,27 +220,27 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
|
||||||
// If there is a script file
|
// If there is a script file
|
||||||
if (sf) {
|
if (sf) {
|
||||||
|
|
||||||
|
// clear array
|
||||||
memset(script_cmd_buf, 0, sizeof(script_cmd_buf));
|
memset(script_cmd_buf, 0, sizeof(script_cmd_buf));
|
||||||
|
|
||||||
|
// read script file
|
||||||
if (!fgets(script_cmd_buf, sizeof(script_cmd_buf), sf)) {
|
if (!fgets(script_cmd_buf, sizeof(script_cmd_buf), sf)) {
|
||||||
fclose(sf);
|
fclose(sf);
|
||||||
sf = NULL;
|
sf = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// remove linebreaks
|
||||||
strcleanrn(script_cmd_buf, sizeof(script_cmd_buf));
|
strcleanrn(script_cmd_buf, sizeof(script_cmd_buf));
|
||||||
|
|
||||||
if ((cmd = strmcopy(script_cmd_buf)) != NULL) {
|
if ((cmd = strmcopy(script_cmd_buf)) != NULL)
|
||||||
pthread_mutex_lock(&print_lock);
|
PrintAndLogEx(NORMAL, PROXPROMPT"%s\n", cmd);
|
||||||
printf(PROXPROMPT"%s\n", cmd);
|
|
||||||
pthread_mutex_unlock(&print_lock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If there is a script command
|
// If there is a script command
|
||||||
if (execCommand){
|
if (execCommand){
|
||||||
if ((cmd = strmcopy(script_cmd)) != NULL) {
|
|
||||||
pthread_mutex_lock(&print_lock);
|
if ((cmd = strmcopy(script_cmd)) != NULL)
|
||||||
printf(PROXPROMPT"%s\n", cmd);
|
PrintAndLogEx(NORMAL, PROXPROMPT"%s", cmd);
|
||||||
pthread_mutex_unlock(&print_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
execCommand = false;
|
execCommand = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -250,24 +250,23 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
|
||||||
|
|
||||||
// if there is a pipe from stdin
|
// if there is a pipe from stdin
|
||||||
if (stdinOnPipe) {
|
if (stdinOnPipe) {
|
||||||
|
|
||||||
|
// clear array
|
||||||
memset(script_cmd_buf, 0, sizeof(script_cmd_buf));
|
memset(script_cmd_buf, 0, sizeof(script_cmd_buf));
|
||||||
|
// get
|
||||||
if (!fgets(script_cmd_buf, sizeof(script_cmd_buf), stdin)) {
|
if (!fgets(script_cmd_buf, sizeof(script_cmd_buf), stdin)) {
|
||||||
pthread_mutex_lock(&print_lock);
|
PrintAndLogEx(ERROR, "STDIN unexpected end, exit...");
|
||||||
PrintAndLogEx(NORMAL, "\n[!] stdin end, exit...\n");
|
|
||||||
pthread_mutex_unlock(&print_lock);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// remove linebreaks
|
||||||
strcleanrn(script_cmd_buf, sizeof(script_cmd_buf));
|
strcleanrn(script_cmd_buf, sizeof(script_cmd_buf));
|
||||||
|
|
||||||
if ((cmd = strmcopy(script_cmd_buf)) != NULL) {
|
if ((cmd = strmcopy(script_cmd_buf)) != NULL)
|
||||||
pthread_mutex_lock(&print_lock);
|
PrintAndLogEx(NORMAL, PROXPROMPT"%s", cmd);
|
||||||
PrintAndLogEx(NORMAL, PROXPROMPT"%s\n", cmd);
|
|
||||||
pthread_mutex_unlock(&print_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// read command from command prompt
|
|
||||||
cmd = readline(PROXPROMPT);
|
cmd = readline(PROXPROMPT);
|
||||||
|
fflush(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,12 +290,10 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
|
||||||
free(cmd);
|
free(cmd);
|
||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
} else {
|
} else {
|
||||||
pthread_mutex_lock(&print_lock);
|
|
||||||
PrintAndLogEx(NORMAL, "\n");
|
PrintAndLogEx(NORMAL, "\n");
|
||||||
pthread_mutex_unlock(&print_lock);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} // end while
|
||||||
|
|
||||||
if (sf)
|
if (sf)
|
||||||
fclose(sf);
|
fclose(sf);
|
||||||
|
@ -379,8 +376,6 @@ int main(int argc, char* argv[]) {
|
||||||
char *script_cmds_file = NULL;
|
char *script_cmds_file = NULL;
|
||||||
char *script_cmd = NULL;
|
char *script_cmd = NULL;
|
||||||
|
|
||||||
// Must be before the first PrintAndLog call, for rl_redisplay
|
|
||||||
//rl_initialize();
|
|
||||||
/* initialize history */
|
/* initialize history */
|
||||||
using_history();
|
using_history();
|
||||||
|
|
||||||
|
@ -410,8 +405,8 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
// flush output
|
// flush output
|
||||||
if(strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "-flush") == 0){
|
if(strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "-flush") == 0){
|
||||||
PrintAndLogEx(NORMAL, "Output will be flushed after every print.\n");
|
g_flushAfterWrite = 1;
|
||||||
flushAfterWrite = 1;
|
PrintAndLogEx(INFO, "Output will be flushed after every print.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for comport
|
// wait for comport
|
||||||
|
@ -436,7 +431,7 @@ int main(int argc, char* argv[]) {
|
||||||
if (executeCommand){
|
if (executeCommand){
|
||||||
script_cmd = argv[argc - 1];
|
script_cmd = argv[argc - 1];
|
||||||
|
|
||||||
while(script_cmd[strlen(script_cmd) - 1] == ' ')
|
while (script_cmd[strlen(script_cmd) - 1] == ' ')
|
||||||
script_cmd[strlen(script_cmd) - 1] = 0x00;
|
script_cmd[strlen(script_cmd) - 1] = 0x00;
|
||||||
|
|
||||||
if (strlen(script_cmd) == 0) {
|
if (strlen(script_cmd) == 0) {
|
||||||
|
@ -507,6 +502,7 @@ int main(int argc, char* argv[]) {
|
||||||
offline = 0;
|
offline = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fflush(NULL);
|
||||||
// create a mutex to avoid interlacing print commands from our different threads
|
// create a mutex to avoid interlacing print commands from our different threads
|
||||||
pthread_mutex_init(&print_lock, NULL);
|
pthread_mutex_init(&print_lock, NULL);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
double CursorScaleFactor = 1;
|
double CursorScaleFactor = 1;
|
||||||
int PlotGridX=0, PlotGridY=0, PlotGridXdefault= 64, PlotGridYdefault= 64, CursorCPos= 0, CursorDPos= 0;
|
int PlotGridX=0, PlotGridY=0, PlotGridXdefault= 64, PlotGridYdefault= 64, CursorCPos= 0, CursorDPos= 0;
|
||||||
int offline;
|
int offline;
|
||||||
int flushAfterWrite = 0; //buzzy
|
int g_flushAfterWrite = 0; //buzzy
|
||||||
int GridOffset = 0;
|
int GridOffset = 0;
|
||||||
bool GridLocked = false;
|
bool GridLocked = false;
|
||||||
bool showDemod = true;
|
bool showDemod = true;
|
||||||
|
@ -159,7 +159,7 @@ void PrintAndLog(char *fmt, ...) {
|
||||||
}
|
}
|
||||||
va_end(argptr2);
|
va_end(argptr2);
|
||||||
|
|
||||||
if (flushAfterWrite == 1) {
|
if (g_flushAfterWrite == 1) {
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
}
|
}
|
||||||
//release lock
|
//release lock
|
||||||
|
|
|
@ -42,11 +42,11 @@ extern void SetLogFilename(char *fn);
|
||||||
|
|
||||||
extern double CursorScaleFactor;
|
extern double CursorScaleFactor;
|
||||||
extern int PlotGridX, PlotGridY, PlotGridXdefault, PlotGridYdefault, CursorCPos, CursorDPos, GridOffset;
|
extern int PlotGridX, PlotGridY, PlotGridXdefault, PlotGridYdefault, CursorCPos, CursorDPos, GridOffset;
|
||||||
extern int offline;
|
|
||||||
extern int flushAfterWrite; //buzzy
|
|
||||||
extern bool GridLocked;
|
extern bool GridLocked;
|
||||||
extern bool showDemod;
|
extern bool showDemod;
|
||||||
|
|
||||||
|
extern int offline;
|
||||||
|
extern int g_flushAfterWrite; //buzzy
|
||||||
//extern uint8_t g_debugMode;
|
//extern uint8_t g_debugMode;
|
||||||
|
|
||||||
extern pthread_mutex_t print_lock;
|
extern pthread_mutex_t print_lock;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue