Merge branch 'master' into experimental_varlen

* master:
  rework Dbprintf & add color support
  use color macros
  doc magic
  archive and fix hid-flasher
  update standalone readme
This commit is contained in:
Philippe Teuwen 2019-04-26 10:48:28 +02:00
commit 1c136c8fc6
32 changed files with 210 additions and 183 deletions

View file

@ -114,13 +114,13 @@ void print_result(char *name, uint8_t *buf, size_t len) {
// Debug print functions, to go out over USB, to the usual PC-side client.
//=============================================================================
void DbpStringEx(char *str, uint32_t cmd) {
void DbpStringEx(uint32_t flags, char *str) {
#if DEBUG
struct {
uint16_t flag;
uint8_t buf[USB_CMD_DATA_SIZE - sizeof(uint16_t)];
} PACKED data;
data.flag = cmd;
data.flag = flags;
uint16_t len = MIN(strlen(str), sizeof(data.buf));
memcpy(data.buf, str, len);
reply_ng(CMD_DEBUG_PRINT_STRING, PM3_SUCCESS, (uint8_t *)&data, sizeof(data.flag) + len);
@ -129,7 +129,7 @@ void DbpStringEx(char *str, uint32_t cmd) {
void DbpString(char *str) {
#if DEBUG
DbpStringEx(str, 0);
DbpStringEx(FLAG_LOG, str);
#endif
}
@ -138,7 +138,7 @@ void DbpIntegers(int x1, int x2, int x3) {
reply_old(CMD_DEBUG_PRINT_INTEGERS, x1, x2, x3, 0, 0);
}
#endif
void DbprintfEx(uint32_t cmd, const char *fmt, ...) {
void DbprintfEx(uint32_t flags, const char *fmt, ...) {
#if DEBUG
// should probably limit size here; oh well, let's just use a big buffer
char output_string[128] = {0x00};
@ -147,7 +147,7 @@ void DbprintfEx(uint32_t cmd, const char *fmt, ...) {
kvsprintf(fmt, output_string, 10, ap);
va_end(ap);
DbpStringEx(output_string, cmd);
DbpStringEx(flags, output_string);
#endif
}
@ -316,10 +316,10 @@ void MeasureAntennaTuningHf(void) {
} else {
volt = (MAX_ADC_HF_VOLTAGE_RDV40 * AvgAdc(ADC_CHAN_HF_RDV40)) >> 10;
}
DbprintfEx(FLAG_NONEWLINE, "%u mV / %5u V", volt, (uint16_t)(volt / 1000));
DbprintfEx(FLAG_INPLACE, "%u mV / %5u V", volt, (uint16_t)(volt / 1000));
}
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
DbprintfEx(FLAG_NOOPT, "\n[+] cancelled", 1);
DbprintfEx(FLAG_LOG, "\n[+] cancelled", 1);
}
void ReadMem(int addr) {
@ -371,7 +371,7 @@ void SendVersion(void) {
// measure the USB Speed by sending SpeedTestBufferSize bytes to client and measuring the elapsed time.
// Note: this mimics GetFromBigbuf(), i.e. we have the overhead of the PacketCommandNG structure included.
void printUSBSpeed(void) {
Dbprintf("USB Speed");
DbpStringEx(FLAG_LOG|FLAG_ANSI, _BLUE_("USB Speed"));
Dbprintf(" Sending USB packets to client...");
#define USB_SPEED_TEST_MIN_TIME 1500 // in milliseconds
@ -412,12 +412,12 @@ void SendStatus(void) {
printT55xxConfig(); // LF T55XX Config
#endif
printUSBSpeed();
Dbprintf("Various");
DbpStringEx(FLAG_LOG|FLAG_ANSI, _BLUE_("Various"));
Dbprintf(" MF_DBGLEVEL.............%d", MF_DBGLEVEL);
Dbprintf(" ToSendMax...............%d", ToSendMax);
Dbprintf(" ToSendBit...............%d", ToSendBit);
Dbprintf(" ToSend BUFFERSIZE.......%d", TOSEND_BUFFER_SIZE);
DbpString("Installed StandAlone Mode");
DbpStringEx(FLAG_LOG|FLAG_ANSI, _BLUE_("Installed StandAlone Mode"));
ModInfo();
//DbpString("Running ");