mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-15 11:43:14 +08:00
fix: seems the mutex messed up on ubuntu but there it works without.
This commit is contained in:
parent
a49ae2d0ce
commit
8e2d5370f9
1 changed files with 12 additions and 8 deletions
|
@ -27,7 +27,6 @@ communication_arg_t conn;
|
||||||
capabilities_t pm3_capabilities;
|
capabilities_t pm3_capabilities;
|
||||||
|
|
||||||
static pthread_t USB_communication_thread;
|
static pthread_t USB_communication_thread;
|
||||||
//static pthread_t FPC_communication_thread;
|
|
||||||
|
|
||||||
// Transmit buffer.
|
// Transmit buffer.
|
||||||
static PacketCommandOLD txBuffer;
|
static PacketCommandOLD txBuffer;
|
||||||
|
@ -355,7 +354,6 @@ __attribute__((force_align_arg_pointer))
|
||||||
bool ACK_received = false;
|
bool ACK_received = false;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_lock(&spMutex);
|
pthread_mutex_lock(&spMutex);
|
||||||
|
|
||||||
if (uart_receive(sp, (uint8_t *)&rx_raw.pre, sizeof(PacketResponseNGPreamble), &rxlen) && (rxlen == sizeof(PacketResponseNGPreamble))) {
|
if (uart_receive(sp, (uint8_t *)&rx_raw.pre, sizeof(PacketResponseNGPreamble), &rxlen) && (rxlen == sizeof(PacketResponseNGPreamble))) {
|
||||||
|
@ -486,6 +484,8 @@ __attribute__((force_align_arg_pointer))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (txBuffer_pending) {
|
if (txBuffer_pending) {
|
||||||
|
|
||||||
|
pthread_mutex_lock(&spMutex);
|
||||||
if (txBufferNGLen) { // NG packet
|
if (txBufferNGLen) { // NG packet
|
||||||
if (!uart_send(sp, (uint8_t *) &txBufferNG, txBufferNGLen)) {
|
if (!uart_send(sp, (uint8_t *) &txBufferNG, txBufferNGLen)) {
|
||||||
//counter_to_offline++;
|
//counter_to_offline++;
|
||||||
|
@ -498,6 +498,8 @@ __attribute__((force_align_arg_pointer))
|
||||||
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device " _RED_("failed"));
|
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device " _RED_("failed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&spMutex);
|
||||||
|
|
||||||
txBuffer_pending = false;
|
txBuffer_pending = false;
|
||||||
|
|
||||||
// tell main thread that txBuffer is empty
|
// tell main thread that txBuffer is empty
|
||||||
|
@ -560,7 +562,7 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
|
||||||
conn.send_via_fpc = false;
|
conn.send_via_fpc = false;
|
||||||
|
|
||||||
pthread_create(&USB_communication_thread, NULL, &uart_communication, &conn);
|
pthread_create(&USB_communication_thread, NULL, &uart_communication, &conn);
|
||||||
//pthread_create(&FPC_communication_thread, NULL, &uart_communication, &conn);
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
// create a mutex to avoid interlacing print commands from our different threads
|
// create a mutex to avoid interlacing print commands from our different threads
|
||||||
//pthread_mutex_init(&print_lock, NULL);
|
//pthread_mutex_init(&print_lock, NULL);
|
||||||
|
@ -605,10 +607,13 @@ int TestProxmark(void) {
|
||||||
// reconfigure.
|
// reconfigure.
|
||||||
if (conn.send_via_fpc == false) {
|
if (conn.send_via_fpc == false) {
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
pthread_mutex_lock(&spMutex);
|
pthread_mutex_lock(&spMutex);
|
||||||
|
#endif
|
||||||
int res = uart_reconfigure_timeouts(sp, UART_USB_CLIENT_RX_TIMEOUT_MS);
|
int res = uart_reconfigure_timeouts(sp, UART_USB_CLIENT_RX_TIMEOUT_MS);
|
||||||
|
#if defined(_WIN32)
|
||||||
pthread_mutex_unlock(&spMutex);
|
pthread_mutex_unlock(&spMutex);
|
||||||
|
#endif
|
||||||
if ( res != PM3_SUCCESS ) {
|
if ( res != PM3_SUCCESS ) {
|
||||||
PrintAndLogEx(ERR, "UART reconfigure failed");
|
PrintAndLogEx(ERR, "UART reconfigure failed");
|
||||||
return res;
|
return res;
|
||||||
|
@ -633,7 +638,6 @@ void CloseProxmark(void) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
pthread_join(USB_communication_thread, NULL);
|
pthread_join(USB_communication_thread, NULL);
|
||||||
//pthread_join(FPC_communication_thread, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sp) {
|
if (sp) {
|
||||||
|
|
Loading…
Reference in a new issue