mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
minor changes to iso15693.c to get rid off all the compile warnings
This commit is contained in:
parent
ad2a97824d
commit
f7c64b570c
1 changed files with 82 additions and 118 deletions
|
@ -21,12 +21,9 @@
|
||||||
// to the FPGA, to transmit that command to the tag.
|
// to the FPGA, to transmit that command to the tag.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The sampling rate is 106.353 ksps/s, for T = 18.8 us
|
// The sampling rate is 106.353 ksps/s, for T = 18.8 us
|
||||||
|
|
||||||
// SOF defined as
|
// SOF defined as
|
||||||
// 1) Unmodulated time of 56.64us
|
// 1) Unmodulated time of 56.64us
|
||||||
// 2) 24 pulses of 423.75khz
|
// 2) 24 pulses of 423.75khz
|
||||||
// 3) logic '1' (unmodulated for 18.88us followed by 8 pulses of 423.75khz)
|
// 3) logic '1' (unmodulated for 18.88us followed by 8 pulses of 423.75khz)
|
||||||
|
@ -54,7 +51,7 @@
|
||||||
1, 1, 1, 1
|
1, 1, 1, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
// EOF defined as
|
// EOF defined as
|
||||||
// 1) logic '0' (8 pulses of 423.75khz followed by unmodulated for 18.88us)
|
// 1) logic '0' (8 pulses of 423.75khz followed by unmodulated for 18.88us)
|
||||||
// 2) 24 pulses of 423.75khz
|
// 2) 24 pulses of 423.75khz
|
||||||
// 3) Unmodulated time of 56.64us
|
// 3) Unmodulated time of 56.64us
|
||||||
|
@ -70,9 +67,6 @@
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void CodeIso15693AsReader(BYTE *cmd, int n)
|
static void CodeIso15693AsReader(BYTE *cmd, int n)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -173,9 +167,19 @@ static WORD Crc(BYTE *v, int n)
|
||||||
return ~reg;
|
return ~reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////// code to do 'itoa'
|
char *strcat(char *dest, const char *src)
|
||||||
|
{
|
||||||
|
size_t dest_len = strlen(dest);
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0 ; src[i] != '\0' ; i++)
|
||||||
|
dest[dest_len + i] = src[i];
|
||||||
|
dest[dest_len + i] = '\0';
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////// code to do 'itoa'
|
||||||
|
|
||||||
/* reverse: reverse string s in place */
|
/* reverse: reverse string s in place */
|
||||||
void reverse(char s[])
|
void reverse(char s[])
|
||||||
|
@ -204,11 +208,10 @@ void itoa(int n, char s[])
|
||||||
s[i++] = '-';
|
s[i++] = '-';
|
||||||
s[i] = '\0';
|
s[i] = '\0';
|
||||||
reverse(s);
|
reverse(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////// END 'itoa' CODE
|
//////////////////////////////////////// END 'itoa' CODE
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Encode (into the ToSend buffers) an identify request, which is the first
|
// Encode (into the ToSend buffers) an identify request, which is the first
|
||||||
// thing that you must send to a tag to get a response.
|
// thing that you must send to a tag to get a response.
|
||||||
|
@ -220,7 +223,7 @@ static void BuildIdentifyRequest(void)
|
||||||
WORD crc;
|
WORD crc;
|
||||||
// one sub-carrier, inventory, 1 slot, fast rate
|
// one sub-carrier, inventory, 1 slot, fast rate
|
||||||
// AFI is at bit 5 (1<<4) when doing an INVENTORY
|
// AFI is at bit 5 (1<<4) when doing an INVENTORY
|
||||||
cmd[0] = (1 << 2) | (1 << 5) | (1 << 1);
|
cmd[0] = (1 << 2) | (1 << 5) | (1 << 1);
|
||||||
// inventory command code
|
// inventory command code
|
||||||
cmd[1] = 0x01;
|
cmd[1] = 0x01;
|
||||||
// no mask
|
// no mask
|
||||||
|
@ -252,10 +255,10 @@ static void BuildSysInfoRequest(BYTE *uid)
|
||||||
cmd[5] = 0x01;
|
cmd[5] = 0x01;
|
||||||
cmd[6] = 0x00;
|
cmd[6] = 0x00;
|
||||||
cmd[7] = 0x10;
|
cmd[7] = 0x10;
|
||||||
cmd[8] = 0x05;
|
cmd[8] = 0x05;
|
||||||
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
||||||
//Now the CRC
|
//Now the CRC
|
||||||
crc = Crc(cmd, 10); // the crc needs to be calculated over 2 bytes
|
crc = Crc(cmd, 10); // the crc needs to be calculated over 2 bytes
|
||||||
cmd[10] = crc & 0xff;
|
cmd[10] = crc & 0xff;
|
||||||
cmd[11] = crc >> 8;
|
cmd[11] = crc >> 8;
|
||||||
|
|
||||||
|
@ -264,7 +267,7 @@ static void BuildSysInfoRequest(BYTE *uid)
|
||||||
|
|
||||||
static void BuildSelectRequest( BYTE uid[])
|
static void BuildSelectRequest( BYTE uid[])
|
||||||
{
|
{
|
||||||
|
|
||||||
// uid[6]=0x31; // this is getting ignored - the uid array is not happening...
|
// uid[6]=0x31; // this is getting ignored - the uid array is not happening...
|
||||||
BYTE cmd[12];
|
BYTE cmd[12];
|
||||||
|
|
||||||
|
@ -281,20 +284,20 @@ static void BuildSelectRequest( BYTE uid[])
|
||||||
// cmd[5] = uid[3];//0x01;
|
// cmd[5] = uid[3];//0x01;
|
||||||
// cmd[6] = uid[4];//0x00;
|
// cmd[6] = uid[4];//0x00;
|
||||||
// cmd[7] = uid[5];//0x10;
|
// cmd[7] = uid[5];//0x10;
|
||||||
// cmd[8] = uid[6];//0x05;
|
// cmd[8] = uid[6];//0x05;
|
||||||
cmd[2] = 0x32;//
|
cmd[2] = 0x32;//
|
||||||
cmd[3]= 0x4b;
|
cmd[3] = 0x4b;
|
||||||
cmd[4] = 0x03;
|
cmd[4] = 0x03;
|
||||||
cmd[5] = 0x01;
|
cmd[5] = 0x01;
|
||||||
cmd[6] = 0x00;
|
cmd[6] = 0x00;
|
||||||
cmd[7] = 0x10;
|
cmd[7] = 0x10;
|
||||||
cmd[8] = 0x05; // infineon?
|
cmd[8] = 0x05; // infineon?
|
||||||
|
|
||||||
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
||||||
|
|
||||||
// DbpIntegers(cmd[8],cmd[7],cmd[6]);
|
// DbpIntegers(cmd[8],cmd[7],cmd[6]);
|
||||||
// Now the CRC
|
// Now the CRC
|
||||||
crc = Crc(cmd, 10); // the crc needs to be calculated over 10 bytes
|
crc = Crc(cmd, 10); // the crc needs to be calculated over 10 bytes
|
||||||
cmd[10] = crc & 0xff;
|
cmd[10] = crc & 0xff;
|
||||||
cmd[11] = crc >> 8;
|
cmd[11] = crc >> 8;
|
||||||
|
|
||||||
|
@ -320,19 +323,18 @@ static void BuildReadBlockRequest(BYTE *uid, BYTE blockNumber )
|
||||||
cmd[5] = 0x01;
|
cmd[5] = 0x01;
|
||||||
cmd[6] = 0x00;
|
cmd[6] = 0x00;
|
||||||
cmd[7] = 0x10;
|
cmd[7] = 0x10;
|
||||||
cmd[8] = 0x05;
|
cmd[8] = 0x05;
|
||||||
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
||||||
// Block number to read
|
// Block number to read
|
||||||
cmd[10] = blockNumber;//0x00;
|
cmd[10] = blockNumber;//0x00;
|
||||||
//Now the CRC
|
//Now the CRC
|
||||||
crc = Crc(cmd, 11); // the crc needs to be calculated over 2 bytes
|
crc = Crc(cmd, 11); // the crc needs to be calculated over 2 bytes
|
||||||
cmd[11] = crc & 0xff;
|
cmd[11] = crc & 0xff;
|
||||||
cmd[12] = crc >> 8;
|
cmd[12] = crc >> 8;
|
||||||
|
|
||||||
CodeIso15693AsReader(cmd, sizeof(cmd));
|
CodeIso15693AsReader(cmd, sizeof(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void BuildReadMultiBlockRequest(BYTE *uid)
|
static void BuildReadMultiBlockRequest(BYTE *uid)
|
||||||
{
|
{
|
||||||
BYTE cmd[14];
|
BYTE cmd[14];
|
||||||
|
@ -352,14 +354,14 @@ static void BuildReadMultiBlockRequest(BYTE *uid)
|
||||||
cmd[5] = 0x01;
|
cmd[5] = 0x01;
|
||||||
cmd[6] = 0x00;
|
cmd[6] = 0x00;
|
||||||
cmd[7] = 0x10;
|
cmd[7] = 0x10;
|
||||||
cmd[8] = 0x05;
|
cmd[8] = 0x05;
|
||||||
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
||||||
// First Block number to read
|
// First Block number to read
|
||||||
cmd[10] = 0x00;
|
cmd[10] = 0x00;
|
||||||
// Number of Blocks to read
|
// Number of Blocks to read
|
||||||
cmd[11] = 0x2f; // read quite a few
|
cmd[11] = 0x2f; // read quite a few
|
||||||
//Now the CRC
|
//Now the CRC
|
||||||
crc = Crc(cmd, 12); // the crc needs to be calculated over 2 bytes
|
crc = Crc(cmd, 12); // the crc needs to be calculated over 2 bytes
|
||||||
cmd[12] = crc & 0xff;
|
cmd[12] = crc & 0xff;
|
||||||
cmd[13] = crc >> 8;
|
cmd[13] = crc >> 8;
|
||||||
|
|
||||||
|
@ -385,22 +387,22 @@ static void BuildArbitraryRequest(BYTE *uid,BYTE CmdCode)
|
||||||
cmd[5] = 0x01;
|
cmd[5] = 0x01;
|
||||||
cmd[6] = 0x00;
|
cmd[6] = 0x00;
|
||||||
cmd[7] = 0x10;
|
cmd[7] = 0x10;
|
||||||
cmd[8] = 0x05;
|
cmd[8] = 0x05;
|
||||||
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
||||||
// Parameter
|
// Parameter
|
||||||
cmd[10] = 0x00;
|
cmd[10] = 0x00;
|
||||||
cmd[11] = 0x0a;
|
cmd[11] = 0x0a;
|
||||||
|
|
||||||
// cmd[12] = 0x00;
|
// cmd[12] = 0x00;
|
||||||
// cmd[13] = 0x00; //Now the CRC
|
// cmd[13] = 0x00; //Now the CRC
|
||||||
crc = Crc(cmd, 12); // the crc needs to be calculated over 2 bytes
|
crc = Crc(cmd, 12); // the crc needs to be calculated over 2 bytes
|
||||||
cmd[12] = crc & 0xff;
|
cmd[12] = crc & 0xff;
|
||||||
cmd[13] = crc >> 8;
|
cmd[13] = crc >> 8;
|
||||||
|
|
||||||
CodeIso15693AsReader(cmd, sizeof(cmd));
|
CodeIso15693AsReader(cmd, sizeof(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BuildArbitraryCustomRequest(BYTE *uid,BYTE CmdCode)
|
static void BuildArbitraryCustomRequest(BYTE uid[], BYTE CmdCode)
|
||||||
{
|
{
|
||||||
BYTE cmd[14];
|
BYTE cmd[14];
|
||||||
|
|
||||||
|
@ -419,15 +421,15 @@ static void BuildArbitraryCustomRequest(BYTE *uid,BYTE CmdCode)
|
||||||
cmd[5] = 0x01;
|
cmd[5] = 0x01;
|
||||||
cmd[6] = 0x00;
|
cmd[6] = 0x00;
|
||||||
cmd[7] = 0x10;
|
cmd[7] = 0x10;
|
||||||
cmd[8] = 0x05;
|
cmd[8] = 0x05;
|
||||||
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
cmd[9]= 0xe0; // always e0 (not exactly unique)
|
||||||
// Parameter
|
// Parameter
|
||||||
cmd[10] = 0x05; // for custom codes this must be manufcturer code
|
cmd[10] = 0x05; // for custom codes this must be manufcturer code
|
||||||
cmd[11] = 0x00;
|
cmd[11] = 0x00;
|
||||||
|
|
||||||
// cmd[12] = 0x00;
|
// cmd[12] = 0x00;
|
||||||
// cmd[13] = 0x00; //Now the CRC
|
// cmd[13] = 0x00; //Now the CRC
|
||||||
crc = Crc(cmd, 12); // the crc needs to be calculated over 2 bytes
|
crc = Crc(cmd, 12); // the crc needs to be calculated over 2 bytes
|
||||||
cmd[12] = crc & 0xff;
|
cmd[12] = crc & 0xff;
|
||||||
cmd[13] = crc >> 8;
|
cmd[13] = crc >> 8;
|
||||||
|
|
||||||
|
@ -445,7 +447,7 @@ static void BuildArbitraryCustomRequest(BYTE *uid,BYTE CmdCode)
|
||||||
WORD crc;
|
WORD crc;
|
||||||
// one sub-carrier, inventory, 1 slot, fast rate
|
// one sub-carrier, inventory, 1 slot, fast rate
|
||||||
// AFI is at bit 5 (1<<4) when doing an INVENTORY
|
// AFI is at bit 5 (1<<4) when doing an INVENTORY
|
||||||
cmd[0] = 0; //(1 << 2) | (1 << 5) | (1 << 1);
|
cmd[0] = 0; //(1 << 2) | (1 << 5) | (1 << 1);
|
||||||
cmd[1] = 0;
|
cmd[1] = 0;
|
||||||
// 64-bit UID
|
// 64-bit UID
|
||||||
cmd[2] = 0x32;
|
cmd[2] = 0x32;
|
||||||
|
@ -454,7 +456,7 @@ static void BuildArbitraryCustomRequest(BYTE *uid,BYTE CmdCode)
|
||||||
cmd[5] = 0x01;
|
cmd[5] = 0x01;
|
||||||
cmd[6] = 0x00;
|
cmd[6] = 0x00;
|
||||||
cmd[7] = 0x10;
|
cmd[7] = 0x10;
|
||||||
cmd[8] = 0x05;
|
cmd[8] = 0x05;
|
||||||
cmd[9]= 0xe0;
|
cmd[9]= 0xe0;
|
||||||
//Now the CRC
|
//Now the CRC
|
||||||
crc = Crc(cmd, 10);
|
crc = Crc(cmd, 10);
|
||||||
|
@ -464,7 +466,6 @@ static void BuildArbitraryCustomRequest(BYTE *uid,BYTE CmdCode)
|
||||||
CodeIso15693AsReader(cmd, sizeof(cmd));
|
CodeIso15693AsReader(cmd, sizeof(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Transmit the command (to the tag) that was placed in ToSend[].
|
// Transmit the command (to the tag) that was placed in ToSend[].
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -506,7 +507,6 @@ static void TransmitTo15693Tag(const BYTE *cmd, int len, int *samples, int *wait
|
||||||
*samples = (c + *wait) << 3;
|
*samples = (c + *wait) << 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Transmit the command (to the reader) that was placed in ToSend[].
|
// Transmit the command (to the reader) that was placed in ToSend[].
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -536,18 +536,12 @@ static void TransmitTo15693Reader(const BYTE *cmd, int len, int *samples, int *w
|
||||||
*samples = (c + *wait) << 3;
|
*samples = (c + *wait) << 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int GetIso15693AnswerFromTag(BYTE *receivedResponse, int maxLen, int *samples, int *elapsed)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int GetIso15693AnswerFromTag(BYTE *receivedResponse, int maxLen, int *samples, int *elapsed)
|
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
BYTE *dest = (BYTE *)BigBuf;
|
BYTE *dest = (BYTE *)BigBuf;
|
||||||
int getNext = 0;
|
int getNext = 0;
|
||||||
|
|
||||||
|
|
||||||
SBYTE prev = 0;
|
SBYTE prev = 0;
|
||||||
|
|
||||||
// NOW READ RESPONSE
|
// NOW READ RESPONSE
|
||||||
|
@ -599,11 +593,10 @@ static int GetIso15693AnswerFromTag(BYTE *receivedResponse, int maxLen, int *sam
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
int max = 0, maxPos;
|
int max = 0, maxPos=0;
|
||||||
|
|
||||||
int skip = 4;
|
int skip = 4;
|
||||||
|
|
||||||
|
|
||||||
// if(GraphTraceLen < 1000) return; // THIS CHECKS FOR A BUFFER TO SMALL
|
// if(GraphTraceLen < 1000) return; // THIS CHECKS FOR A BUFFER TO SMALL
|
||||||
|
|
||||||
// First, correlate for SOF
|
// First, correlate for SOF
|
||||||
|
@ -622,11 +615,11 @@ static int GetIso15693AnswerFromTag(BYTE *receivedResponse, int maxLen, int *sam
|
||||||
int k = 0; // this will be our return value
|
int k = 0; // this will be our return value
|
||||||
|
|
||||||
// greg - If correlation is less than 1 then there's little point in continuing
|
// greg - If correlation is less than 1 then there's little point in continuing
|
||||||
if ((max/(arraylen(FrameSOF)/skip)) >= 1)
|
if ((max/(arraylen(FrameSOF)/skip)) >= 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
i = maxPos + arraylen(FrameSOF)/skip;
|
i = maxPos + arraylen(FrameSOF)/skip;
|
||||||
|
|
||||||
BYTE outBuf[20];
|
BYTE outBuf[20];
|
||||||
memset(outBuf, 0, sizeof(outBuf));
|
memset(outBuf, 0, sizeof(outBuf));
|
||||||
BYTE mask = 0x01;
|
BYTE mask = 0x01;
|
||||||
|
@ -681,23 +674,21 @@ static int GetIso15693AnswerFromTag(BYTE *receivedResponse, int maxLen, int *sam
|
||||||
|
|
||||||
for(i = 0; i < k; i++) {
|
for(i = 0; i < k; i++) {
|
||||||
receivedResponse[i] = outBuf[i];
|
receivedResponse[i] = outBuf[i];
|
||||||
}
|
}
|
||||||
} // "end if correlation > 0" (max/(arraylen(FrameSOF)/skip))
|
} // "end if correlation > 0" (max/(arraylen(FrameSOF)/skip))
|
||||||
return k; // return the number of bytes demodulated
|
return k; // return the number of bytes demodulated
|
||||||
|
|
||||||
/// DbpString("CRC=%04x", Iso15693Crc(outBuf, k-2));
|
/// DbpString("CRC=%04x", Iso15693Crc(outBuf, k-2));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now the GetISO15693 message from sniffing command
|
// Now the GetISO15693 message from sniffing command
|
||||||
static int GetIso15693AnswerFromSniff(BYTE *receivedResponse, int maxLen, int *samples, int *elapsed)
|
static int GetIso15693AnswerFromSniff(BYTE *receivedResponse, int maxLen, int *samples, int *elapsed)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
BYTE *dest = (BYTE *)BigBuf;
|
BYTE *dest = (BYTE *)BigBuf;
|
||||||
int getNext = 0;
|
int getNext = 0;
|
||||||
|
|
||||||
|
|
||||||
SBYTE prev = 0;
|
SBYTE prev = 0;
|
||||||
|
|
||||||
// NOW READ RESPONSE
|
// NOW READ RESPONSE
|
||||||
|
@ -749,11 +740,10 @@ static int GetIso15693AnswerFromSniff(BYTE *receivedResponse, int maxLen, int *s
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
int max = 0, maxPos;
|
int max = 0, maxPos=0;
|
||||||
|
|
||||||
int skip = 4;
|
int skip = 4;
|
||||||
|
|
||||||
|
|
||||||
// if(GraphTraceLen < 1000) return; // THIS CHECKS FOR A BUFFER TO SMALL
|
// if(GraphTraceLen < 1000) return; // THIS CHECKS FOR A BUFFER TO SMALL
|
||||||
|
|
||||||
// First, correlate for SOF
|
// First, correlate for SOF
|
||||||
|
@ -772,11 +762,11 @@ static int GetIso15693AnswerFromSniff(BYTE *receivedResponse, int maxLen, int *s
|
||||||
int k = 0; // this will be our return value
|
int k = 0; // this will be our return value
|
||||||
|
|
||||||
// greg - If correlation is less than 1 then there's little point in continuing
|
// greg - If correlation is less than 1 then there's little point in continuing
|
||||||
if ((max/(arraylen(FrameSOF)/skip)) >= 1) // THIS SHOULD BE 1
|
if ((max/(arraylen(FrameSOF)/skip)) >= 1) // THIS SHOULD BE 1
|
||||||
{
|
{
|
||||||
|
|
||||||
i = maxPos + arraylen(FrameSOF)/skip;
|
i = maxPos + arraylen(FrameSOF)/skip;
|
||||||
|
|
||||||
BYTE outBuf[20];
|
BYTE outBuf[20];
|
||||||
memset(outBuf, 0, sizeof(outBuf));
|
memset(outBuf, 0, sizeof(outBuf));
|
||||||
BYTE mask = 0x01;
|
BYTE mask = 0x01;
|
||||||
|
@ -831,17 +821,13 @@ static int GetIso15693AnswerFromSniff(BYTE *receivedResponse, int maxLen, int *s
|
||||||
|
|
||||||
for(i = 0; i < k; i++) {
|
for(i = 0; i < k; i++) {
|
||||||
receivedResponse[i] = outBuf[i];
|
receivedResponse[i] = outBuf[i];
|
||||||
}
|
}
|
||||||
} // "end if correlation > 0" (max/(arraylen(FrameSOF)/skip))
|
} // "end if correlation > 0" (max/(arraylen(FrameSOF)/skip))
|
||||||
return k; // return the number of bytes demodulated
|
return k; // return the number of bytes demodulated
|
||||||
|
|
||||||
/// DbpString("CRC=%04x", Iso15693Crc(outBuf, k-2));
|
/// DbpString("CRC=%04x", Iso15693Crc(outBuf, k-2));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Start to read an ISO 15693 tag. We send an identify request, then wait
|
// Start to read an ISO 15693 tag. We send an identify request, then wait
|
||||||
// for the response. The response is not demodulated, just left in the buffer
|
// for the response. The response is not demodulated, just left in the buffer
|
||||||
|
@ -927,8 +913,6 @@ void AcquireRawAdcSamplesIso15693(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Simulate an ISO15693 reader, perform anti-collision and then attempt to read a sector
|
// Simulate an ISO15693 reader, perform anti-collision and then attempt to read a sector
|
||||||
// all demodulation performed in arm rather than host. - greg
|
// all demodulation performed in arm rather than host. - greg
|
||||||
|
@ -940,15 +924,14 @@ void ReaderIso15693(DWORD parameter)
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
LED_D_OFF();
|
LED_D_OFF();
|
||||||
|
|
||||||
|
|
||||||
//DbpString(parameter);
|
//DbpString(parameter);
|
||||||
|
|
||||||
BYTE *receivedAnswer0 = (((BYTE *)BigBuf) + 3560); // allow 100 bytes per reponse (way too much)
|
BYTE *receivedAnswer0 = (((BYTE *)BigBuf) + 3560); // allow 100 bytes per reponse (way too much)
|
||||||
BYTE *receivedAnswer1 = (((BYTE *)BigBuf) + 3660); //
|
BYTE *receivedAnswer1 = (((BYTE *)BigBuf) + 3660); //
|
||||||
BYTE *receivedAnswer2 = (((BYTE *)BigBuf) + 3760);
|
BYTE *receivedAnswer2 = (((BYTE *)BigBuf) + 3760);
|
||||||
BYTE *receivedAnswer3 = (((BYTE *)BigBuf) + 3860);
|
BYTE *receivedAnswer3 = (((BYTE *)BigBuf) + 3860);
|
||||||
//BYTE *TagUID= (((BYTE *)BigBuf) + 3960); // where we hold the uid for hi15reader
|
//BYTE *TagUID= (((BYTE *)BigBuf) + 3960); // where we hold the uid for hi15reader
|
||||||
int responseLen0 = 0;
|
// int responseLen0 = 0;
|
||||||
int responseLen1 = 0;
|
int responseLen1 = 0;
|
||||||
int responseLen2 = 0;
|
int responseLen2 = 0;
|
||||||
int responseLen3 = 0;
|
int responseLen3 = 0;
|
||||||
|
@ -988,14 +971,13 @@ void ReaderIso15693(DWORD parameter)
|
||||||
|
|
||||||
// FIRST WE RUN AN INVENTORY TO GET THE TAG UID
|
// FIRST WE RUN AN INVENTORY TO GET THE TAG UID
|
||||||
// THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME
|
// THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME
|
||||||
BYTE TagUID[7]; // where we hold the uid for hi15reader
|
BYTE TagUID[7]; // where we hold the uid for hi15reader
|
||||||
|
|
||||||
|
|
||||||
// BuildIdentifyRequest();
|
// BuildIdentifyRequest();
|
||||||
// //TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);
|
// //TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);
|
||||||
// TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
// TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
||||||
// // Now wait for a response
|
// // Now wait for a response
|
||||||
// responseLen0 = GetIso15693AnswerFromTag(receivedAnswer0, 100, &samples, &elapsed) ;
|
// responseLen0 = GetIso15693AnswerFromTag(receivedAnswer0, 100, &samples, &elapsed) ;
|
||||||
// if (responseLen0 >=12) // we should do a better check than this
|
// if (responseLen0 >=12) // we should do a better check than this
|
||||||
// {
|
// {
|
||||||
// // really we should check it is a valid mesg
|
// // really we should check it is a valid mesg
|
||||||
|
@ -1007,19 +989,19 @@ void ReaderIso15693(DWORD parameter)
|
||||||
// TagUID[4] = receivedAnswer0[6];
|
// TagUID[4] = receivedAnswer0[6];
|
||||||
// TagUID[5] = receivedAnswer0[7];
|
// TagUID[5] = receivedAnswer0[7];
|
||||||
// TagUID[6] = receivedAnswer0[8]; // IC Manufacturer code
|
// TagUID[6] = receivedAnswer0[8]; // IC Manufacturer code
|
||||||
// DbpIntegers(TagUID[6],TagUID[5],TagUID[4]);
|
// DbpIntegers(TagUID[6],TagUID[5],TagUID[4]);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// Now send the IDENTIFY command
|
// Now send the IDENTIFY command
|
||||||
BuildIdentifyRequest();
|
BuildIdentifyRequest();
|
||||||
//TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);
|
//TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);
|
||||||
TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
||||||
// Now wait for a response
|
// Now wait for a response
|
||||||
responseLen1 = GetIso15693AnswerFromTag(receivedAnswer1, 100, &samples, &elapsed) ;
|
responseLen1 = GetIso15693AnswerFromTag(receivedAnswer1, 100, &samples, &elapsed) ;
|
||||||
|
|
||||||
if (responseLen1 >=12) // we should do a better check than this
|
if (responseLen1 >=12) // we should do a better check than this
|
||||||
{
|
{
|
||||||
|
|
||||||
TagUID[0] = receivedAnswer1[2];
|
TagUID[0] = receivedAnswer1[2];
|
||||||
TagUID[1] = receivedAnswer1[3];
|
TagUID[1] = receivedAnswer1[3];
|
||||||
TagUID[2] = receivedAnswer1[4];
|
TagUID[2] = receivedAnswer1[4];
|
||||||
|
@ -1027,28 +1009,26 @@ void ReaderIso15693(DWORD parameter)
|
||||||
TagUID[4] = receivedAnswer1[6];
|
TagUID[4] = receivedAnswer1[6];
|
||||||
TagUID[5] = receivedAnswer1[7];
|
TagUID[5] = receivedAnswer1[7];
|
||||||
TagUID[6] = receivedAnswer1[8]; // IC Manufacturer code
|
TagUID[6] = receivedAnswer1[8]; // IC Manufacturer code
|
||||||
|
|
||||||
// Now send the SELECT command
|
// Now send the SELECT command
|
||||||
BuildSelectRequest(*TagUID);
|
BuildSelectRequest(TagUID);
|
||||||
TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
||||||
// Now wait for a response
|
// Now wait for a response
|
||||||
responseLen2 = GetIso15693AnswerFromTag(receivedAnswer2, 100, &samples, &elapsed);
|
responseLen2 = GetIso15693AnswerFromTag(receivedAnswer2, 100, &samples, &elapsed);
|
||||||
|
|
||||||
// Now send the MULTI READ command
|
// Now send the MULTI READ command
|
||||||
// BuildArbitraryRequest(*TagUID,parameter);
|
// BuildArbitraryRequest(*TagUID,parameter);
|
||||||
BuildArbitraryCustomRequest(*TagUID,parameter);
|
BuildArbitraryCustomRequest(TagUID,parameter);
|
||||||
// BuildReadBlockRequest(*TagUID,parameter);
|
// BuildReadBlockRequest(*TagUID,parameter);
|
||||||
// BuildSysInfoRequest(*TagUID);
|
// BuildSysInfoRequest(*TagUID);
|
||||||
//TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);
|
//TransmitTo15693Tag(ToSend,ToSendMax+3,&tsamples, &wait);
|
||||||
TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
||||||
// Now wait for a response
|
// Now wait for a response
|
||||||
responseLen3 = GetIso15693AnswerFromTag(receivedAnswer3, 100, &samples, &elapsed) ;
|
responseLen3 = GetIso15693AnswerFromTag(receivedAnswer3, 100, &samples, &elapsed) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char str1 [4];
|
||||||
|
|
||||||
BYTE str1 [4];
|
|
||||||
//char str2 [200];
|
//char str2 [200];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1072,25 +1052,20 @@ void ReaderIso15693(DWORD parameter)
|
||||||
for(i = 0; i < responseLen3; i+=3) {
|
for(i = 0; i < responseLen3; i+=3) {
|
||||||
DbpIntegers(receivedAnswer3[i],receivedAnswer3[i+1],receivedAnswer3[i+2]);
|
DbpIntegers(receivedAnswer3[i],receivedAnswer3[i+1],receivedAnswer3[i+2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// str2[0]=0;
|
// str2[0]=0;
|
||||||
// for(i = 0; i < responseLen3; i++) {
|
// for(i = 0; i < responseLen3; i++) {
|
||||||
// itoa(str1,receivedAnswer3[i]);
|
// itoa(str1,receivedAnswer3[i]);
|
||||||
// strcat(str2,str1);
|
// strcat(str2,str1);
|
||||||
// }
|
// }
|
||||||
// DbpString(str2);
|
// DbpString(str2);
|
||||||
|
|
||||||
LED_A_OFF();
|
LED_A_OFF();
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
LED_D_OFF();
|
LED_D_OFF();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Simulate an ISO15693 TAG, perform anti-collision and then print any reader commands
|
// Simulate an ISO15693 TAG, perform anti-collision and then print any reader commands
|
||||||
// all demodulation performed in arm rather than host. - greg
|
// all demodulation performed in arm rather than host. - greg
|
||||||
|
@ -1102,18 +1077,17 @@ void SimTagIso15693(DWORD parameter)
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
LED_D_OFF();
|
LED_D_OFF();
|
||||||
|
|
||||||
|
|
||||||
//DbpString(parameter);
|
//DbpString(parameter);
|
||||||
|
|
||||||
BYTE *receivedAnswer0 = (((BYTE *)BigBuf) + 3560); // allow 100 bytes per reponse (way too much)
|
BYTE *receivedAnswer0 = (((BYTE *)BigBuf) + 3560); // allow 100 bytes per reponse (way too much)
|
||||||
BYTE *receivedAnswer1 = (((BYTE *)BigBuf) + 3660); //
|
BYTE *receivedAnswer1 = (((BYTE *)BigBuf) + 3660); //
|
||||||
BYTE *receivedAnswer2 = (((BYTE *)BigBuf) + 3760);
|
BYTE *receivedAnswer2 = (((BYTE *)BigBuf) + 3760);
|
||||||
BYTE *receivedAnswer3 = (((BYTE *)BigBuf) + 3860);
|
BYTE *receivedAnswer3 = (((BYTE *)BigBuf) + 3860);
|
||||||
//BYTE *TagUID= (((BYTE *)BigBuf) + 3960); // where we hold the uid for hi15reader
|
//BYTE *TagUID= (((BYTE *)BigBuf) + 3960); // where we hold the uid for hi15reader
|
||||||
int responseLen0 = 0;
|
// int responseLen0 = 0;
|
||||||
int responseLen1 = 0;
|
int responseLen1 = 0;
|
||||||
int responseLen2 = 0;
|
// int responseLen2 = 0;
|
||||||
int responseLen3 = 0;
|
// int responseLen3 = 0;
|
||||||
|
|
||||||
// Blank arrays
|
// Blank arrays
|
||||||
int j;
|
int j;
|
||||||
|
@ -1150,41 +1124,34 @@ void SimTagIso15693(DWORD parameter)
|
||||||
|
|
||||||
// FIRST WE RUN AN INVENTORY TO GET THE TAG UID
|
// FIRST WE RUN AN INVENTORY TO GET THE TAG UID
|
||||||
// THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME
|
// THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME
|
||||||
BYTE TagUID[7]; // where we hold the uid for hi15reader
|
// BYTE TagUID[7]; // where we hold the uid for hi15reader
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Now send the IDENTIFY command
|
// Now send the IDENTIFY command
|
||||||
// BuildIdentifyRequest();
|
// BuildIdentifyRequest();
|
||||||
// TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
// TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait); // No longer ToSendMax+3
|
||||||
|
|
||||||
|
|
||||||
// Now wait for a command from the reader
|
// Now wait for a command from the reader
|
||||||
responseLen1=0;
|
responseLen1=0;
|
||||||
// while(responseLen1=0) {
|
// while(responseLen1=0) {
|
||||||
// if(BUTTON_PRESS()) break;
|
// if(BUTTON_PRESS()) break;
|
||||||
responseLen1 = GetIso15693AnswerFromSniff(receivedAnswer1, 100, &samples, &elapsed) ;
|
responseLen1 = GetIso15693AnswerFromSniff(receivedAnswer1, 100, &samples, &elapsed) ;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
if (responseLen1 >=1) // we should do a better check than this
|
if (responseLen1 >=1) // we should do a better check than this
|
||||||
{
|
{
|
||||||
// Build a suitable reponse to the reader INVENTORY cocmmand
|
// Build a suitable reponse to the reader INVENTORY cocmmand
|
||||||
BuildInventoryResponse;
|
BuildInventoryResponse();
|
||||||
TransmitTo15693Reader(ToSend,ToSendMax,&tsamples, &wait);
|
TransmitTo15693Reader(ToSend,ToSendMax,&tsamples, &wait);
|
||||||
|
|
||||||
// Now wait for a command from the reader
|
// Now wait for a command from the reader
|
||||||
// responseLen2 = GetIso15693AnswerFromTag(receivedAnswer2, 100, &samples, &elapsed);
|
// responseLen2 = GetIso15693AnswerFromTag(receivedAnswer2, 100, &samples, &elapsed);
|
||||||
|
|
||||||
|
|
||||||
// Now wait for a command from the reader
|
// Now wait for a command from the reader
|
||||||
// responseLen3 = GetIso15693AnswerFromTag(receivedAnswer3, 100, &samples, &elapsed) ;
|
// responseLen3 = GetIso15693AnswerFromTag(receivedAnswer3, 100, &samples, &elapsed) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char str1 [4];
|
||||||
|
|
||||||
BYTE str1 [4];
|
|
||||||
//char str2 [200];
|
//char str2 [200];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1208,19 +1175,16 @@ void SimTagIso15693(DWORD parameter)
|
||||||
// for(i = 0; i < responseLen3; i+=3) {
|
// for(i = 0; i < responseLen3; i+=3) {
|
||||||
// DbpIntegers(receivedAnswer3[i],receivedAnswer3[i+1],receivedAnswer3[i+2]);
|
// DbpIntegers(receivedAnswer3[i],receivedAnswer3[i+1],receivedAnswer3[i+2]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// str2[0]=0;
|
// str2[0]=0;
|
||||||
// for(i = 0; i < responseLen3; i++) {
|
// for(i = 0; i < responseLen3; i++) {
|
||||||
// itoa(str1,receivedAnswer3[i]);
|
// itoa(str1,receivedAnswer3[i]);
|
||||||
// strcat(str2,str1);
|
// strcat(str2,str1);
|
||||||
// }
|
// }
|
||||||
// DbpString(str2);
|
// DbpString(str2);
|
||||||
|
|
||||||
LED_A_OFF();
|
LED_A_OFF();
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
LED_D_OFF();
|
LED_D_OFF();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue