lf sniff offset

Added samples to skip to lf config
This commit is contained in:
mwalker33 2019-09-29 10:43:01 +10:00
parent b41013ca8f
commit cf0d72e172
3 changed files with 32 additions and 13 deletions
armsrc
client
include

View file

@ -33,6 +33,7 @@ void printConfig() {
Dbprintf(" [d] decimation..........%d", config.decimation); Dbprintf(" [d] decimation..........%d", config.decimation);
Dbprintf(" [a] averaging...........%s", (config.averaging) ? "Yes" : "No"); Dbprintf(" [a] averaging...........%s", (config.averaging) ? "Yes" : "No");
Dbprintf(" [t] trigger threshold...%d", config.trigger_threshold); Dbprintf(" [t] trigger threshold...%d", config.trigger_threshold);
Dbprintf(" [s] samples to skip.....%d ", config.samples_to_skip);
} }
/** /**
@ -50,6 +51,7 @@ void setSamplingConfig(sample_config *sc) {
if (sc->divisor != 0) config.divisor = sc->divisor; if (sc->divisor != 0) config.divisor = sc->divisor;
if (sc->bits_per_sample != 0) config.bits_per_sample = sc->bits_per_sample; if (sc->bits_per_sample != 0) config.bits_per_sample = sc->bits_per_sample;
if (sc->trigger_threshold != -1) config.trigger_threshold = sc->trigger_threshold; if (sc->trigger_threshold != -1) config.trigger_threshold = sc->trigger_threshold;
if (sc->samples_to_skip != -1) config.samples_to_skip = sc->samples_to_skip;
config.decimation = (sc->decimation != 0) ? sc->decimation : 1; config.decimation = (sc->decimation != 0) ? sc->decimation : 1;
config.averaging = sc->averaging; config.averaging = sc->averaging;
@ -124,7 +126,7 @@ void LFSetupFPGAForADC(int divisor, bool lf_field) {
* @param silent - is true, now outputs are made. If false, dbprints the status * @param silent - is true, now outputs are made. If false, dbprints the status
* @return the number of bits occupied by the samples. * @return the number of bits occupied by the samples.
*/ */
uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averaging, int trigger_threshold, bool silent, int bufsize, uint32_t cancel_after) { uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averaging, int trigger_threshold, bool silent, int bufsize, uint32_t cancel_after, int samples_to_skip) {
uint8_t *dest = BigBuf_get_addr(); uint8_t *dest = BigBuf_get_addr();
bufsize = (bufsize > 0 && bufsize < BigBuf_max_traceLen()) ? bufsize : BigBuf_max_traceLen(); bufsize = (bufsize > 0 && bufsize < BigBuf_max_traceLen()) ? bufsize : BigBuf_max_traceLen();
@ -144,6 +146,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
uint32_t sample_total_numbers = 0; uint32_t sample_total_numbers = 0;
uint32_t sample_total_saved = 0; uint32_t sample_total_saved = 0;
uint32_t cancel_counter = 0; uint32_t cancel_counter = 0;
uint32_t samples_skipped = 0;
uint16_t checker = 0; uint16_t checker = 0;
@ -176,6 +179,12 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
} }
trigger_threshold = 0; trigger_threshold = 0;
if (samples_to_skip > samples_skipped) {
samples_skipped++;
continue;
}
sample_total_numbers++; sample_total_numbers++;
if (averaging) if (averaging)
@ -196,6 +205,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
// store the sample // store the sample
sample_total_saved ++; sample_total_saved ++;
if (bits_per_sample == 8) { if (bits_per_sample == 8) {
dest[sample_total_saved - 1] = sample; dest[sample_total_saved - 1] = sample;
@ -238,7 +248,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
* @return number of bits sampled * @return number of bits sampled
*/ */
uint32_t DoAcquisition_default(int trigger_threshold, bool silent) { uint32_t DoAcquisition_default(int trigger_threshold, bool silent) {
return DoAcquisition(1, 8, 0, trigger_threshold, silent, 0, 0); return DoAcquisition(1, 8, 0, trigger_threshold, silent, 0, 0,0);
} }
uint32_t DoAcquisition_config(bool silent, int sample_size) { uint32_t DoAcquisition_config(bool silent, int sample_size) {
return DoAcquisition(config.decimation return DoAcquisition(config.decimation
@ -247,11 +257,12 @@ uint32_t DoAcquisition_config(bool silent, int sample_size) {
, config.trigger_threshold , config.trigger_threshold
, silent , silent
, sample_size , sample_size
, 0); , 0
, config.samples_to_skip);
} }
uint32_t DoPartialAcquisition(int trigger_threshold, bool silent, int sample_size, uint32_t cancel_after) { uint32_t DoPartialAcquisition(int trigger_threshold, bool silent, int sample_size, uint32_t cancel_after) {
return DoAcquisition(1, 8, 0, trigger_threshold, silent, sample_size, cancel_after); return DoAcquisition(1, 8, 0, trigger_threshold, silent, sample_size, cancel_after,0);
} }
uint32_t ReadLF(bool activeField, bool silent, int sample_size) { uint32_t ReadLF(bool activeField, bool silent, int sample_size) {

View file

@ -105,14 +105,15 @@ static int usage_lf_sniff(void) {
static int usage_lf_config(void) { static int usage_lf_config(void) {
PrintAndLogEx(NORMAL, "Usage: lf config [h] [H|<divisor>] [b <bps>] [d <decim>] [a 0|1]"); PrintAndLogEx(NORMAL, "Usage: lf config [h] [H|<divisor>] [b <bps>] [d <decim>] [a 0|1]");
PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h This help"); PrintAndLogEx(NORMAL, " h This help");
PrintAndLogEx(NORMAL, " L Low frequency (125 kHz)"); PrintAndLogEx(NORMAL, " L Low frequency (125 kHz)");
PrintAndLogEx(NORMAL, " H High frequency (134 kHz)"); PrintAndLogEx(NORMAL, " H High frequency (134 kHz)");
PrintAndLogEx(NORMAL, " q <divisor> Manually set divisor. 88-> 134 kHz, 95-> 125 kHz"); PrintAndLogEx(NORMAL, " q <divisor> Manually set divisor. 88-> 134 kHz, 95-> 125 kHz");
PrintAndLogEx(NORMAL, " b <bps> Sets resolution of bits per sample. Default (max): 8"); PrintAndLogEx(NORMAL, " b <bps> Sets resolution of bits per sample. Default (max): 8");
PrintAndLogEx(NORMAL, " d <decim> Sets decimation. A value of N saves only 1 in N samples. Default: 1"); PrintAndLogEx(NORMAL, " d <decim> Sets decimation. A value of N saves only 1 in N samples. Default: 1");
PrintAndLogEx(NORMAL, " a [0|1] Averaging - if set, will average the stored sample value when decimating. Default: 1"); PrintAndLogEx(NORMAL, " a [0|1] Averaging - if set, will average the stored sample value when decimating. Default: 1");
PrintAndLogEx(NORMAL, " t <threshold> Sets trigger threshold. 0 means no threshold (range: 0-128)"); PrintAndLogEx(NORMAL, " t <threshold> Sets trigger threshold. 0 means no threshold (range: 0-128)");
PrintAndLogEx(NORMAL, " s <samplestoskip> Sets a number of samples to skip before capture. Default: 0");
PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf config b 8 L"); PrintAndLogEx(NORMAL, " lf config b 8 L");
PrintAndLogEx(NORMAL, " Samples at 125 kHz, 8bps."); PrintAndLogEx(NORMAL, " Samples at 125 kHz, 8bps.");
@ -399,6 +400,8 @@ int CmdLFSetConfig(const char *Cmd) {
bool errors = false; bool errors = false;
int trigger_threshold = -1;//Means no change int trigger_threshold = -1;//Means no change
uint8_t unsigned_trigg = 0; uint8_t unsigned_trigg = 0;
int samples_to_skip = -1;
uint8_t cmdp = 0; uint8_t cmdp = 0;
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) { while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
@ -437,6 +440,10 @@ int CmdLFSetConfig(const char *Cmd) {
averaging = param_getchar(Cmd, cmdp + 1) == '1'; averaging = param_getchar(Cmd, cmdp + 1) == '1';
cmdp += 2; cmdp += 2;
break; break;
case 's':
samples_to_skip = param_get32ex(Cmd,cmdp+1,0,10);
cmdp+=2;
break;
default: default:
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp)); PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
errors = 1; errors = 1;
@ -450,7 +457,7 @@ int CmdLFSetConfig(const char *Cmd) {
//Bps is limited to 8 //Bps is limited to 8
if (bps >> 4) bps = 8; if (bps >> 4) bps = 8;
sample_config config = { decimation, bps, averaging, divisor, trigger_threshold }; sample_config config = { decimation, bps, averaging, divisor, trigger_threshold,samples_to_skip };
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_LF_SAMPLING_SET_CONFIG, (uint8_t *)&config, sizeof(sample_config)); SendCommandNG(CMD_LF_SAMPLING_SET_CONFIG, (uint8_t *)&config, sizeof(sample_config));

View file

@ -118,6 +118,7 @@ typedef struct {
bool averaging; bool averaging;
int divisor; int divisor;
int trigger_threshold; int trigger_threshold;
int samples_to_skip;
} PACKED sample_config; } PACKED sample_config;
/* /*
typedef struct { typedef struct {