FIX: 'hf tune' - now works...

This commit is contained in:
iceman1001 2019-01-06 20:28:23 +01:00
commit 0dee369a58
3 changed files with 27 additions and 37 deletions

View file

@ -113,7 +113,7 @@ void print_result(char *name, uint8_t *buf, size_t len) {
void DbpStringEx(char *str, uint32_t cmd) { void DbpStringEx(char *str, uint32_t cmd) {
#if DEBUG #if DEBUG
uint8_t len = strlen(str); uint8_t len = strlen(str);
cmd_send(CMD_DEBUG_PRINT_STRING, len, cmd, 0, (byte_t*)str, len); cmd_send(CMD_DEBUG_PRINT_STRING, len, cmd, 0, (uint8_t*)str, len);
#endif #endif
} }
@ -307,10 +307,10 @@ void MeasureAntennaTuningHf(void) {
} else { } else {
volt = (MAX_ADC_HF_VOLTAGE_RDV40 * AvgAdc(ADC_CHAN_HF_RDV40)) >> 10; volt = (MAX_ADC_HF_VOLTAGE_RDV40 * AvgAdc(ADC_CHAN_HF_RDV40)) >> 10;
} }
DbprintfEx(CMD_MEASURE_ANTENNA_TUNING_HF, "%u mV / %5u V", volt, (uint16_t)(volt/1000)); DbprintfEx(FLAG_NONEWLINE, "%u mV / %5u V", volt, (uint16_t)(volt/1000));
} }
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
DbpString("\n[+] cancelled"); DbprintfEx(FLAG_NOOPT, "\n[+] cancelled", 1);
} }
void ReadMem(int addr) { void ReadMem(int addr) {

View file

@ -155,35 +155,24 @@ static void UsbCommandReceived(UsbCommand* c) {
memset(s, 0x00, sizeof(s)); memset(s, 0x00, sizeof(s));
size_t len = MIN(c->arg[0], USB_CMD_DATA_SIZE); size_t len = MIN(c->arg[0], USB_CMD_DATA_SIZE);
memcpy(s, c->d.asBytes, len); memcpy(s, c->d.asBytes, len);
//#define FLAG_RAWPRINT 0x0111
//#define FLAG_NOOPT 0x0000
//#define FLAG_NOLOG 0x0001
//#define FLAG_NONEWLINE 0x0010
//#define FLAG_NOPROMPT 0x0100
uint64_t flag = c->arg[1]; uint64_t flag = c->arg[1];
if (flag > 0) { // FLAG_RAWPRINT) {
switch (flag) { switch (flag) {
case FLAG_RAWPRINT: case FLAG_RAWPRINT:
printf("%s", s); printf("%s", s);
return; break;
case FLAG_NONEWLINE: case FLAG_NONEWLINE:
printf("%s\r", s); printf("\r%s", s);
return; break;
case FLAG_NOLOG: case FLAG_NOLOG:
printf("%s\r\n", s); printf("%s\r\n", s);
return; break;
} //case FLAG_NOPROMPT:
fflush(stdout); // break;
return; case FLAG_NOOPT:
} default:
// print debug line on same row. escape seq \r
if ( c->arg[1] == CMD_MEASURE_ANTENNA_TUNING_HF) {
PrintAndLogEx(NORMAL, "\r#db# %s", s);
} else {
PrintAndLogEx(NORMAL, "#db# %s", s); PrintAndLogEx(NORMAL, "#db# %s", s);
break;
} }
fflush(stdout); fflush(stdout);
break; break;

View file

@ -306,6 +306,7 @@ typedef struct{
#define FLAG_NONEWLINE 0x0010 #define FLAG_NONEWLINE 0x0010
#define FLAG_NOPROMPT 0x0100 #define FLAG_NOPROMPT 0x0100
// CMD_DEVICE_INFO response packet has flags in arg[0], flag definitions: // CMD_DEVICE_INFO response packet has flags in arg[0], flag definitions:
/* Whether a bootloader that understands the common_area is present */ /* Whether a bootloader that understands the common_area is present */
#define DEVICE_INFO_FLAG_BOOTROM_PRESENT (1<<0) #define DEVICE_INFO_FLAG_BOOTROM_PRESENT (1<<0)