mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-12 16:22:59 -07:00
send LF commands to TAG (locomread)
This commit is contained in:
parent
ac174b297a
commit
959baa89f7
5 changed files with 920 additions and 818 deletions
1678
armsrc/appmain.c
1678
armsrc/appmain.c
File diff suppressed because it is too large
Load diff
|
@ -12,8 +12,11 @@ void AppMain(void);
|
||||||
void DbpIntegers(int a, int b, int c);
|
void DbpIntegers(int a, int b, int c);
|
||||||
void DbpString(char *str);
|
void DbpString(char *str);
|
||||||
void SpinDelay(int ms);
|
void SpinDelay(int ms);
|
||||||
|
void SpinDelayUs(int us);
|
||||||
void ToSendStuffBit(int b);
|
void ToSendStuffBit(int b);
|
||||||
void ToSendReset(void);
|
void ToSendReset(void);
|
||||||
|
void AcquireRawAdcSamples125k(BOOL at134khz);
|
||||||
|
void DoAcquisition125k(BOOL at134khz);
|
||||||
extern int ToSendMax;
|
extern int ToSendMax;
|
||||||
extern BYTE ToSend[];
|
extern BYTE ToSend[];
|
||||||
extern DWORD BigBuf[];
|
extern DWORD BigBuf[];
|
||||||
|
|
|
@ -48,6 +48,7 @@ typedef struct {
|
||||||
#define CMD_HID_SIM_TAG 0x0209 // ## New command: simulate HID tag by ID
|
#define CMD_HID_SIM_TAG 0x0209 // ## New command: simulate HID tag by ID
|
||||||
#define CMD_SET_LF_DIVISOR 0x020A
|
#define CMD_SET_LF_DIVISOR 0x020A
|
||||||
#define CMD_SWEEP_LF 0x020B
|
#define CMD_SWEEP_LF 0x020B
|
||||||
|
#define CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K 0x020C
|
||||||
|
|
||||||
// For the 13.56 MHz tags
|
// For the 13.56 MHz tags
|
||||||
#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693 0x0300
|
#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693 0x0300
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "prox.h"
|
#include "prox.h"
|
||||||
#include "../common/iso14443_crc.c"
|
#include "../common/iso14443_crc.c"
|
||||||
|
@ -535,6 +536,21 @@ static void CmdLoread(char *str)
|
||||||
SendCommand(&c, FALSE);
|
SendCommand(&c, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* send a command before reading */
|
||||||
|
static void CmdLoCommandRead(char *str)
|
||||||
|
{
|
||||||
|
static char dummy[3];
|
||||||
|
|
||||||
|
dummy[0]= ' ';
|
||||||
|
|
||||||
|
UsbCommand c;
|
||||||
|
c.cmd = CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K;
|
||||||
|
sscanf(str, "%i %i %i %s %s", &c.ext1, &c.ext2, &c.ext3, &c.d.asBytes,&dummy+1);
|
||||||
|
// in case they specified 'h'
|
||||||
|
strcpy(&c.d.asBytes + strlen(c.d.asBytes),dummy);
|
||||||
|
SendCommand(&c, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static void CmdLosamples(char *str)
|
static void CmdLosamples(char *str)
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
@ -2065,7 +2081,7 @@ static void Cmdmanchestermod(char *str)
|
||||||
* Typical values can be 64, 32, 128...
|
* Typical values can be 64, 32, 128...
|
||||||
*/
|
*/
|
||||||
static void Cmdmanchesterdemod(char *str) {
|
static void Cmdmanchesterdemod(char *str) {
|
||||||
int i, j, invert= 0;
|
int i, j;
|
||||||
int bit;
|
int bit;
|
||||||
int clock;
|
int clock;
|
||||||
int lastval;
|
int lastval;
|
||||||
|
@ -2077,16 +2093,6 @@ static void Cmdmanchesterdemod(char *str) {
|
||||||
int bit2idx = 0;
|
int bit2idx = 0;
|
||||||
int warnings = 0;
|
int warnings = 0;
|
||||||
|
|
||||||
/* check if we're inverting output */
|
|
||||||
if(*str == 'i')
|
|
||||||
{
|
|
||||||
PrintToScrollback("Inverting output");
|
|
||||||
invert= 1;
|
|
||||||
do
|
|
||||||
++str;
|
|
||||||
while(*str == ' '); // in case a 2nd argument was given
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Holds the decoded bitstream: each clock period contains 2 bits */
|
/* Holds the decoded bitstream: each clock period contains 2 bits */
|
||||||
/* later simplified to 1 bit after manchester decoding. */
|
/* later simplified to 1 bit after manchester decoding. */
|
||||||
/* Add 10 bits to allow for noisy / uncertain traces without aborting */
|
/* Add 10 bits to allow for noisy / uncertain traces without aborting */
|
||||||
|
@ -2157,7 +2163,7 @@ static void Cmdmanchesterdemod(char *str) {
|
||||||
if (!hithigh || !hitlow)
|
if (!hithigh || !hitlow)
|
||||||
bit ^= 1;
|
bit ^= 1;
|
||||||
|
|
||||||
BitStream[bit2idx++] = bit ^ invert;
|
BitStream[bit2idx++] = bit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2165,7 +2171,7 @@ static void Cmdmanchesterdemod(char *str) {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Then detect duration between 2 successive transitions */
|
/* Then detect duration between 2 successive transitions */
|
||||||
for (bitidx = 1; i < GraphTraceLen; i++)
|
for (bitidx = 1; i < GraphTraceLen; i++)
|
||||||
{
|
{
|
||||||
if (GraphBuffer[i-1] != GraphBuffer[i])
|
if (GraphBuffer[i-1] != GraphBuffer[i])
|
||||||
|
@ -2200,18 +2206,18 @@ static void Cmdmanchesterdemod(char *str) {
|
||||||
PrintToScrollback("Error: too many detection errors, aborting.");
|
PrintToScrollback("Error: too many detection errors, aborting.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// At this stage, we now have a bitstream of "01" ("1") or "10" ("0"), parse it into final decoded bitstream
|
// At this stage, we now have a bitstream of "01" ("1") or "10" ("0"), parse it into final decoded bitstream
|
||||||
// Actually, we overwrite BitStream with the new decoded bitstream, we just need to be careful
|
// Actually, we overwrite BitStream with the new decoded bitstream, we just need to be careful
|
||||||
// to stop output at the final bitidx2 value, not bitidx
|
// to stop output at the final bitidx2 value, not bitidx
|
||||||
for (i = 0; i < bitidx; i += 2) {
|
for (i = 0; i < bitidx; i += 2) {
|
||||||
if ((BitStream[i] == 0) && (BitStream[i+1] == 1)) {
|
if ((BitStream[i] == 0) && (BitStream[i+1] == 1)) {
|
||||||
BitStream[bit2idx++] = 1 ^ invert;
|
BitStream[bit2idx++] = 1;
|
||||||
} else if ((BitStream[i] == 1) && (BitStream[i+1] == 0)) {
|
} else if ((BitStream[i] == 1) && (BitStream[i+1] == 0)) {
|
||||||
BitStream[bit2idx++] = 0 ^ invert;
|
BitStream[bit2idx++] = 0;
|
||||||
} else {
|
} else {
|
||||||
// We cannot end up in this state, this means we are unsynchronized,
|
// We cannot end up in this state, this means we are unsynchronized,
|
||||||
// move up 1 bit:
|
// move up 1 bit:
|
||||||
|
@ -2225,8 +2231,8 @@ static void Cmdmanchesterdemod(char *str) {
|
||||||
PrintToScrollback("Error: too many decode errors, aborting.");
|
PrintToScrollback("Error: too many decode errors, aborting.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintToScrollback("Manchester decoded bitstream");
|
PrintToScrollback("Manchester decoded bitstream");
|
||||||
|
@ -2450,11 +2456,12 @@ static struct {
|
||||||
"lcd", CmdLcd,0, "<HEX command> <count> -- Send command/data to LCD",
|
"lcd", CmdLcd,0, "<HEX command> <count> -- Send command/data to LCD",
|
||||||
"lcdreset", CmdLcdReset,0, " Hardware reset LCD",
|
"lcdreset", CmdLcdReset,0, " Hardware reset LCD",
|
||||||
"load", CmdLoad,1, "<filename> -- Load trace (to graph window",
|
"load", CmdLoad,1, "<filename> -- Load trace (to graph window",
|
||||||
|
"locomread", CmdLoCommandRead,0, "<off period> <'0' period> <'1' period> <command> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)",
|
||||||
"loread", CmdLoread,0, "['h'] -- Read 125/134 kHz LF ID-only tag (option 'h' for 134)",
|
"loread", CmdLoread,0, "['h'] -- Read 125/134 kHz LF ID-only tag (option 'h' for 134)",
|
||||||
"losamples", CmdLosamples,0, "[128 - 16000] -- Get raw samples for LF tag",
|
"losamples", CmdLosamples,0, "[128 - 16000] -- Get raw samples for LF tag",
|
||||||
"losim", CmdLosim,0, " Simulate LF tag",
|
"losim", CmdLosim,0, " Simulate LF tag",
|
||||||
"ltrim", CmdLtrim,1, "<samples> -- Trim samples from left of trace",
|
"ltrim", CmdLtrim,1, "<samples> -- Trim samples from left of trace",
|
||||||
"mandemod", Cmdmanchesterdemod,1, "[i] [clock rate] -- Manchester demodulate binary stream (option 'i' to invert output)",
|
"mandemod", Cmdmanchesterdemod,1, "[clock rate] -- Try a Manchester demodulation on a binary stream",
|
||||||
"manmod", Cmdmanchestermod,1, "[clock rate] -- Manchester modulate a binary stream",
|
"manmod", Cmdmanchestermod,1, "[clock rate] -- Manchester modulate a binary stream",
|
||||||
"norm", CmdNorm,1, " Normalize max/min to +/-500",
|
"norm", CmdNorm,1, " Normalize max/min to +/-500",
|
||||||
"plot", CmdPlot,1, " Show graph window",
|
"plot", CmdPlot,1, " Show graph window",
|
||||||
|
|
|
@ -51,6 +51,7 @@ int CmdClearGraph(int redraw);
|
||||||
static void CmdAppendGraph(int redraw, int clock, int bit);
|
static void CmdAppendGraph(int redraw, int clock, int bit);
|
||||||
static void CmdEM410xsim(char *str);
|
static void CmdEM410xsim(char *str);
|
||||||
static void CmdLosim(char *str);
|
static void CmdLosim(char *str);
|
||||||
|
static void CmdLoCommandRead(char *str);
|
||||||
static void CmdLoread(char *str);
|
static void CmdLoread(char *str);
|
||||||
static void CmdLosamples(char *str);
|
static void CmdLosamples(char *str);
|
||||||
static void CmdBitsamples(char *str);
|
static void CmdBitsamples(char *str);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue