Merge branch 'khorben/blocking'
This commit is contained in:
commit
7121808f28
@ -72,7 +72,7 @@ void CloseProxmark() {
|
||||
|
||||
int OpenProxmark(size_t i) {
|
||||
sp = uart_open(serial_port_name);
|
||||
if (sp == INVALID_SERIAL_PORT || sp == CLAIMED_SERIAL_PORT) {
|
||||
if (sp == INVALID_SERIAL_PORT || sp == CLAIMED_SERIAL_PORT || sp == NONBLOCKING_SERIAL_PORT) {
|
||||
//poll once a second
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ int main(int argc, char* argv[]) {
|
||||
msleep(1000);
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
} while(++openCount < 20 && (sp == INVALID_SERIAL_PORT || sp == CLAIMED_SERIAL_PORT));
|
||||
} while(++openCount < 20 && (sp == INVALID_SERIAL_PORT || sp == CLAIMED_SERIAL_PORT || sp == NONBLOCKING_SERIAL_PORT));
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
@ -56,6 +56,10 @@ typedef void* serial_port;
|
||||
*/
|
||||
#define CLAIMED_SERIAL_PORT (void*)(~2)
|
||||
|
||||
/* Returned by uart_open if the serial port specified is in non-blocking mode.
|
||||
*/
|
||||
#define NONBLOCKING_SERIAL_PORT (void*)(~4)
|
||||
|
||||
/* Given a user-specified port name, connect to the port and return a structure
|
||||
* used for future references to that port.
|
||||
*
|
||||
|
||||
@ -86,6 +86,13 @@ serial_port uart_open(const char* pcPortName)
|
||||
return CLAIMED_SERIAL_PORT;
|
||||
}
|
||||
|
||||
int i;
|
||||
i = fcntl(sp->fd, F_GETFL, 0);
|
||||
if((i & ~O_NONBLOCK) != i && fcntl(sp->fd, F_SETFL, i & ~O_NONBLOCK) != 0) {
|
||||
free(sp);
|
||||
return NONBLOCKING_SERIAL_PORT;
|
||||
}
|
||||
|
||||
// Try to retrieve the old (current) terminal info struct
|
||||
if(tcgetattr(sp->fd,&sp->tiOld) == -1) {
|
||||
uart_close(sp);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user