mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-11 18:33:18 +08:00
Merge branch 'master' of https://github.com/Proxmark/proxmark3
This commit is contained in:
commit
bf8328e928
1 changed files with 30 additions and 31 deletions
|
@ -592,41 +592,40 @@ uint32_t bytebits_to_byte(uint8_t* src, int numbits)
|
||||||
|
|
||||||
int IOdemodFSK(uint8_t *dest, size_t size)
|
int IOdemodFSK(uint8_t *dest, size_t size)
|
||||||
{
|
{
|
||||||
|
static const uint8_t THRESHOLD = 140;
|
||||||
uint32_t idx=0;
|
uint32_t idx=0;
|
||||||
//make sure buffer has data
|
//make sure buffer has data
|
||||||
if (size < 66) return -1;
|
if (size < 66) return -1;
|
||||||
//test samples are not just noise
|
//test samples are not just noise
|
||||||
uint8_t testMax=0;
|
uint8_t justNoise = 1;
|
||||||
for(idx=0;idx<65;idx++){
|
for(idx=0;idx< size && justNoise ;idx++){
|
||||||
if (testMax<dest[idx]) testMax=dest[idx];
|
justNoise = dest[idx] < THRESHOLD;
|
||||||
}
|
}
|
||||||
idx=0;
|
if(justNoise) return 0;
|
||||||
//if not just noise
|
|
||||||
if (testMax>20){
|
// FSK demodulator
|
||||||
// FSK demodulator
|
size = fskdemod(dest, size,64,1,10,8); // RF/64 and invert
|
||||||
size = fskdemod(dest, size,64,1,10,8); // RF/64 and invert
|
if (size < 65) return -1; //did we get a good demod?
|
||||||
if (size < 65) return -1; //did we get a good demod?
|
//Index map
|
||||||
//Index map
|
//0 10 20 30 40 50 60
|
||||||
//0 10 20 30 40 50 60
|
//| | | | | | |
|
||||||
//| | | | | | |
|
//01234567 8 90123456 7 89012345 6 78901234 5 67890123 4 56789012 3 45678901 23
|
||||||
//01234567 8 90123456 7 89012345 6 78901234 5 67890123 4 56789012 3 45678901 23
|
//-----------------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------------
|
//00000000 0 11110000 1 facility 1 version* 1 code*one 1 code*two 1 ???????? 11
|
||||||
//00000000 0 11110000 1 facility 1 version* 1 code*one 1 code*two 1 ???????? 11
|
//
|
||||||
//
|
//XSF(version)facility:codeone+codetwo
|
||||||
//XSF(version)facility:codeone+codetwo
|
//Handle the data
|
||||||
//Handle the data
|
uint8_t mask[] = {0,0,0,0,0,0,0,0,0,1};
|
||||||
uint8_t mask[] = {0,0,0,0,0,0,0,0,0,1};
|
for( idx=0; idx < (size - 65); idx++) {
|
||||||
for( idx=0; idx < (size - 65); idx++) {
|
if ( memcmp(dest + idx, mask, sizeof(mask))==0) {
|
||||||
if ( memcmp(dest + idx, mask, sizeof(mask))==0) {
|
//frame marker found
|
||||||
//frame marker found
|
if (!dest[idx+8] && dest[idx+17]==1 && dest[idx+26]==1 && dest[idx+35]==1 && dest[idx+44]==1 && dest[idx+53]==1){
|
||||||
if (!dest[idx+8] && dest[idx+17]==1 && dest[idx+26]==1 && dest[idx+35]==1 && dest[idx+44]==1 && dest[idx+53]==1){
|
//confirmed proper separator bits found
|
||||||
//confirmed proper separator bits found
|
//return start position
|
||||||
//return start position
|
return (int) idx;
|
||||||
return (int) idx;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue