2 * Copyright (C) 2015, 2016 "IoT.bzh"
3 * Author "Romain Forlot" <romain.forlot@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "active-diagnostic-request.hpp"
20 active_diagnostic_request_t::active_diagnostic_request_t()
21 : can_bus_dev_{nullptr}, uint32_t id_{0}, DiagnosticRequestHandle{nullptr}, name_{""},
22 decoder_{nullptr}, callback_{nullptr}, reccuring_{false}, wait_for_multiple_responses_{false},
23 in_flight_{false}, frequency_clock_{frequency_clock_t()}, timeout_clock_{frequency_clock_t()}
26 void updateDiagnosticRequestEntry(CanBus* bus, DiagnosticRequest* request,
27 const char* name, bool waitForMultipleResponses,
28 const DiagnosticResponseDecoder decoder,
29 const DiagnosticResponseCallback callback, float frequencyHz)
32 entry->arbitration_id = request->arbitration_id;
33 entry->handle = generate_diagnostic_request(
34 &manager->shims[bus->address - 1], request, NULL);
36 strncpy(entry->name, name, MAX_GENERIC_NAME_LENGTH);
38 entry->name[0] = '\0';
40 entry->waitForMultipleResponses = waitForMultipleResponses;
42 entry->decoder = decoder;
43 entry->callback = callback;
44 entry->recurring = frequencyHz != 0;
45 entry->frequencyClock = {0};
46 entry->frequencyClock.frequency = entry->recurring ? frequencyHz : 0;
47 // time out after 100ms
48 entry->timeoutClock = {0};
49 entry->timeoutClock.frequency = 10;
50 entry->inFlight = false;