mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-01 13:14:30 +08:00
chg: reverting tests
This commit is contained in:
parent
a41cdf803a
commit
85eb7c2cc6
2 changed files with 6 additions and 40 deletions
|
@ -61,9 +61,6 @@ 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));
|
||||
|
@ -128,8 +125,8 @@ serial_port uart_open(const char* pcPortName)
|
|||
}
|
||||
|
||||
void uart_close(const serial_port sp) {
|
||||
if (sp == INVALID_SERIAL_PORT) return;
|
||||
if (sp == CLAIMED_SERIAL_PORT) return;
|
||||
// if (sp == INVALID_SERIAL_PORT) return;
|
||||
// if (sp == CLAIMED_SERIAL_PORT) return;
|
||||
|
||||
serial_port_unix* spu = (serial_port_unix*)sp;
|
||||
tcflush(spu->fd, TCIOFLUSH);
|
||||
|
@ -150,18 +147,11 @@ void uart_close(const serial_port sp) {
|
|||
free(sp);
|
||||
}
|
||||
|
||||
bool uart_cts(const serial_port sp) {
|
||||
char status;
|
||||
if (ioctl(((serial_port_unix*)sp)->fd,TIOCMGET,&status) < 0) return false;
|
||||
return (status & TIOCM_CTS);
|
||||
}
|
||||
|
||||
bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_t* pszRxLen) {
|
||||
int res;
|
||||
int byteCount;
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
//uint64_t timeout_at = msclock() + RECV_TOTAL_TIMEOUT_MS;
|
||||
|
||||
// Reset the output count
|
||||
*pszRxLen = 0;
|
||||
|
@ -212,7 +202,7 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_
|
|||
}
|
||||
|
||||
} while (byteCount);
|
||||
// } while (msclock() < timeout_at);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -221,14 +211,13 @@ bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen)
|
|||
size_t szPos = 0;
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
const serial_port_unix* spu = (serial_port_unix*)sp;
|
||||
|
||||
while (szPos < szTxLen) {
|
||||
// Reset file descriptor
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(spu->fd, &rfds);
|
||||
FD_SET(((serial_port_unix*)sp)->fd,&rfds);
|
||||
tv = timeout;
|
||||
res = select(spu->fd + 1, NULL, &rfds, NULL, &tv);
|
||||
res = select(((serial_port_unix*)sp)->fd+1, NULL, &rfds, NULL, &tv);
|
||||
|
||||
// Write error
|
||||
if (res < 0) {
|
||||
|
@ -243,7 +232,7 @@ bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen)
|
|||
}
|
||||
|
||||
// Send away the bytes
|
||||
res = write(spu->fd, pbtTx + szPos, szTxLen-szPos);
|
||||
res = write(((serial_port_unix*)sp)->fd,pbtTx+szPos,szTxLen-szPos);
|
||||
|
||||
// Stop if the OS has some troubles sending the data
|
||||
if (res <= 0) {
|
||||
|
|
|
@ -122,29 +122,6 @@ void uart_close(const serial_port sp) {
|
|||
bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_t* pszRxLen) {
|
||||
ReadFile(((serial_port_windows*)sp)->hPort, pbtRx, pszMaxRxLen, (LPDWORD)pszRxLen, NULL);
|
||||
return (*pszRxLen != 0);
|
||||
/*
|
||||
DWORD dwBytesToGet = (DWORD)pszMaxRxLen;
|
||||
DWORD dwBytesReceived = 0;
|
||||
DWORD dwTotalBytesReceived = 0;
|
||||
BOOL res;
|
||||
|
||||
do {
|
||||
res = ReadFile(((serial_port_windows *) sp)->hPort, pbtRx + dwTotalBytesReceived, dwBytesToGet, &dwBytesReceived, NULL);
|
||||
|
||||
dwTotalBytesReceived += dwBytesReceived;
|
||||
|
||||
if (!res)
|
||||
return false;
|
||||
else if (dwBytesReceived == 0)
|
||||
return false;
|
||||
|
||||
if (((DWORD)pszMaxRxLen) > dwTotalBytesReceived)
|
||||
dwBytesToGet -= dwBytesReceived;
|
||||
|
||||
} while (((DWORD)pszMaxRxLen) > dwTotalBytesReceived);
|
||||
|
||||
return (dwTotalBytesReceived == (DWORD) pszMaxRxLen);
|
||||
*/
|
||||
}
|
||||
|
||||
bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen) {
|
||||
|
|
Loading…
Reference in a new issue