Skip to content

Commit

Permalink
modified hw tune output layout
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Jan 4, 2024
1 parent 1101a26 commit 7817458
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
55 changes: 36 additions & 19 deletions client/src/cmddata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1978,16 +1978,16 @@ int CmdTuneSamples(const char *Cmd) {
struct p *package = (struct p *)resp.data.asBytes;

if (package->v_lf125 > NON_VOLTAGE)
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - %.2f kHz", (package->v_lf125 * ANTENNA_ERROR) / 1000.0, LF_DIV2FREQ(LF_DIVISOR_125));
PrintAndLogEx(SUCCESS, "At %.2f kHz .......... " _YELLOW_("%5.2f") " V", LF_DIV2FREQ(LF_DIVISOR_125), (package->v_lf125 * ANTENNA_ERROR) / 1000.0);

if (package->v_lf134 > NON_VOLTAGE)
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - %.2f kHz", (package->v_lf134 * ANTENNA_ERROR) / 1000.0, LF_DIV2FREQ(LF_DIVISOR_134));
PrintAndLogEx(SUCCESS, "At %.2f kHz .......... " _YELLOW_("%5.2f") " V", LF_DIV2FREQ(LF_DIVISOR_134), (package->v_lf134 * ANTENNA_ERROR) / 1000.0);

if (package->v_lfconf > NON_VOLTAGE && package->divisor > 0 && package->divisor != LF_DIVISOR_125 && package->divisor != LF_DIVISOR_134)
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - %.2f kHz", (package->v_lfconf * ANTENNA_ERROR) / 1000.0, LF_DIV2FREQ(package->divisor));
PrintAndLogEx(SUCCESS, "At %.2f kHz .......... " _YELLOW_("%5.2f") " V", LF_DIV2FREQ(package->divisor), (package->v_lfconf * ANTENNA_ERROR) / 1000.0);

if (package->peak_v > NON_VOLTAGE && package->peak_f > 0)
PrintAndLogEx(SUCCESS, "LF optimal: %5.2f V - %6.2f kHz", (package->peak_v * ANTENNA_ERROR) / 1000.0, LF_DIV2FREQ(package->peak_f));
PrintAndLogEx(SUCCESS, "At %.2f kHz optimal... " _YELLOW_("%5.2f") " V", LF_DIV2FREQ(package->peak_f), (package->peak_v * ANTENNA_ERROR) / 1000.0);

// Empirical measures in mV
const double vdd_rdv4 = 9000;
Expand All @@ -2008,6 +2008,9 @@ int CmdTuneSamples(const char *Cmd) {
break;
}
}

