33int32_t
read_fd_linux(uint8_t* buf, uint16_t count, int32_t timeout_ms,
void* arg)
38 while (total != count)
44 struct timeval* tv_p = NULL;
49 tv.tv_sec = timeout_ms / 1000;
50 tv.tv_usec = (int64_t) (timeout_ms % 1000) * 1000;
53 int ret = select(
fd + 1, &rfds, NULL, NULL, tv_p);
61 ssize_t r = read(
fd, buf + total, 1);
81int32_t
write_fd_linux(
const uint8_t* buf, uint16_t count, int32_t timeout_ms,
void* arg)
86 while (total != count)
92 struct timeval* tv_p = NULL;
97 tv.tv_sec = timeout_ms / 1000;
98 tv.tv_usec = (int64_t) (timeout_ms % 1000) * 1000;
101 int ret = select(
fd + 1, NULL, &wfds, NULL, tv_p);
109 ssize_t w = write(
fd, buf + total, count);
119 total += (int32_t) w;