mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -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 <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "common.h"
|
||||||
typedef unsigned char byte_t;
|
|
||||||
|
|
||||||
/* serial_port is declared as a void*, which you should cast to whatever type
|
/* 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
|
* makes sense to your connection method. Both the posix and win32
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
// Test if we are dealing with posix operating systems
|
// Test if we are dealing with posix operating systems
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct termios term_info;
|
typedef struct termios term_info;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int fd; // Serial port file descriptor
|
int fd; // Serial port file descriptor
|
||||||
|
@ -59,6 +61,9 @@ const struct timeval timeout = {
|
||||||
.tv_usec = 30000 // 30000 micro seconds
|
.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 uart_open(const char* pcPortName)
|
||||||
{
|
{
|
||||||
serial_port_unix* sp = malloc(sizeof(serial_port_unix));
|
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);
|
bool err = uart_set_speed(sp, 460800);
|
||||||
if (!err)
|
if (!err)
|
||||||
uart_set_speed(sp, 115200);
|
uart_set_speed(sp, 115200);
|
||||||
|
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +158,7 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_
|
||||||
int byteCount;
|
int byteCount;
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
uint64_t timeout_at = msclock() + RECV_TOTAL_TIMEOUT_MS;
|
||||||
|
|
||||||
// Reset the output count
|
// Reset the output count
|
||||||
*pszRxLen = 0;
|
*pszRxLen = 0;
|
||||||
|
@ -203,8 +208,8 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (byteCount);
|
// } while (byteCount);
|
||||||
|
} while (msclock() < timeout_at);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue