aboutsummaryrefslogtreecommitdiffstats
path: root/src/diagnostic
diff options
context:
space:
mode:
Diffstat (limited to 'src/diagnostic')
-rw-r--r--src/diagnostic/diagnostic-manager.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/diagnostic/diagnostic-manager.cpp b/src/diagnostic/diagnostic-manager.cpp
index 482a88fe..e7293ca6 100644
--- a/src/diagnostic/diagnostic-manager.cpp
+++ b/src/diagnostic/diagnostic-manager.cpp
@@ -27,6 +27,7 @@
#define MAX_RECURRING_DIAGNOSTIC_FREQUENCY_HZ 10
#define MAX_SIMULTANEOUS_DIAG_REQUESTS 50
#define MAX_REQUEST_ENTRIES 50
+#define TIMERFD_ACCURACY 0
#define MICRO 1000000
diagnostic_manager_t::diagnostic_manager_t()
@@ -250,18 +251,11 @@ bool diagnostic_manager_t::add_recurring_request(DiagnosticRequest* request, con
DEBUG(binder_interface, "Added recurring diagnostic request (freq: %f) on bus %s: %s",
frequencyHz, bus_->get_device_name().c_str(), request_string);
+ uint64_t usec;
+ usec = sd_event_now(afb_daemon_get_event_loop(binder_interface->daemon), CLOCK_MONOTONIC, &usec) + (uint64_t)(frequency_clock_t::frequency_to_period(frequencyHz)*MICRO);
if(sd_event_add_time(afb_daemon_get_event_loop(binder_interface->daemon), &source,
- CLOCK_MONOTONIC, (uint64_t)frequencyHz*MICRO, 0,send_request, request) >= 0)
- {
- if(sd_event_source_set_enabled(source, SD_EVENT_ON) >= 0)
- recurring_requests_.push_back(entry);
- else
- {
- ERROR(binder_interface, "add_reccurring_request: Request has not been enabled, it will occurs only one time");
- free_request_entries_.push_back(entry);
- added = false;
- }
- }
+ CLOCK_MONOTONIC, usec, TIMERFD_ACCURACY, send_request, request) >= 0)
+ recurring_requests_.push_back(entry);
else
{
ERROR(binder_interface, "add_recurring_request: Request fails to be schedule through event loop");
@@ -385,7 +379,18 @@ int diagnostic_manager_t::send_request(sd_event_source *s, uint64_t usec, void *
adr->get_timeout_clock().tick();
adr->set_in_flight(true);
return 1;
+
+ usec = usec + (uint64_t)(frequency_clock_t::frequency_to_period(adr->get_frequency_clock().get_frequency())*MICRO);
+ DEBUG(binder_interface, "send_request: usec: %d", usec);
+ if(sd_event_source_set_time(s, usec) >= 0)
+ if(sd_event_source_set_enabled(s, SD_EVENT_ON) >= 0)
+ {
+ dm.recurring_requests_.push_back(adr);
+ return 1;
+ }
}
+ dm.recurring_requests_.push_back(adr);
+ ERROR(binder_interface, "send_request: Something goes wrong when submitting a new request to the CAN bus");
return -1;
}