em4x50: fix listen window sync, add runtime reader timings

Every bidirectional EM4x50 command (rdbl, info, dump, lf search) failed
on a PM3 Easy with a 500 uH antenna, while `lf em 4x50 reader` worked.
A raw ADC capture of the exchange showed RM being sent into the tag data
right after the double listen window: find_em4x50_tag() consumes the
first window, the second one is then taken as the first, and
invalid_bit() cannot reject data because its single 3/4-bit sample of
the AC-coupled, saturating signal always sits between g_Low and g_High.

- detect the second listen window by the absence of a rising edge over
  its 128-cycle low phase (Manchester data has one per bit)
- `lf em 4x50 config` (CMD_LF_EM4X50_CONFIG): threshold, pulse
  tolerance, "0" bit gap start/end and RM delay, changeable at runtime
- defaults moved to the centres of the working ranges measured with the
  new lf_em4x50_tune.lua sweep: tol 10 (5-15), gap end 38 (28-50),
  rm 132 (104-164); the old gap end 32 was 4 cycles from failing
- rdbl/info retry the login + selective read for up to 1 s
- at debug level extended the whole exchange is captured into BigBuf,
  fetch it with `data samples`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
abou28andClaude Opus 5.5 committed 2026-11-05 11:51:59 +01:00
1 parent 1b71dfbbd4
commit 0f777089a4
10 files changed
+470 -47

No files matched your search

+1
View File
@@ -1089,6 +1089,7 @@ typedef struct {
#define CMD_LF_EM4X50_READER 0x0251
#define CMD_LF_EM4X50_ESET 0x0252
#define CMD_LF_EM4X50_CHK 0x0253
#define CMD_LF_EM4X50_CONFIG 0x0254
#define CMD_LF_EM4X70_INFO 0x0260
#define CMD_LF_EM4X70_WRITE 0x0261
#define CMD_LF_EM4X70_UNLOCK 0x0262