PrintAndLogEx(SUCCESS, "");
PrintAndLogEx(SUCCESS, "Approx. Q factor measurement (*)");
double lfq1 = 0;
if (s4 != 0) { // we got all our points of interest
double a = package->results[s2 - 1];
Expand All @@ -2017,12 +2020,12 @@ int CmdTuneSamples(const char *Cmd) {
double d = package->results[s4];
double f2 = LF_DIV2FREQ(s4 - 1 + (c - v_3db_scaled) / (c - d));
lfq1 = LF_DIV2FREQ(package->peak_f) / (f1 - f2);
PrintAndLogEx(SUCCESS, "Approx. Q factor (*): %.1lf by frequency bandwidth measurement", lfq1);
PrintAndLogEx(SUCCESS, "Frequency bandwidth..... " _YELLOW_("%.1lf"), lfq1);
}

// Q measure with Vlr=Q*(2*Vdd/pi)
double lfq2 = (double)package->peak_v * 3.14 / 2 / vdd;
PrintAndLogEx(SUCCESS, "Approx. Q factor (*): %.1lf by peak voltage measurement", lfq2);
PrintAndLogEx(SUCCESS, "Peak voltage............ " _YELLOW_("%.1lf") , lfq2);
// cross-check results
if (lfq1 > 3) {
double approx_vdd = (double)package->peak_v * 3.14 / 2 / lfq1;
Expand All @@ -2047,34 +2050,40 @@ int CmdTuneSamples(const char *Cmd) {
memset(judgement, 0, sizeof(judgement));
// LF evaluation
if (package->peak_v < LF_UNUSABLE_V)
snprintf(judgement, sizeof(judgement), _RED_("UNUSABLE"));
snprintf(judgement, sizeof(judgement), _RED_("unusable"));
else if (package->peak_v < LF_MARGINAL_V)
snprintf(judgement, sizeof(judgement), _YELLOW_("MARGINAL"));
snprintf(judgement, sizeof(judgement), _YELLOW_("marginal"));
else
snprintf(judgement, sizeof(judgement), _GREEN_("OK"));
snprintf(judgement, sizeof(judgement), _GREEN_("ok"));

PrintAndLogEx((package->peak_v < LF_UNUSABLE_V) ? WARNING : SUCCESS, "LF antenna is %s", judgement);
PrintAndLogEx((package->peak_v < LF_UNUSABLE_V) ? WARNING : SUCCESS, "LF antenna ( %s )", judgement);

PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "---------- " _CYAN_("HF Antenna") " ----------");
// HF evaluation
if (package->v_hf > NON_VOLTAGE)
PrintAndLogEx(SUCCESS, "HF antenna: %5.2f V - 13.56 MHz", (package->v_hf * ANTENNA_ERROR) / 1000.0);
if (package->v_hf > NON_VOLTAGE) {
PrintAndLogEx(SUCCESS, "13.56 MHz............... " _YELLOW_("%5.2f") " V", (package->v_hf * ANTENNA_ERROR) / 1000.0);
}

memset(judgement, 0, sizeof(judgement));

PrintAndLogEx(SUCCESS, "");
PrintAndLogEx(SUCCESS, "Approx. Q factor measurement (*)");

if (package->v_hf >= HF_UNUSABLE_V) {
// Q measure with Vlr=Q*(2*Vdd/pi)
double hfq = (double)package->v_hf * 3.14 / 2 / vdd;
PrintAndLogEx(SUCCESS, "Approx. Q factor (*): %.1lf by peak voltage measurement", hfq);
PrintAndLogEx(SUCCESS, "peak voltage............ " _YELLOW_("%.1lf") , hfq);
}

if (package->v_hf < HF_UNUSABLE_V)
snprintf(judgement, sizeof(judgement), _RED_("UNUSABLE"));
snprintf(judgement, sizeof(judgement), _RED_("unusable"));
else if (package->v_hf < HF_MARGINAL_V)
snprintf(judgement, sizeof(judgement), _YELLOW_("MARGINAL"));
snprintf(judgement, sizeof(judgement), _YELLOW_("marginal"));
else
snprintf(judgement, sizeof(judgement), _GREEN_("OK"));
snprintf(judgement, sizeof(judgement), _GREEN_("ok"));

PrintAndLogEx((package->v_hf < HF_UNUSABLE_V) ? WARNING : SUCCESS, "HF antenna is %s", judgement);
PrintAndLogEx((package->v_hf < HF_UNUSABLE_V) ? WARNING : SUCCESS, "HF antenna ( %s )", judgement);
PrintAndLogEx(NORMAL, "\n(*) Q factor must be measured without tag on the antenna");

// graph LF measurements
Expand All @@ -2086,8 +2095,16 @@ int CmdTuneSamples(const char *Cmd) {
}

if (test1 > 0) {
PrintAndLogEx(SUCCESS, "\nDisplaying LF tuning graph. Divisor %d (blue) is %.2f kHz, %d (red) is %.2f kHz.\n\n",
LF_DIVISOR_134, LF_DIV2FREQ(LF_DIVISOR_134), LF_DIVISOR_125, LF_DIV2FREQ(LF_DIVISOR_125));
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "-------- " _CYAN_("LF tuning graph") " ---------");
PrintAndLogEx(SUCCESS, "Blue line Divisor %d / %.2f kHz"
, LF_DIVISOR_134
, LF_DIV2FREQ(LF_DIVISOR_134)
);
PrintAndLogEx(SUCCESS, "Red line Divisor %d / %.2f kHz\n\n"
, LF_DIVISOR_125
, LF_DIV2FREQ(LF_DIVISOR_125)
);
g_GraphTraceLen = 256;
g_CursorCPos = LF_DIVISOR_125;
g_CursorDPos = LF_DIVISOR_134;
Expand Down
2 changes: 1 addition & 1 deletion client/src/cmdhfmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ static int mf_analyse_st_block(uint8_t blockno, uint8_t *block, bool force) {
return PM3_EINVARG;
}
} else {
PrintAndLogEx(SUCCESS, "ST passed checks, continuing...");
PrintAndLogEx(SUCCESS, "ST checks ( " _GREEN_("ok") " )");
}

return PM3_SUCCESS;
Expand Down
5 changes: 4 additions & 1 deletion client/src/cmdhfmfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,10 @@ static int ulev1_print_configuration(uint64_t tagtype, uint8_t *data, uint8_t st
default:
break;
}
PrintAndLogEx(INFO, " mirror start page %02X | byte pos %02X - %s", mirror_page, mirror_byte, (mirror_page >= 0x4 && ((mirror_user_mem_start_byte + bytes_required_for_mirror_data) <= 144)) ? _GREEN_("OK") : _YELLOW_("Invalid value"));
PrintAndLogEx(INFO, " mirror start page %02X | byte pos %02X - %s"
, mirror_page, mirror_byte
, (mirror_page >= 0x4 && ((mirror_user_mem_start_byte + bytes_required_for_mirror_data) <= 144)) ? _GREEN_("ok") : _YELLOW_("Invalid value")
);
}

} else if (tagtype & (MFU_TT_NTAG_213_F | MFU_TT_NTAG_216_F)) {
Expand Down
8 changes: 4 additions & 4 deletions client/src/cmdlfem4x70.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,11 @@ int CmdEM4x70WritePIN(const char *Cmd) {

if (resp.status) {
print_info_result(resp.data.asBytes);
PrintAndLogEx(INFO, "Writing new PIN: " _GREEN_("SUCCESS"));
PrintAndLogEx(INFO, "Writing new PIN: " _GREEN_("ok"));
return PM3_SUCCESS;
}

PrintAndLogEx(FAILED, "Writing new PIN: " _RED_("FAILED"));
PrintAndLogEx(FAILED, "Writing new PIN: " _RED_("failed"));
return PM3_ESOFT;
}

Expand Down Expand Up @@ -539,11 +539,11 @@ int CmdEM4x70WriteKey(const char *Cmd) {
}

if (resp.status) {
PrintAndLogEx(INFO, "Writing new crypt key: " _GREEN_("SUCCESS"));
PrintAndLogEx(INFO, "Writing new crypt key: " _GREEN_("ok"));
return PM3_SUCCESS;
}

PrintAndLogEx(FAILED, "Writing new crypt key: " _RED_("FAILED"));
PrintAndLogEx(FAILED, "Writing new crypt key: " _RED_("failed"));
return PM3_ESOFT;
}

Expand Down

0 comments on commit 7817458

Please sign in to comment.