1
0
mirror of https://github.com/wjwwood/serial.git synced 2026-01-22 19:54:57 +08:00

Merge dc7a59f329c0d13f351964a1f4b5fc3ae534c4b8 into 4ed3889979d6edaa6fe14d40c45f64b32606a2b8

This commit is contained in:
David Hodo 2013-05-22 18:37:05 -07:00
commit 0c73c46946

View File

@ -454,7 +454,7 @@ Serial::SerialImpl::read (uint8_t *buf, size_t size)
// Calculate the time select took
struct timeval diff;
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
if (total_timeout.tv_sec <= diff.tv_sec) {
total_timeout.tv_sec = 0;
@ -554,7 +554,7 @@ Serial::SerialImpl::write (const uint8_t *data, size_t length)
// Calculate the time select took
struct timeval diff;
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
if (timeout.tv_sec <= diff.tv_sec) {
timeout.tv_sec = 0;