chg: textual, and increase cmds receive buffer to 100.

This commit is contained in:
Chris 2018-06-30 22:54:30 +02:00
parent ed5367a124
commit 942e64706d
2 changed files with 19 additions and 18 deletions

View file

@ -14,33 +14,25 @@ static int CmdQuit(const char *Cmd);
static int CmdRev(const char *Cmd); static int CmdRev(const char *Cmd);
//For storing command that are received from the device //For storing command that are received from the device
#define CMD_BUFFER_SIZE 50
static UsbCommand cmdBuffer[CMD_BUFFER_SIZE]; static UsbCommand cmdBuffer[CMD_BUFFER_SIZE];
//Points to the next empty position to write to //Points to the next empty position to write to
static int cmd_head;//Starts as 0 static int cmd_head = 0;
//Points to the position of the last unread command //Points to the position of the last unread command
static int cmd_tail;//Starts as 0 static int cmd_tail = 0;
// to lock cmdBuffer operations from different threads // to lock cmdBuffer operations from different threads
static pthread_mutex_t cmdBufferMutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t cmdBufferMutex = PTHREAD_MUTEX_INITIALIZER;
int CmdQuit(const char *Cmd) {
return 99;
}
int CmdRev(const char *Cmd) {
CmdCrc(Cmd);
return 0;
}
static command_t CommandTable[] = { static command_t CommandTable[] = {
{"help", CmdHelp, 1, "This help. Use '<command> help' for details of a particular command."}, {"help", CmdHelp, 1, "This help. Use '<command> help' for details of a particular command."},
{"analyse", CmdAnalyse, 1, "{ Analyse bytes... }"}, {"analyse", CmdAnalyse, 1, "{ Analyse utils... }"},
{"data", CmdData, 1, "{ Plot window / data buffer manipulation... }"}, {"data", CmdData, 1, "{ Plot window / data buffer manipulation... }"},
{"hf", CmdHF, 1, "{ High Frequency commands... }"}, {"hf", CmdHF, 1, "{ High Frequency commands... }"},
{"hw", CmdHW, 1, "{ Hardware commands... }"}, {"hw", CmdHW, 1, "{ Hardware commands... }"},
{"lf", CmdLF, 1, "{ Low Frequency commands... }"}, {"lf", CmdLF, 1, "{ Low Frequency commands... }"},
{"reveng", CmdRev, 1, "Crc calculations from the software reveng 1.44"}, {"reveng", CmdRev, 1, "{ Crc calculations from the software reveng 1.51... }"},
{"script", CmdScript, 1, "{ Scripting commands }"}, {"script", CmdScript, 1, "{ Scripting commands }"},
{"trace", CmdTrace, 1, "{ Trace manipulation... }"}, {"trace", CmdTrace, 1, "{ Trace manipulation... }"},
#ifdef WITH_FLASH #ifdef WITH_FLASH
@ -60,6 +52,15 @@ int CmdHelp(const char *Cmd) {
return 0; return 0;
} }
int CmdQuit(const char *Cmd) {
return 99;
}
int CmdRev(const char *Cmd) {
CmdCrc(Cmd);
return 0;
}
bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbCommand *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd); bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbCommand *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
/** /**
* @brief This method should be called when sending a new command to the pm3. In case any old * @brief This method should be called when sending a new command to the pm3. In case any old
@ -85,6 +86,7 @@ void storeCommand(UsbCommand *command) {
//If these two are equal, we're about to overwrite in the //If these two are equal, we're about to overwrite in the
// circular buffer. // circular buffer.
PrintAndLogEx(FAILED, "WARNING: Command buffer about to overwrite command! This needs to be fixed!"); PrintAndLogEx(FAILED, "WARNING: Command buffer about to overwrite command! This needs to be fixed!");
fflush(NULL);
} }
//Store the command at the 'head' location //Store the command at the 'head' location
UsbCommand* destination = &cmdBuffer[cmd_head]; UsbCommand* destination = &cmdBuffer[cmd_head];
@ -197,12 +199,11 @@ void UsbCommandReceived(UsbCommand* _ch) {
// print debug line on same row. escape seq \r // print debug line on same row. escape seq \r
if ( c->arg[1] == CMD_MEASURE_ANTENNA_TUNING_HF) { if ( c->arg[1] == CMD_MEASURE_ANTENNA_TUNING_HF) {
printf("\r#db# %s", s); PrintAndLogEx(NORMAL, "\r#db# %s", s);
fflush(NULL);
} else { } else {
PrintAndLogEx(NORMAL, "#db# %s", s); PrintAndLogEx(NORMAL, "#db# %s", s);
fflush(NULL);
} }
fflush(NULL);
break; break;
} }
case CMD_DEBUG_PRINT_INTEGERS: { case CMD_DEBUG_PRINT_INTEGERS: {

View file

@ -36,7 +36,7 @@
#include "cmdflashmem.h" // rdv40 flashmem commands #include "cmdflashmem.h" // rdv40 flashmem commands
//For storing command that are received from the device //For storing command that are received from the device
#define CMD_BUFFER_SIZE 50 #define CMD_BUFFER_SIZE 100
typedef enum { typedef enum {
BIG_BUF, BIG_BUF,
BIG_BUF_EML, BIG_BUF_EML,