Skip to content

Commit

Permalink
Testing code updates with the PM3 -- a few small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxieds committed Jul 15, 2022
1 parent 53de26e commit bfac980
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,14 @@ uint16_t ISO144433APiccProcess(uint8_t *Buffer, uint16_t BitCount) {
ISO144433AHalt();
return ISO14443A_APP_NO_RESPONSE;
} else if (CheckStateRetryCount(false)) {
DEBUG_PRINT_P(PSTR("ISO14443-3: RESETTING -- TOO MANY TRIES"));
ISO144433AReset();
ISO144433ASwitchState(ISO14443_3A_STATE_IDLE);
return ISO14443A_APP_NO_RESPONSE;
/* ??? TODO: Is this the correct action ??? */
DEBUG_PRINT_P(PSTR("ISO14443-3: RESETTING"));
ISO144433AHalt();
Buffer[0] == ISO14443A_CMD_HLTA;
Buffer[1] == 0x00;
ISO14443AAppendCRCA(Buffer, ASBYTES(ISO14443A_HLTA_FRAME_SIZE));
return ISO14443A_HLTA_FRAME_SIZE + ASBITS(ISO14443A_CRCA_SIZE);
//return ISO14443A_APP_NO_RESPONSE;
}

/* This implements ISO 14443-3A state machine */
Expand All @@ -331,7 +335,6 @@ uint16_t ISO144433APiccProcess(uint8_t *Buffer, uint16_t BitCount) {
break;
} else {
ISO144433ASwitchState(ISO14443_3A_STATE_IDLE);
return ISO14443A_APP_NO_RESPONSE;
}

case ISO14443_3A_STATE_IDLE:
Expand Down Expand Up @@ -414,8 +417,8 @@ uint16_t ISO144433APiccProcess(uint8_t *Buffer, uint16_t BitCount) {
} else if (Cmd == ISO14443A_CMD_DESELECT) {
/* This has been observed to happen at this stage when swiping the
* Chameleon running CONFIG=MF_DESFIRE on an ACR122 USB external reader.
* ??? What are we supposed to return in this case ???
*/
* ??? TODO: What are we supposed to return in this case ???
*/
DesfireLogEntry(LOG_INFO_APP_CMD_DESELECT, NULL, 0);
//return ISO14443A_APP_NO_RESPONSE;
return BitCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ extern uint8_t ISO14443ALastIncomingDataFrame[MAX_DATA_FRAME_XFER_SIZE];
extern uint16_t ISO14443ALastIncomingDataFrameBits;
uint16_t ISO14443AStoreLastDataFrameAndReturn(const uint8_t *Buffer, uint16_t BufferBitCount);

#define MAX_STATE_RETRY_COUNT (0x0B)
#define MAX_STATE_RETRY_COUNT (0xFF)
extern uint8_t StateRetryCount;
bool CheckStateRetryCount(bool resetByDefault);
bool CheckStateRetryCountWithLogging(bool resetByDefault, bool performLogging);
Expand Down
3 changes: 2 additions & 1 deletion Firmware/Chameleon-Mini/Application/DESFire/DESFireLogging.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void DesfireLogEntry(LogEntryEnum LogCode, void *LogDataBuffer, uint16_t BufSize
void DesfireLogEntry(LogEntryEnum LogCode, void *LogDataBuffer, uint16_t BufSize) {}
#endif

#ifdef DESFIRE_DEBUGGING
#if 0
//#ifdef DESFIRE_DEBUGGING
void DesfireLogISOStateChange(int state, int logCode) {
const char *statePrintName;
int logLength = 0;
Expand Down
11 changes: 7 additions & 4 deletions Firmware/Chameleon-Mini/Application/MifareDESFire.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,15 @@ uint16_t MifareDesfireProcessCommand(uint8_t *Buffer, uint16_t ByteCount) {
}

uint16_t MifareDesfireProcess(uint8_t *Buffer, uint16_t BitCount) {
DesfireCmdCLA = Buffer[0];
size_t ByteCount = ASBYTES(BitCount);
if (ByteCount == 0) {
DEBUG_PRINT_P(PSTR("RESENDING LAST FRAME"));
return ISO14443A_APP_NO_RESPONSE;
} else if (ByteCount >= 2 && Buffer[1] == STATUS_ADDITIONAL_FRAME && DesfireCLA(Buffer[0])) {
DEBUG_PRINT_P(PSTR("RESEND LAST"));
memcpy(&Buffer[0], &ISO14443ALastIncomingDataFrame[0], ASBYTES(ISO14443ALastIncomingDataFrameBits));
return ISO14443ALastIncomingDataFrameBits;
//return ISO14443A_APP_NO_RESPONSE;
}
DesfireCmdCLA = Buffer[0];
if (ByteCount >= 2 && Buffer[1] == STATUS_ADDITIONAL_FRAME && DesfireCLA(Buffer[0])) {
ByteCount -= 1;
memmove(&Buffer[0], &Buffer[1], ByteCount);
uint16_t ProcessedByteCount = MifareDesfireProcessCommand(Buffer, ByteCount);
Expand Down
2 changes: 1 addition & 1 deletion Firmware/Chameleon-Mini/LiveLogTick.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern LogBlockListNode *LogBlockListBegin;
extern LogBlockListNode *LogBlockListEnd;
extern uint8_t LogBlockListElementCount;

#define LIVE_LOGGER_POST_TICKS (4)
#define LIVE_LOGGER_POST_TICKS (7)
extern uint8_t LiveLogModePostTickCount;

INLINE bool AtomicAppendLogBlock(LogEntryEnum logCode, uint16_t sysTickTime, const uint8_t *logData, uint8_t logDataSize);
Expand Down
4 changes: 2 additions & 2 deletions Firmware/Chameleon-Mini/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include "Common.h"

#ifdef MEMORY_LIMITED_TESTING
#define LOG_SIZE 1024
#define LOG_SIZE 1664 // 1024
#else
#define LOG_SIZE 2048
#define LOG_SIZE 2048
#endif
#define FRAM_LOG_ADDR_ADDR 0x4000 // start of the second half of FRAM
#define FRAM_LOG_START_ADDR 0x4002 // directly after the address
Expand Down

0 comments on commit bfac980

Please sign in to comment.