FIX: usb slow for posix systems - https://github.com/Proxmark/proxmark3/pull/787 (@fl0-0)

This commit is contained in:
iceman1001 2019-02-17 15:37:20 +01:00
commit 535d4e6ee9

View file

@ -70,11 +70,10 @@ typedef struct {
// Set time-out on 30 miliseconds // Set time-out on 30 miliseconds
const struct timeval timeout = { const struct timeval timeout = {
.tv_sec = 0, // 0 second .tv_sec = 0, // 0 second
.tv_usec = 300000 // 300 000 micro seconds .tv_usec = 30000 // 30 000 micro seconds
}; };
serial_port uart_open(const char* pcPortName) serial_port uart_open(const char* pcPortName) {
{
serial_port_unix* sp = calloc(sizeof(serial_port_unix), sizeof(uint8_t)); serial_port_unix* sp = calloc(sizeof(serial_port_unix), sizeof(uint8_t));
if (sp == 0) return INVALID_SERIAL_PORT; if (sp == 0) return INVALID_SERIAL_PORT;
@ -87,6 +86,8 @@ serial_port uart_open(const char* pcPortName)
return INVALID_SERIAL_PORT; return INVALID_SERIAL_PORT;
} }
timeout.tv_usec = 300000 // 300 000 micro seconds
char *colon = strrchr(addrstr, ':'); char *colon = strrchr(addrstr, ':');
char *portstr; char *portstr;
if (colon) { if (colon) {
@ -365,7 +366,10 @@ uint32_t uart_get_speed(const serial_port sp) {
struct termios ti; struct termios ti;
uint32_t uiPortSpeed; uint32_t uiPortSpeed;
const serial_port_unix* spu = (serial_port_unix*)sp; const serial_port_unix* spu = (serial_port_unix*)sp;
if (tcgetattr(spu->fd, &ti) == -1) return 0;
if (tcgetattr(spu->fd, &ti) == -1)
return 0;
// Set port speed (Input) // Set port speed (Input)
speed_t stPortSpeed = cfgetispeed(&ti); speed_t stPortSpeed = cfgetispeed(&ti);
switch (stPortSpeed) { switch (stPortSpeed) {
@ -403,5 +407,4 @@ uint32_t uart_get_speed(const serial_port sp) {
}; };
return uiPortSpeed; return uiPortSpeed;
} }
#endif #endif