mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-22 22:23:38 -07:00
fix: @micolous changes
This commit is contained in:
parent
0a58e8f0fe
commit
7eeea9bf2a
2 changed files with 17 additions and 13 deletions
|
@ -38,8 +38,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef unsigned char byte_t;
|
||||
#include "common.h"
|
||||
|
||||
/* serial_port is declared as a void*, which you should cast to whatever type
|
||||
* makes sense to your connection method. Both the posix and win32
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
// Test if we are dealing with posix operating systems
|
||||
#ifndef _WIN32
|
||||
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
@ -46,6 +47,7 @@
|
|||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
typedef struct termios term_info;
|
||||
typedef struct {
|
||||
int fd; // Serial port file descriptor
|
||||
|
@ -59,6 +61,9 @@ const struct timeval timeout = {
|
|||
.tv_usec = 30000 // 30000 micro seconds
|
||||
};
|
||||
|
||||
// Overall timeout for receives -- 300ms
|
||||
#define RECV_TOTAL_TIMEOUT_MS 300
|
||||
|
||||
serial_port uart_open(const char* pcPortName)
|
||||
{
|
||||
serial_port_unix* sp = malloc(sizeof(serial_port_unix));
|
||||
|
@ -119,7 +124,6 @@ serial_port uart_open(const char* pcPortName)
|
|||
bool err = uart_set_speed(sp, 460800);
|
||||
if (!err)
|
||||
uart_set_speed(sp, 115200);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
@ -154,6 +158,7 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_
|
|||
int byteCount;
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
uint64_t timeout_at = msclock() + RECV_TOTAL_TIMEOUT_MS;
|
||||
|
||||
// Reset the output count
|
||||
*pszRxLen = 0;
|
||||
|
@ -203,8 +208,8 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_
|
|||
return true;
|
||||
}
|
||||
|
||||
} while (byteCount);
|
||||
|
||||
// } while (byteCount);
|
||||
} while (msclock() < timeout_at);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue