Commit 90c5ea80 authored by Thomas Edwards's avatar Thomas Edwards
Browse files

returned to clock_realtime in prep for workaround

parent cc971b06
......@@ -211,14 +211,14 @@ int driver_serial::receive(char *buf, int buflen, double timeout,
// Timeout in nanoseconds
if (timeout>0){
// clock_gettime(CLOCK_REALTIME, &start_time);
clock_gettime(CLOCK_MONOTONIC_RAW, &start_time);
clock_gettime(CLOCK_REALTIME, &start_time);
}
// Repeat loop until all termination characters have been received
while (n < termlen) {
// clock_gettime(CLOCK_MONOTONIC, &test_time);
// clock_gettime(CLOCK_REALTIME, &test_time);
// fprintf(stderr,"LOOP TIME: %d\n",(int)(test_time.tv_nsec/1e3));
//
......@@ -226,11 +226,11 @@ int driver_serial::receive(char *buf, int buflen, double timeout,
//
if (timeout > 0) {
// clock_gettime(CLOCK_REALTIME, &end_time);
clock_gettime(CLOCK_MONOTONIC_RAW, &end_time);
clock_gettime(CLOCK_REALTIME, &end_time);
if ( (end_time.tv_sec-start_time.tv_sec)+end_time.tv_nsec/1e9 >=
start_time.tv_nsec/1e9+timeout ) {
//flush();
//fprintf(stderr,"TIMEOUT: %f %f\n",start_time.tv_nsec/1e9+timeout,
// fprintf(stderr,"TIMEOUT: %f %f\n",start_time.tv_nsec/1e9+timeout,
// (end_time.tv_sec-start_time.tv_sec)+end_time.tv_nsec/1e9);
fprintf(stderr, "Warning: Timeout. No response received.\n");
return (-1);
......@@ -255,6 +255,9 @@ int driver_serial::receive(char *buf, int buflen, double timeout,
// Time of first received character is saved
if (i == 0) {
clock_gettime(CLOCK_REALTIME, recv_time);
// clock_gettime(CLOCK_REALTIME, &test_time);
// fprintf(stderr,"MONO REAL DIFF: %d\n",(int)(recv_time->tv_nsec/1e3) - (int)(test_time.tv_nsec/1e3));
// fprintf(stderr,"REAL TIME: %d\n",(int)(test_time.tv_nsec/1e3));
}
// Reset termination check if not all characters are received in a row
if (n > 0) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment