Add fast mode support for RX NG frames

This commit is contained in:
Philippe Teuwen 2019-05-05 22:34:22 +02:00
commit eb7aa033ff
2 changed files with 9 additions and 3 deletions

View file

@ -374,16 +374,19 @@ __attribute__((force_align_arg_pointer))
} else { } else {
if (rx.ng) { if (rx.ng) { // Received a valid NG frame
memcpy(&rx.data, &rx_raw.data, length); memcpy(&rx.data, &rx_raw.data, length);
rx.length = length; rx.length = length;
if ((rx.cmd == conn.last_command) && (rx.status == PM3_SUCCESS)) {
ACK_received = true;
}
} else { } else {
uint64_t arg[3]; uint64_t arg[3];
if (length < sizeof(arg)) { if (length < sizeof(arg)) {
PrintAndLogEx(WARNING, "Received MIX packet frame with incompatible length: 0x%04x", length); PrintAndLogEx(WARNING, "Received MIX packet frame with incompatible length: 0x%04x", length);
error = true; error = true;
} }
if (!error) { if (!error) { // Received a valid MIX frame
memcpy(arg, &rx_raw.data, sizeof(arg)); memcpy(arg, &rx_raw.data, sizeof(arg));
rx.oldarg[0] = arg[0]; rx.oldarg[0] = arg[0];
rx.oldarg[1] = arg[1]; rx.oldarg[1] = arg[1];
@ -414,7 +417,7 @@ __attribute__((force_align_arg_pointer))
} }
} }
} }
if (!error) { if (!error) { // Received a valid OLD frame
#ifdef COMMS_DEBUG #ifdef COMMS_DEBUG
PrintAndLogEx(NORMAL, "Receiving %s:", rx.ng ? "NG" : "MIX"); PrintAndLogEx(NORMAL, "Receiving %s:", rx.ng ? "NG" : "MIX");
#endif #endif
@ -491,12 +494,14 @@ __attribute__((force_align_arg_pointer))
//counter_to_offline++; //counter_to_offline++;
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device " _RED_("failed")); PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device " _RED_("failed"));
} }
conn.last_command = txBufferNG.pre.cmd;
txBufferNGLen = 0; txBufferNGLen = 0;
} else { } else {
if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(PacketCommandOLD))) { if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(PacketCommandOLD))) {
//counter_to_offline++; //counter_to_offline++;
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device " _RED_("failed")); PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device " _RED_("failed"));
} }
conn.last_command = txBuffer.cmd;
} }
pthread_mutex_unlock(&spMutex); pthread_mutex_unlock(&spMutex);

View file

@ -49,6 +49,7 @@ typedef struct {
bool send_via_fpc_usart; bool send_via_fpc_usart;
// To memorise baudrate // To memorise baudrate
uint32_t uart_speed; uint32_t uart_speed;
uint16_t last_command;
} communication_arg_t; } communication_arg_t;
extern communication_arg_t conn; extern communication_arg_t conn;