mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
syntax sugar
This commit is contained in:
parent
5ebba500dc
commit
5e9d59fe2a
3 changed files with 15 additions and 15 deletions
|
@ -1757,9 +1757,7 @@ int CmdFDXBdemodBI(const char *Cmd){
|
||||||
//attempt to psk1 demod graph buffer
|
//attempt to psk1 demod graph buffer
|
||||||
int PSKDemod(const char *Cmd, bool verbose)
|
int PSKDemod(const char *Cmd, bool verbose)
|
||||||
{
|
{
|
||||||
int invert=0;
|
int invert = 0, clk = 0, maxErr = 100;
|
||||||
int clk=0;
|
|
||||||
int maxErr=100;
|
|
||||||
sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr);
|
sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr);
|
||||||
if (clk==1){
|
if (clk==1){
|
||||||
invert=1;
|
invert=1;
|
||||||
|
@ -1769,25 +1767,26 @@ int PSKDemod(const char *Cmd, bool verbose)
|
||||||
if (g_debugMode || verbose) PrintAndLog("Invalid argument: %s", Cmd);
|
if (g_debugMode || verbose) PrintAndLog("Invalid argument: %s", Cmd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
|
uint8_t BitStream[MAX_GRAPH_TRACE_LEN] = {0};
|
||||||
size_t BitLen = getFromGraphBuf(BitStream);
|
size_t BitLen = getFromGraphBuf(BitStream);
|
||||||
if (BitLen==0) return 0;
|
if (BitLen==0) return 0;
|
||||||
uint8_t carrier=countFC(BitStream, BitLen, 0);
|
|
||||||
|
uint8_t carrier = countFC(BitStream, BitLen, 0);
|
||||||
if (carrier!=2 && carrier!=4 && carrier!=8){
|
if (carrier!=2 && carrier!=4 && carrier!=8){
|
||||||
//invalid carrier
|
//invalid carrier
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (g_debugMode){
|
|
||||||
PrintAndLog("Carrier: rf/%d",carrier);
|
if (g_debugMode) PrintAndLog("Carrier: rf/%d",carrier);
|
||||||
}
|
|
||||||
int errCnt=0;
|
int errCnt=0;
|
||||||
errCnt = pskRawDemod(BitStream, &BitLen, &clk, &invert);
|
errCnt = pskRawDemod(BitStream, &BitLen, &clk, &invert);
|
||||||
if (errCnt > maxErr){
|
if (errCnt > maxErr){
|
||||||
if (g_debugMode || verbose) PrintAndLog("Too many errors found, clk: %d, invert: %d, numbits: %d, errCnt: %d",clk,invert,BitLen,errCnt);
|
if (g_debugMode || verbose) PrintAndLog("Too many errors found, clk: %d, invert: %d, numbits: %d, errCnt: %d", clk, invert, BitLen, errCnt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (errCnt<0|| BitLen<16){ //throw away static - allow 1 and -1 (in case of threshold command first)
|
if (errCnt<0|| BitLen<16){ //throw away static - allow 1 and -1 (in case of threshold command first)
|
||||||
if (g_debugMode || verbose) PrintAndLog("no data found, clk: %d, invert: %d, numbits: %d, errCnt: %d",clk,invert,BitLen,errCnt);
|
if (g_debugMode || verbose) PrintAndLog("no data found, clk: %d, invert: %d, numbits: %d, errCnt: %d", clk, invert, BitLen, errCnt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (verbose || g_debugMode){
|
if (verbose || g_debugMode){
|
||||||
|
@ -1797,7 +1796,7 @@ int PSKDemod(const char *Cmd, bool verbose)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//prime demod buffer for output
|
//prime demod buffer for output
|
||||||
setDemodBuf(BitStream,BitLen,0);
|
setDemodBuf(BitStream, BitLen, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -774,14 +774,14 @@ int CmdEM4x05Dump(const char *Cmd) {
|
||||||
// for now use default input of 1 as invalid (unlikely 1 will be a valid password...)
|
// for now use default input of 1 as invalid (unlikely 1 will be a valid password...)
|
||||||
pwd = param_get32ex(Cmd, 0, 1, 16);
|
pwd = param_get32ex(Cmd, 0, 1, 16);
|
||||||
|
|
||||||
if ( pwd != 1 ) {
|
if ( pwd != 1 )
|
||||||
usePwd = true;
|
usePwd = true;
|
||||||
}
|
|
||||||
int success = 1;
|
int success = 1;
|
||||||
for (; addr < 16; addr++) {
|
for (; addr < 16; addr++) {
|
||||||
if (addr == 2) {
|
if (addr == 2) {
|
||||||
if (usePwd) {
|
if (usePwd) {
|
||||||
PrintAndLog("PWD Address %02u | %08X",addr,pwd);
|
PrintAndLog("PWD Address %02u | %08X", addr, pwd);
|
||||||
} else {
|
} else {
|
||||||
PrintAndLog("PWD Address 02 | cannot read");
|
PrintAndLog("PWD Address 02 | cannot read");
|
||||||
}
|
}
|
||||||
|
@ -792,7 +792,7 @@ int CmdEM4x05Dump(const char *Cmd) {
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
//ICEMAN; mentalnote to self: -1 is not doable for uint32_t..
|
||||||
int CmdEM4x05Read(const char *Cmd) {
|
int CmdEM4x05Read(const char *Cmd) {
|
||||||
int addr, pwd;
|
int addr, pwd;
|
||||||
bool usePwd = false;
|
bool usePwd = false;
|
||||||
|
|
|
@ -615,6 +615,7 @@ bool tryDetectModulation(){
|
||||||
tests[hits].ST = FALSE;
|
tests[hits].ST = FALSE;
|
||||||
++hits;
|
++hits;
|
||||||
}
|
}
|
||||||
|
//ICEMAN: are these PSKDemod calls needed?
|
||||||
// PSK2 - needs a call to psk1TOpsk2.
|
// PSK2 - needs a call to psk1TOpsk2.
|
||||||
if ( PSKDemod("0 0 6", FALSE)) {
|
if ( PSKDemod("0 0 6", FALSE)) {
|
||||||
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
psk1TOpsk2(DemodBuffer, DemodBufferLen);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue