lf cmdread: add -k to keep field on

This commit is contained in:
Philippe Teuwen 2021-12-18 00:42:06 +01:00
commit c3864a0ce5
5 changed files with 26 additions and 14 deletions

View file

@ -823,7 +823,8 @@ static void PacketReceived(PacketCommandNG *packet) {
uint16_t period_1;
uint8_t symbol_extra[LF_CMDREAD_MAX_EXTRA_SYMBOLS];
uint16_t period_extra[LF_CMDREAD_MAX_EXTRA_SYMBOLS];
uint32_t samples : 31;
uint32_t samples : 30;
bool keep : 1;
bool verbose : 1;
} PACKED;
struct p *payload = (struct p *)packet->data.asBytes;
@ -831,7 +832,7 @@ static void PacketReceived(PacketCommandNG *packet) {
uint16_t period_extra[LF_CMDREAD_MAX_EXTRA_SYMBOLS];
memcpy(symbol_extra, payload->symbol_extra, sizeof(symbol_extra));
memcpy(period_extra, payload->period_extra, sizeof(period_extra));
ModThenAcquireRawAdcSamples125k(payload->delay, payload->period_0, payload->period_1, symbol_extra, period_extra, packet->data.asBytes + sizeof(struct p), payload->verbose, payload->samples, true);
ModThenAcquireRawAdcSamples125k(payload->delay, payload->period_0, payload->period_1, symbol_extra, period_extra, packet->data.asBytes + sizeof(struct p), payload->verbose, payload->keep, payload->samples, true);
break;
}
case CMD_LF_SNIFF_RAW_ADC: {

View file

@ -383,6 +383,8 @@ void loadT55xxConfig(void) {
#endif
}
static bool prev_keep = false;
/**
* Function to do a modulation and then get samples.
* @param delay_off
@ -390,24 +392,26 @@ void loadT55xxConfig(void) {
* @param period_1
* @param command (in binary char array)
*/
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint16_t period_1, uint8_t *symbol_extra, uint16_t *period_extra, uint8_t *command, bool verbose, uint32_t samples, bool ledcontrol) {
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint16_t period_1, uint8_t *symbol_extra, uint16_t *period_extra, uint8_t *command, bool verbose, bool keep_field_on, uint32_t samples, bool ledcontrol) {
if (!prev_keep){
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
}
// use lf config settings
sample_config *sc = getSamplingConfig();
LFSetupFPGAForADC(sc->divisor, true);
// this causes the field to turn on for uncontrolled amount of time, so we'll turn it off
// Make sure the tag is reset
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
if (!prev_keep){
// Make sure the tag is reset
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
}
// start timer
StartTicks();
WaitMS(100);
// clear read buffer
BigBuf_Clear_keep_EM();
@ -494,8 +498,10 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint
DoAcquisition_config(verbose, samples, ledcontrol);
// Turn off antenna
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
if (!keep_field_on) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
}
prev_keep = keep_field_on;
// tell client we are done
reply_ng(CMD_LF_MOD_THEN_ACQ_RAW_ADC, PM3_SUCCESS, NULL, 0);
}

View file

@ -15,7 +15,7 @@
#include "pm3_cmd.h" // struct
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint16_t period_1, uint8_t *symbol_extra, uint16_t *period_extra, uint8_t *command, bool verbose, uint32_t samples, bool ledcontrol);
void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint16_t period_0, uint16_t period_1, uint8_t *symbol_extra, uint16_t *period_extra, uint8_t *command, bool verbose, bool keep_field_on, uint32_t samples, bool ledcontrol);
void ReadTItag(bool ledcontrol);
void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc, bool ledcontrol);