mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-20 12:07:05 +08:00
bit names refactoring
This commit is contained in:
parent
a18e50b18a
commit
6bb71fb860
2 changed files with 18 additions and 11 deletions
|
@ -244,37 +244,36 @@ static uint8_t TexcomTK17CRC(uint8_t* data) {
|
|||
inline int TexcomTK17Get2Bits(uint32_t len1, uint32_t len2) {
|
||||
uint32_t xlen = (len2 * 100) / (len1 + len2);
|
||||
if (xlen < 10 || xlen > 90)
|
||||
return -1;
|
||||
return TK17WrongBit;
|
||||
if (xlen < 30)
|
||||
return 0;
|
||||
return TK17Bit00;
|
||||
if (xlen < 50)
|
||||
return 2;
|
||||
return TK17Bit10;
|
||||
if (xlen < 70)
|
||||
return 1;
|
||||
return 3;
|
||||
return TK17Bit01;
|
||||
return TK17Bit11;
|
||||
}
|
||||
|
||||
|
||||
static bool TexcomTK17Decode(uint32_t* implengths, uint32_t implengthslen, char* bitstring, char* cbitstring, bool verbose) {
|
||||
bitstring[0] = 0;
|
||||
cbitstring[0] = 0;
|
||||
|
||||
for (uint32_t i = 0; i < implengthslen; i = i + 2) {
|
||||
int dbit = TexcomTK17Get2Bits(implengths[i], implengths[i + 1]);
|
||||
if (dbit < 0)
|
||||
if (dbit == TK17WrongBit)
|
||||
return false;
|
||||
|
||||
switch (dbit) {
|
||||
case 0:
|
||||
case TK17Bit00:
|
||||
strcat(bitstring, "00");
|
||||
break;
|
||||
case 1:
|
||||
case TK17Bit01:
|
||||
strcat(bitstring, "01");
|
||||
break;
|
||||
case 2:
|
||||
case TK17Bit10:
|
||||
strcat(bitstring, "10");
|
||||
break;
|
||||
case 3:
|
||||
case TK17Bit11:
|
||||
strcat(bitstring, "11");
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -22,6 +22,14 @@
|
|||
#include "common.h"
|
||||
#include "pm3_cmd.h"
|
||||
|
||||
enum TK17Bits {
|
||||
TK17WrongBit,
|
||||
TK17Bit00,
|
||||
TK17Bit01,
|
||||
TK17Bit10,
|
||||
TK17Bit11
|
||||
};
|
||||
|
||||
int CmdHFTexkom(const char *Cmd);
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue