mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-21 07:46:12 +08:00
rename global conn
This commit is contained in:
parent
8280fc3c07
commit
6a2f2b3979
|
@ -69,7 +69,7 @@ void RepaintPictureWindow(void) {}
|
|||
int push_cmdscriptfile(char *path, bool stayafter) { return PM3_SUCCESS; }
|
||||
|
||||
static bool OpenPm3(void) {
|
||||
if (conn.run) { return true; }
|
||||
if (g_conn.run) { return true; }
|
||||
// Open with LocalSocket. Not a tcp connection!
|
||||
bool ret = OpenProxmark(session.current_device, "socket:"PM3_LOCAL_SOCKET_SERVER, false, 1000, false, 115200);
|
||||
return ret;
|
||||
|
@ -80,7 +80,7 @@ static bool OpenPm3(void) {
|
|||
* */
|
||||
jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
|
||||
|
||||
if (!conn.run) {
|
||||
if (!g_conn.run) {
|
||||
if (OpenPm3() && TestProxmark(session.current_device) == PM3_SUCCESS) {
|
||||
LOGD("Connected to device");
|
||||
PrintAndLogEx(SUCCESS, "Connected to device");
|
||||
|
@ -109,7 +109,7 @@ jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
|
|||
* Is client running!
|
||||
* */
|
||||
jboolean IsClientRunning(JNIEnv *env, jobject instance) {
|
||||
return (jboolean)((jboolean) conn.run);
|
||||
return (jboolean)((jboolean) g_conn.run);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -273,7 +273,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
|||
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
while (bytes_remaining > 0) {
|
||||
uint32_t bytes_in_packet = MIN(FLASH_MEM_BLOCK_SIZE, bytes_remaining);
|
||||
|
@ -293,20 +293,20 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
|||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_FLASHMEM_WRITE, &resp, 2000) == false) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
free(data);
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
|
||||
if (resp.status != PM3_SUCCESS) {
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
PrintAndLogEx(FAILED, "Flash write fail [offset %u]", bytes_sent);
|
||||
free(data);
|
||||
return PM3_EFLASH;
|
||||
}
|
||||
}
|
||||
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
free(data);
|
||||
PrintAndLogEx(SUCCESS, "Wrote "_GREEN_("%zu")" bytes to offset "_GREEN_("%u"), datalen, offset);
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -30,7 +30,7 @@ int flashmem_spiffs_load(char *destfn, uint8_t *data, size_t datalen) {
|
|||
uint32_t bytes_remaining = datalen;
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
while (bytes_remaining > 0) {
|
||||
|
||||
|
@ -73,7 +73,7 @@ out:
|
|||
clearCommandBuffer();
|
||||
|
||||
// turn off fast push mode
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
|
||||
// We want to unmount after these to set things back to normal but more than this
|
||||
// unmouting ensure that SPIFFS CACHES are all flushed so our file is actually written on memory
|
||||
|
|
|
@ -462,7 +462,7 @@ static int CmdHFCryptoRFELoad(const char *Cmd) {
|
|||
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining);
|
||||
if (bytes_in_packet == bytes_remaining) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
SendCommandMIX(CMD_HF_CRYPTORF_EML_MEMSET, bytes_sent, bytes_in_packet, 0, data + bytes_sent, bytes_in_packet);
|
||||
|
|
|
@ -140,7 +140,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
|||
// transfer the APDUs to the Proxmark
|
||||
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
for (int i = 0; i < ARRAYLEN(apdu_lengths); i++) {
|
||||
|
||||
// transfer the APDU in several parts if necessary
|
||||
|
@ -152,7 +152,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
|||
}
|
||||
if ((i == ARRAYLEN(apdu_lengths) - 1) && (j * sizeof(data) >= apdu_lengths[i] - 1)) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
memcpy(data, // + (j * sizeof(data)),
|
||||
apdus[i] + (j * sizeof(data)),
|
||||
|
|
|
@ -126,7 +126,7 @@ static void iclass_upload_emul(uint8_t *d, uint16_t n, uint16_t *bytes_sent) {
|
|||
} PACKED;
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
//Send to device
|
||||
*bytes_sent = 0;
|
||||
|
@ -136,7 +136,7 @@ static void iclass_upload_emul(uint8_t *d, uint16_t n, uint16_t *bytes_sent) {
|
|||
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE - 4, bytes_remaining);
|
||||
if (bytes_in_packet == bytes_remaining) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
|
||||
|
@ -3056,7 +3056,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
|||
max_chunk_size = keycount;
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
// keep track of position of found key
|
||||
uint32_t chunk_offset = 0;
|
||||
|
@ -3085,7 +3085,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
|||
// last chunk?
|
||||
if (curr_chunk_cnt == keycount - chunk_offset) {
|
||||
// Disable fast mode on last command
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
|
||||
uint32_t tmp_plen = sizeof(iclass_chk_t) + (4 * curr_chunk_cnt);
|
||||
|
|
|
@ -519,12 +519,12 @@ static int CmdHF14AJookiSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(INFO, "." NOLF);
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
uint8_t blockwidth = 4, counter = 0, blockno = 0;
|
||||
while (datalen) {
|
||||
if (datalen == blockwidth) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
|
||||
if (mfEmlSetMem_xt(data + counter, blockno, 1, blockwidth) != PM3_SUCCESS) {
|
||||
|
|
|
@ -717,13 +717,13 @@ void legic_chk_iv(uint32_t *iv) {
|
|||
}
|
||||
void legic_seteml(uint8_t *src, uint32_t offset, uint32_t numofbytes) {
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
for (size_t i = offset; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||
|
||||
size_t len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||
if (len == numofbytes - i) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_LEGIC_ESET, i, len, 0, src + i, len);
|
||||
|
@ -913,7 +913,7 @@ static int CmdLegicRestore(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Restoring to card");
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
// transfer to device
|
||||
PacketResponseNG resp;
|
||||
|
@ -922,7 +922,7 @@ static int CmdLegicRestore(const char *Cmd) {
|
|||
size_t len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||
if (len == numofbytes - i) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_LEGIC_WRITER, i, len, 0x55, data + i, len);
|
||||
|
@ -1129,7 +1129,7 @@ static int CmdLegicWipe(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Erasing");
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
// transfer to device
|
||||
PacketResponseNG resp;
|
||||
|
@ -1140,7 +1140,7 @@ static int CmdLegicWipe(const char *Cmd) {
|
|||
size_t len = MIN((card.cardsize - i), PM3_CMD_DATA_SIZE);
|
||||
if (len == card.cardsize - i) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_HF_LEGIC_WRITER, i, len, 0x55, data + i, len);
|
||||
|
|
|
@ -1322,7 +1322,7 @@ jumptoend:
|
|||
// transfer them to the emulator
|
||||
if (transferToEml) {
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
for (int i = 0; i < SectorsCnt; i++) {
|
||||
mfEmlGetMem(keyBlock, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
|
||||
|
@ -1334,7 +1334,7 @@ jumptoend:
|
|||
|
||||
if (i == SectorsCnt - 1) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
mfEmlSetMem(keyBlock, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
}
|
||||
|
@ -1568,7 +1568,7 @@ jumptoend:
|
|||
// transfer them to the emulator
|
||||
if (transferToEml) {
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
for (int i = 0; i < SectorsCnt; i++) {
|
||||
mfEmlGetMem(keyBlock, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
|
||||
|
@ -1580,7 +1580,7 @@ jumptoend:
|
|||
|
||||
if (i == SectorsCnt - 1) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
mfEmlSetMem(keyBlock, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1);
|
||||
}
|
||||
|
@ -2818,7 +2818,7 @@ out:
|
|||
|
||||
if (transferToEml) {
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
uint8_t block[16] = {0x00};
|
||||
for (i = 0; i < sectorsCnt; ++i) {
|
||||
uint8_t b = FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1;
|
||||
|
@ -2832,7 +2832,7 @@ out:
|
|||
|
||||
if (i == sectorsCnt - 1) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
mfEmlSetMem(block, b, 1);
|
||||
}
|
||||
|
@ -3068,7 +3068,7 @@ static int CmdHF14AMfChk(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "." NOLF);
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
// clear trace log by first check keys call only
|
||||
bool clearLog = true;
|
||||
|
@ -3167,7 +3167,7 @@ out:
|
|||
|
||||
if (transferToEml) {
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
uint8_t block[16] = {0x00};
|
||||
for (int i = 0; i < SectorsCnt; ++i) {
|
||||
uint8_t blockno = FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1;
|
||||
|
@ -3181,7 +3181,7 @@ out:
|
|||
|
||||
if (i == SectorsCnt - 1) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
mfEmlSetMem(block, blockno, 1);
|
||||
}
|
||||
|
@ -3200,7 +3200,7 @@ out:
|
|||
free(e_sector);
|
||||
|
||||
// Disable fast mode and send a dummy command to make it effective
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
SendCommandNG(CMD_PING, NULL, 0);
|
||||
if (!WaitForResponseTimeout(CMD_PING, NULL, 1000)) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
|
@ -3817,7 +3817,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "." NOLF);
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
size_t offset = 0;
|
||||
int cnt = 0;
|
||||
|
@ -3825,7 +3825,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
|
|||
while (datalen && cnt < block_cnt) {
|
||||
if (datalen == block_width) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
|
||||
if (mfEmlSetMem_xt(data + offset, cnt, 1, block_width) != PM3_SUCCESS) {
|
||||
|
@ -4746,11 +4746,11 @@ static int CmdHF14AMfCSave(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "uploading to emulator memory");
|
||||
PrintAndLogEx(INFO, "." NOLF);
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
for (int i = 0; i < block_cnt; i += 5) {
|
||||
if (i == block_cnt - 1) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
if (mfEmlSetMem(dump + (i * MFBLOCK_SIZE), i, 5) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Can't set emul block: %d", i);
|
||||
|
|
|
@ -836,11 +836,11 @@ static int CmdConnect(const char *Cmd) {
|
|||
|
||||
// default back to previous used serial port
|
||||
if (strlen(port) == 0) {
|
||||
if (strlen(conn.serial_port_name) == 0) {
|
||||
if (strlen(g_conn.serial_port_name) == 0) {
|
||||
PrintAndLogEx(WARNING, "Must specify a serial port");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
memcpy(port, conn.serial_port_name, sizeof(port));
|
||||
memcpy(port, g_conn.serial_port_name, sizeof(port));
|
||||
}
|
||||
|
||||
if (session.pm3_present) {
|
||||
|
|
|
@ -790,7 +790,7 @@ int lfsim_upload_gb(void) {
|
|||
payload_up.flag = 0x1;
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
PacketResponseNG resp;
|
||||
|
||||
|
@ -818,7 +818,7 @@ int lfsim_upload_gb(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
// Disable fast mode before last command
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -348,13 +348,13 @@ int em4x05_clone_tag(uint32_t *blockdata, uint8_t numblocks, uint32_t pwd, bool
|
|||
return PM3_EINVARG;
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
int res = 0;
|
||||
for (int8_t i = 0; i < numblocks; i++) {
|
||||
|
||||
// Disable fast mode on last packet
|
||||
if (i == numblocks - 1) {
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
|
||||
if (i != 0) {
|
||||
|
|
|
@ -178,13 +178,13 @@ static int em4x50_load_file(const char *filename, uint8_t *data, size_t data_len
|
|||
static void em4x50_seteml(uint8_t *src, uint32_t offset, uint32_t numofbytes) {
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
for (size_t i = offset; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||
|
||||
size_t len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||
if (len == numofbytes - i) {
|
||||
// Disable fast mode on last packet
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_LF_EM4X50_ESET, i, len, 0, src + i, len);
|
||||
|
|
|
@ -159,13 +159,13 @@ int clone_t55xx_tag(uint32_t *blockdata, uint8_t numblocks) {
|
|||
PacketResponseNG resp;
|
||||
|
||||
// fast push mode
|
||||
conn.block_after_ACK = true;
|
||||
g_conn.block_after_ACK = true;
|
||||
|
||||
for (int8_t i = 0; i < numblocks; i++) {
|
||||
|
||||
// Disable fast mode on last packet
|
||||
if (i == numblocks - 1) {
|
||||
conn.block_after_ACK = false;
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
|
|
|
@ -67,7 +67,7 @@ bool IfPm3FpcUsartHostFromUsb(void) {
|
|||
return false;
|
||||
if (!g_pm3_capabilities.compiled_with_fpc_usart_host)
|
||||
return false;
|
||||
return !conn.send_via_fpc_usart;
|
||||
return !g_conn.send_via_fpc_usart;
|
||||
}
|
||||
|
||||
bool IfPm3FpcUsartDevFromUsb(void) {
|
||||
|
@ -76,7 +76,7 @@ bool IfPm3FpcUsartDevFromUsb(void) {
|
|||
return false;
|
||||
if (!g_pm3_capabilities.compiled_with_fpc_usart_dev)
|
||||
return false;
|
||||
return !conn.send_via_fpc_usart;
|
||||
return !g_conn.send_via_fpc_usart;
|
||||
}
|
||||
|
||||
bool IfPm3FpcUsartFromUsb(void) {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
// Serial port that we are communicating with the PM3 on.
|
||||
static serial_port sp = NULL;
|
||||
|
||||
communication_arg_t conn;
|
||||
communication_arg_t g_conn;
|
||||
capabilities_t g_pm3_capabilities;
|
||||
|
||||
static pthread_t communication_thread;
|
||||
|
@ -148,7 +148,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool
|
|||
if (len > 0 && data)
|
||||
memcpy(&txBufferNG.data, data, len);
|
||||
|
||||
if ((conn.send_via_fpc_usart && conn.send_with_crc_on_fpc) || ((!conn.send_via_fpc_usart) && conn.send_with_crc_on_usb)) {
|
||||
if ((g_conn.send_via_fpc_usart && g_conn.send_with_crc_on_fpc) || ((!g_conn.send_via_fpc_usart) && g_conn.send_with_crc_on_usb)) {
|
||||
uint8_t first, second;
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(PacketCommandNGPreamble) + len, &first, &second);
|
||||
tx_post->crc = (first << 8) + second;
|
||||
|
@ -354,7 +354,7 @@ __attribute__((force_align_arg_pointer))
|
|||
// Signal to main thread that communications seems off.
|
||||
// main thread will kill and restart this thread.
|
||||
if (commfailed) {
|
||||
if (conn.last_command != CMD_HARDWARE_RESET) {
|
||||
if (g_conn.last_command != CMD_HARDWARE_RESET) {
|
||||
PrintAndLogEx(WARNING, "\nCommunicating with Proxmark3 device " _RED_("failed"));
|
||||
}
|
||||
__atomic_test_and_set(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||
|
@ -384,7 +384,7 @@ __attribute__((force_align_arg_pointer))
|
|||
if (rx.ng) { // Received a valid NG frame
|
||||
memcpy(&rx.data, &rx_raw.data, length);
|
||||
rx.length = length;
|
||||
if ((rx.cmd == conn.last_command) && (rx.status == PM3_SUCCESS)) {
|
||||
if ((rx.cmd == g_conn.last_command) && (rx.status == PM3_SUCCESS)) {
|
||||
ACK_received = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -504,14 +504,14 @@ __attribute__((force_align_arg_pointer))
|
|||
if (res == PM3_EIO) {
|
||||
commfailed = true;
|
||||
}
|
||||
conn.last_command = txBufferNG.pre.cmd;
|
||||
g_conn.last_command = txBufferNG.pre.cmd;
|
||||
txBufferNGLen = 0;
|
||||
} else {
|
||||
res = uart_send(sp, (uint8_t *) &txBuffer, sizeof(PacketCommandOLD));
|
||||
if (res == PM3_EIO) {
|
||||
commfailed = true;
|
||||
}
|
||||
conn.last_command = txBuffer.cmd;
|
||||
g_conn.last_command = txBuffer.cmd;
|
||||
}
|
||||
|
||||
txBuffer_pending = false;
|
||||
|
@ -574,20 +574,20 @@ bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout,
|
|||
return false;
|
||||
} else {
|
||||
// start the communication thread
|
||||
if (port != conn.serial_port_name) {
|
||||
if (port != g_conn.serial_port_name) {
|
||||
uint16_t len = MIN(strlen(port), FILE_PATH_SIZE - 1);
|
||||
memset(conn.serial_port_name, 0, FILE_PATH_SIZE);
|
||||
memcpy(conn.serial_port_name, port, len);
|
||||
memset(g_conn.serial_port_name, 0, FILE_PATH_SIZE);
|
||||
memcpy(g_conn.serial_port_name, port, len);
|
||||
}
|
||||
conn.run = true;
|
||||
conn.block_after_ACK = flash_mode;
|
||||
g_conn.run = true;
|
||||
g_conn.block_after_ACK = flash_mode;
|
||||
// Flags to tell where to add CRC on sent replies
|
||||
conn.send_with_crc_on_usb = false;
|
||||
conn.send_with_crc_on_fpc = true;
|
||||
g_conn.send_with_crc_on_usb = false;
|
||||
g_conn.send_with_crc_on_fpc = true;
|
||||
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
|
||||
conn.send_via_fpc_usart = false;
|
||||
g_conn.send_via_fpc_usart = false;
|
||||
|
||||
pthread_create(&communication_thread, NULL, &uart_communication, &conn);
|
||||
pthread_create(&communication_thread, NULL, &uart_communication, &g_conn);
|
||||
__atomic_clear(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||
session.pm3_present = true; // TODO support for multiple devices
|
||||
|
||||
|
@ -595,7 +595,7 @@ bool OpenProxmark(pm3_device **dev, char *port, bool wait_for_port, int timeout,
|
|||
if (*dev == NULL) {
|
||||
*dev = calloc(sizeof(pm3_device), sizeof(uint8_t));
|
||||
}
|
||||
(*dev)->conn = &conn; // TODO conn shouldn't be global
|
||||
(*dev)->g_conn = &g_conn; // TODO g_conn shouldn't be global
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -645,16 +645,16 @@ int TestProxmark(pm3_device *dev) {
|
|||
}
|
||||
|
||||
memcpy(&g_pm3_capabilities, resp.data.asBytes, MIN(sizeof(capabilities_t), resp.length));
|
||||
conn.send_via_fpc_usart = g_pm3_capabilities.via_fpc;
|
||||
conn.uart_speed = g_pm3_capabilities.baudrate;
|
||||
g_conn.send_via_fpc_usart = g_pm3_capabilities.via_fpc;
|
||||
g_conn.uart_speed = g_pm3_capabilities.baudrate;
|
||||
|
||||
PrintAndLogEx(INFO, "Communicating with PM3 over %s%s%s",
|
||||
conn.send_via_fpc_usart ? _YELLOW_("FPC UART") : _YELLOW_("USB-CDC"),
|
||||
memcmp(conn.serial_port_name, "tcp:", 4) == 0 ? " over " _YELLOW_("TCP") : "",
|
||||
memcmp(conn.serial_port_name, "bt:", 3) == 0 ? " over " _YELLOW_("BT") : "");
|
||||
g_conn.send_via_fpc_usart ? _YELLOW_("FPC UART") : _YELLOW_("USB-CDC"),
|
||||
memcmp(g_conn.serial_port_name, "tcp:", 4) == 0 ? " over " _YELLOW_("TCP") : "",
|
||||
memcmp(g_conn.serial_port_name, "bt:", 3) == 0 ? " over " _YELLOW_("BT") : "");
|
||||
|
||||
if (conn.send_via_fpc_usart) {
|
||||
PrintAndLogEx(INFO, "PM3 UART serial baudrate: " _YELLOW_("%u") "\n", conn.uart_speed);
|
||||
if (g_conn.send_via_fpc_usart) {
|
||||
PrintAndLogEx(INFO, "PM3 UART serial baudrate: " _YELLOW_("%u") "\n", g_conn.uart_speed);
|
||||
} else {
|
||||
int res = uart_reconfigure_timeouts(UART_USB_CLIENT_RX_TIMEOUT_MS);
|
||||
if (res != PM3_SUCCESS) {
|
||||
|
@ -665,7 +665,7 @@ int TestProxmark(pm3_device *dev) {
|
|||
}
|
||||
|
||||
void CloseProxmark(pm3_device *dev) {
|
||||
dev->conn->run = false;
|
||||
dev->g_conn->run = false;
|
||||
|
||||
#ifdef __BIONIC__
|
||||
if (communication_thread != 0) {
|
||||
|
@ -702,8 +702,8 @@ void CloseProxmark(pm3_device *dev) {
|
|||
// ~ = 12000000 / USART_BAUD_RATE
|
||||
// Let's take 2x (maybe we need more for BT link?)
|
||||
static size_t communication_delay(void) {
|
||||
if (conn.send_via_fpc_usart) // needed also for Windows USB USART??
|
||||
return 2 * (12000000 / conn.uart_speed);
|
||||
if (g_conn.send_via_fpc_usart) // needed also for Windows USB USART??
|
||||
return 2 * (12000000 / g_conn.uart_speed);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,11 +61,11 @@ typedef struct {
|
|||
char serial_port_name[FILE_PATH_SIZE];
|
||||
} communication_arg_t;
|
||||
|
||||
extern communication_arg_t conn;
|
||||
extern communication_arg_t g_conn;
|
||||
|
||||
typedef struct pm3_device pm3_device;
|
||||
struct pm3_device {
|
||||
communication_arg_t *conn;
|
||||
communication_arg_t *g_conn;
|
||||
int script_embedded;
|
||||
};
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ int pm3_console(pm3_device *dev, char *Cmd) {
|
|||
}
|
||||
|
||||
const char *pm3_name_get(pm3_device *dev) {
|
||||
return dev->conn->serial_port_name;
|
||||
return dev->g_conn->serial_port_name;
|
||||
}
|
||||
|
||||
pm3_device *pm3_get_current_dev(void) {
|
||||
|
|
|
@ -366,7 +366,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
|||
setLayout(layout);
|
||||
|
||||
// plot window title
|
||||
QString pt = QString("[*]Plot [ %1 ]").arg(conn.serial_port_name);
|
||||
QString pt = QString("[*]Plot [ %1 ]").arg(g_conn.serial_port_name);
|
||||
setWindowTitle(pt);
|
||||
|
||||
// shows plot window on the screen.
|
||||
|
@ -380,7 +380,7 @@ ProxWidget::ProxWidget(QWidget *parent, ProxGuiQT *master) : QWidget(parent) {
|
|||
}
|
||||
|
||||
// Olverlays / slider window title
|
||||
QString ct = QString("[*]Slider [ %1 ]").arg(conn.serial_port_name);
|
||||
QString ct = QString("[*]Slider [ %1 ]").arg(g_conn.serial_port_name);
|
||||
controlWidget->setWindowTitle(ct);
|
||||
|
||||
// The hide/show event functions should take care of this.
|
||||
|
|
|
@ -301,7 +301,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
|||
|
||||
bool printprompt = false;
|
||||
if (session.pm3_present) {
|
||||
if (conn.send_via_fpc_usart == false)
|
||||
if (g_conn.send_via_fpc_usart == false)
|
||||
prompt_dev = PROXPROMPT_DEV_USB;
|
||||
else
|
||||
prompt_dev = PROXPROMPT_DEV_FPC;
|
||||
|
|
|
@ -71,7 +71,7 @@ static int l_fast_push_mode(lua_State *L) {
|
|||
|
||||
bool enable = lua_toboolean(L, 1);
|
||||
|
||||
conn.block_after_ACK = enable;
|
||||
g_conn.block_after_ACK = enable;
|
||||
|
||||
// Disable fast mode and send a dummy command to make it effective
|
||||
if (enable == false) {
|
||||
|
|
|
@ -340,7 +340,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
|||
return INVALID_SERIAL_PORT;
|
||||
}
|
||||
}
|
||||
conn.uart_speed = uart_get_speed(sp);
|
||||
g_conn.uart_speed = uart_get_speed(sp);
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
@ -558,7 +558,7 @@ bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed) {
|
|||
cfsetospeed(&ti, stPortSpeed);
|
||||
bool result = tcsetattr(spu->fd, TCSANOW, &ti) != -1;
|
||||
if (result)
|
||||
conn.uart_speed = uiPortSpeed;
|
||||
g_conn.uart_speed = uiPortSpeed;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
|||
return INVALID_SERIAL_PORT;
|
||||
}
|
||||
}
|
||||
conn.uart_speed = uart_get_speed(sp);
|
||||
g_conn.uart_speed = uart_get_speed(sp);
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed) {
|
|||
bool result = SetCommState(spw->hPort, &spw->dcb);
|
||||
PurgeComm(spw->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
|
||||
if (result)
|
||||
conn.uart_speed = uiPortSpeed;
|
||||
g_conn.uart_speed = uiPortSpeed;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue