Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Achim Morschhauser
GeomagLogger
Commits
90c5ea80
Commit
90c5ea80
authored
Mar 15, 2021
by
Thomas Edwards
Browse files
returned to clock_realtime in prep for workaround
parent
cc971b06
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/driver_serial.cpp
View file @
90c5ea80
...
...
@@ -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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment