mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-22 07:04:13 +08:00
sh sniff skip some bytes from data - arm side
This commit is contained in:
parent
dcea185ca2
commit
0b95c519ff
3 changed files with 55 additions and 4 deletions
|
@ -1784,11 +1784,13 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
struct p {
|
||||
uint32_t samplesToSkip;
|
||||
uint32_t triggersToSkip;
|
||||
uint8_t skipMode;
|
||||
uint8_t skipRatio;
|
||||
} PACKED;
|
||||
struct p *payload = (struct p *)packet->data.asBytes;
|
||||
|
||||
uint16_t len = 0;
|
||||
int res = HfSniff(payload->samplesToSkip, payload->triggersToSkip, &len);
|
||||
int res = HfSniff(payload->samplesToSkip, payload->triggersToSkip, &len, payload->skipMode, payload->skipRatio);
|
||||
|
||||
struct {
|
||||
uint16_t len;
|
||||
|
|
|
@ -36,7 +36,46 @@ static void RAMFUNC optimizedSniff(uint16_t *dest, uint16_t dsize) {
|
|||
}
|
||||
}
|
||||
|
||||
int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len) {
|
||||
static void RAMFUNC skipSniff(uint8_t *dest, uint16_t dsize, uint8_t skipMode, uint8_t skipRatio) {
|
||||
uint32_t accum = (skipMode == HF_SNOOP_SKIP_MIN) ? 0xffffffff : 0;
|
||||
uint8_t ratioindx = 0;
|
||||
while (dsize > 0) {
|
||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
|
||||
volatile uint16_t val = (uint16_t)(AT91C_BASE_SSC->SSC_RHR);
|
||||
switch (skipMode) {
|
||||
case HF_SNOOP_SKIP_MAX:
|
||||
if (accum < (val & 0xff))
|
||||
accum = val & 0xff;
|
||||
if (accum < (val << 8))
|
||||
accum = val << 8;
|
||||
case HF_SNOOP_SKIP_MIN:
|
||||
if (accum > (val & 0xff))
|
||||
accum = val & 0xff;
|
||||
if (accum > (val << 8))
|
||||
accum = val << 8;
|
||||
case HF_SNOOP_SKIP_AVG:
|
||||
accum += (val & 0xff) + (val << 8);
|
||||
default: { // HF_SNOOP_SKIP_DROP and the rest
|
||||
if (ratioindx == 0)
|
||||
accum = val & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
ratioindx++;
|
||||
if (ratioindx >= skipRatio) {
|
||||
ratioindx = 0;
|
||||
if (skipMode == HF_SNOOP_SKIP_AVG)
|
||||
*dest = accum / (skipRatio * 2);
|
||||
else
|
||||
*dest = accum;
|
||||
dest++;
|
||||
dsize --;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len, uint8_t skipMode, uint8_t skipRatio) {
|
||||
BigBuf_free();
|
||||
BigBuf_Clear_ext(false);
|
||||
|
||||
|
@ -105,7 +144,10 @@ int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len) {
|
|||
}
|
||||
}
|
||||
|
||||
optimizedSniff((uint16_t *)mem, *len);
|
||||
if (skipMode == 0)
|
||||
optimizedSniff((uint16_t *)mem, *len);
|
||||
else
|
||||
skipSniff(mem, *len, skipMode, skipRatio);
|
||||
|
||||
if (g_dbglevel >= DBG_INFO) {
|
||||
Dbprintf("Trigger kicked in (%d >= 180)", r);
|
||||
|
|
|
@ -18,6 +18,13 @@
|
|||
|
||||
#include "proxmark3_arm.h"
|
||||
|
||||
int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len);
|
||||
// what to do with skipped data
|
||||
#define HF_SNOOP_SKIP_NONE (0)
|
||||
#define HF_SNOOP_SKIP_DROP (1)
|
||||
#define HF_SNOOP_SKIP_MAX (2)
|
||||
#define HF_SNOOP_SKIP_MIN (3)
|
||||
#define HF_SNOOP_SKIP_AVG (4)
|
||||
|
||||
int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len, uint8_t skipMode, uint8_t skipRatio);
|
||||
void HfPlotDownload(void);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue