mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-23 04:04:54 +08:00
Merge dc7a59f329c0d13f351964a1f4b5fc3ae534c4b8 into 4ed3889979d6edaa6fe14d40c45f64b32606a2b8
This commit is contained in:
commit
0c73c46946
@ -454,7 +454,7 @@ Serial::SerialImpl::read (uint8_t *buf, size_t size)
|
|||||||
// Calculate the time select took
|
// Calculate the time select took
|
||||||
struct timeval diff;
|
struct timeval diff;
|
||||||
diff.tv_sec = end.tv_sec - start.tv_sec;
|
diff.tv_sec = end.tv_sec - start.tv_sec;
|
||||||
diff.tv_usec = static_cast<int> ((end.tv_nsec - start.tv_nsec) / 1000);
|
diff.tv_usec = static_cast<int> (((end.tv_nsec+diff.tv_sec*1000000000) - start.tv_nsec) / 1000);
|
||||||
// Update the timeout
|
// Update the timeout
|
||||||
if (total_timeout.tv_sec <= diff.tv_sec) {
|
if (total_timeout.tv_sec <= diff.tv_sec) {
|
||||||
total_timeout.tv_sec = 0;
|
total_timeout.tv_sec = 0;
|
||||||
@ -554,7 +554,7 @@ Serial::SerialImpl::write (const uint8_t *data, size_t length)
|
|||||||
// Calculate the time select took
|
// Calculate the time select took
|
||||||
struct timeval diff;
|
struct timeval diff;
|
||||||
diff.tv_sec = end.tv_sec - start.tv_sec;
|
diff.tv_sec = end.tv_sec - start.tv_sec;
|
||||||
diff.tv_usec = static_cast<int> ((end.tv_nsec - start.tv_nsec) / 1000);
|
diff.tv_usec = static_cast<int> (((end.tv_nsec+diff.tv_sec*1000000000) - start.tv_nsec) / 1000);
|
||||||
// Update the timeout
|
// Update the timeout
|
||||||
if (timeout.tv_sec <= diff.tv_sec) {
|
if (timeout.tv_sec <= diff.tv_sec) {
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user