chg: 'lf hitag' - don't send garbage (@marshmellow42)

This commit is contained in:
iceman1001 2017-11-11 01:31:45 +01:00
commit 8f4c96cc81

View file

@ -1211,19 +1211,19 @@ void SimulateHitagTag(bool tag_mem_supplied, byte_t* data) {
}
void ReaderHitag(hitag_function htf, hitag_data* htd) {
int frame_count;
int response;
int frame_count = 0;
int response = 0;
byte_t rx[HITAG_FRAME_LEN];
size_t rxlen = 0;
byte_t txbuf[HITAG_FRAME_LEN];
byte_t* tx = txbuf;
size_t txlen = 0;
int lastbit;
int lastbit = 1;
bool bSkip;
int reset_sof;
int tag_sof;
int t_wait = HITAG_T_WAIT_MAX;
bool bStop;
bool bStop = false;
bool bQuitTraceFull = false;
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
@ -1330,12 +1330,6 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
// Reset the received frame, frame count and timing info
frame_count = 0;
response = 0;
lastbit = 1;
bStop = false;
// Tag specific configuration settings (sof, timings, etc.)
if (htf < 10){
// hitagS settings
@ -1442,7 +1436,6 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
bSkip = true;
tag_sof = reset_sof;
response = 0;
//Dbprintf("DEBUG: Waiting to receive frame");
uint32_t errorCount = 0;
// Receive frame, watch for at most T0*EOF periods
@ -1511,8 +1504,12 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
// Dbprintf("DONE: frame received: %d",frame_count);
if ( bSuccessful )
cmd_send(CMD_ACK, bSuccessful, 0, 0, (byte_t*)tag.sectors, 48);
else
cmd_send(CMD_ACK, bSuccessful, 0, 0, 0, 0);
set_tracing(false);
}
@ -1544,8 +1541,7 @@ void WriterHitag(hitag_function htf, hitag_data* htd, int page) {
// Check configuration
switch(htf) {
case WHT2F_CRYPTO:
{
case WHT2F_CRYPTO: {
DbpString("Authenticating using key:");
memcpy(key,htd->crypto.key,6); //HACK; 4 or 6?? I read both in the code.
memcpy(writedata, htd->crypto.data, 4);