- /* get fd settings */
- if ((iof = fcntl(fd, F_GETFL, 0)) != -1) {
- /* set fd non blocking */
- fcntl(fd, F_SETFL, iof | O_NONBLOCK);
- /* read input */
- if (read(fd, &ev, sizeof(ev)) < 0) {
- if (num_warnings % 10000 == 0) {
- /* if device is not available anymore - dead or disconnected */
- fprintf(stderr, "Failed to read event from Jog Shuttle FILE DESCRIPTOR (repeated %d times)\n", num_warnings + 1);
- }
- /* exit if device is not available or the error occurs to long */
- if (errno == ENODEV) {
- perror("Failed to read from Jog Shuttle FILE DESCRIPTOR. Stop thread");
- /* stop thread */
- stop_me = true;
- } else if (num_warnings > 1000000) {
- perror("Failed to read from Jog Shuttle FILE DESCRIPTOR. Limit reached. Stop thread");
- /* stop thread */
- stop_me = true;
- }
- num_warnings++;
+ /* read input */
+ readResult = read(fd, &ev, sizeof(ev));
+ if (readResult < 0) {
+ if (num_warnings % 10000 == 0) {
+ /* if device is not available anymore - dead or disconnected */
+ fprintf(stderr, "Failed to read event from Jog Shuttle FILE DESCRIPTOR (repeated %d times)\n", num_warnings + 1);