| 429 | extern int is_uh_radio_fd(int fd); |
| 430 | |
| 431 | static int port_read_sync_data_error_code(hamlib_port_t *p) |
| 432 | { |
| 433 | ssize_t total_bytes_read = 0; |
| 434 | signed char data; |
| 435 | int result; |
| 436 | |
| 437 | do |
| 438 | { |
| 439 | // Wait for data using a zero-length read |
| 440 | result = async_pipe_read(p->sync_data_error_pipe, &data, 0, p->timeout); |
| 441 | |
| 442 | if (result < 0) |
| 443 | { |
| 444 | if (result == -RIG_ETIMEOUT) |
| 445 | { |
| 446 | if (total_bytes_read > 0) |
| 447 | { |
| 448 | return data; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | return result; |
| 453 | } |
| 454 | |
| 455 | result = async_pipe_read(p->sync_data_error_pipe, &data, 1, p->timeout); |
| 456 | |
| 457 | if (result < 0) |
| 458 | { |
| 459 | if (result == -RIG_ETIMEOUT) |
| 460 | { |
| 461 | if (total_bytes_read > 0) |
| 462 | { |
| 463 | return data; |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | return result; |
| 468 | } |
| 469 | |
| 470 | total_bytes_read += result; |
| 471 | } |
| 472 | while (result > 0); |
| 473 | |
| 474 | return data; |
| 475 | } |
| 476 | |
| 477 | static int port_read_sync_data(hamlib_port_t *p, void *buf, size_t count) |
| 478 | { |
no test coverage detected