diff --git a/armsrc/appmain.c b/armsrc/appmain.c index bca106931..57c36490a 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1561,9 +1561,15 @@ static void PacketReceived(PacketCommandNG *packet) { break; } case CMD_HF_ISO14443A_SET_THRESHOLDS: { + struct p { + uint8_t threshold; + uint8_t threshold_high; + uint8_t legic_threshold; + } PACKED; + struct p *payload = (struct p *) packet->data.asBytes; FpgaDownloadAndGo(FPGA_BITSTREAM_HF); - FpgaSendCommand(FPGA_CMD_SET_EDGE_DETECT_THRESHOLD, (packet->data.asBytes[0] & 0x3f) | ((packet->data.asBytes[1] & 0x3f) << 6)); - LegicRfSetThreshold((uint32_t)packet->data.asBytes[2]); + FpgaSendCommand(FPGA_CMD_SET_EDGE_DETECT_THRESHOLD, (payload->threshold & 0x3f) | ((payload->threshold_high & 0x3f) << 6)); + LegicRfSetThreshold((uint32_t)payload->legic_threshold); break; } case CMD_HF_ISO14443A_SNIFF: { diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index e2f2cf93a..767935a77 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -759,13 +759,19 @@ static int CmdSetHFThreshold(const char *Cmd) { arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); - uint8_t params[3]; - params[0] = arg_get_int_def(ctx, 1, 7); - params[1] = arg_get_int_def(ctx, 2, 20); - params[2] = arg_get_int_def(ctx, 3, 8); + + struct { + uint8_t threshold; + uint8_t threshold_high; + uint8_t legic_threshold; + } PACKED params; + + params.threshold = arg_get_int_def(ctx, 1, 7); + params.threshold_high = arg_get_int_def(ctx, 2, 20); + params.legic_threshold = arg_get_int_def(ctx, 3, 8); CLIParserFree(ctx); - if ((params[0] < 1) || (params[0] > 63) || (params[1] < 1) || (params[1] > 63)) { + if ((params.threshold < 1) || (params.threshold > 63) || (params.threshold_high < 1) || (params.threshold_high > 63)) { PrintAndLogEx(ERR, "Thresholds must be between " _YELLOW_("1") " and " _YELLOW_("63")); return PM3_EINVARG; }