diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/can/can-bus.cpp | 16 | ||||
-rw-r--r-- | src/can/can-bus.hpp | 2 | ||||
-rw-r--r-- | src/can/can-message.cpp | 2 | ||||
-rw-r--r-- | src/can/can-signals.cpp | 8 | ||||
-rw-r--r-- | src/diagnostic/diagnostic-message.cpp | 28 | ||||
-rw-r--r-- | src/diagnostic/diagnostic-message.hpp | 9 | ||||
-rw-r--r-- | src/utils/openxc-utils.cpp | 2 | ||||
-rw-r--r-- | src/utils/signals.cpp | 2 | ||||
-rw-r--r-- | src/utils/timer.cpp | 2 |
10 files changed, 32 insertions, 40 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8acdd1d..a1a3253 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -85,7 +85,6 @@ message(STATUS "Creation of ${PROJECT_NAME} binding for AFB-DAEMON") ########################################################################### add_library(${PROJECT_NAME} MODULE ${PROJECT_NAME}.cpp can/can-bus.cpp can/can-message.cpp can/can-signals.cpp can/can-decoder.cpp - obd2/obd2-signals.cpp utils/signals.cpp utils/openxc-utils.cpp utils/timer.cpp) target_link_libraries(${PROJECT_NAME} ${EXTRAS_LIBRARIES} bitfield isotp uds openxc pthread) diff --git a/src/can/can-bus.cpp b/src/can/can-bus.cpp index d46092b..851f62a 100644 --- a/src/can/can-bus.cpp +++ b/src/can/can-bus.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "can-bus.hpp" +#include "can/can-bus.hpp" #include <map> #include <cerrno> @@ -29,8 +29,8 @@ #include <json-c/json.h> #include <linux/can/raw.h> -#include "can-decoder.hpp" -#include "openxc-utils.hpp" +#include "can/can-decoder.hpp" +#include "utils/openxc-utils.hpp" extern "C" { @@ -74,7 +74,7 @@ void can_bus_t::can_decode_message() while(is_decoding_) { std::unique_lock<std::mutex> can_message_lock(can_message_mutex_); - new_can_message_.wait(can_message_lock); + new_can_message_cv_.wait(can_message_lock); can_message = next_can_message(); /* First we have to found which CanSignal it is */ @@ -144,7 +144,7 @@ void can_bus_t::can_event_push() */ void can_bus_t::start_threads() { - v_ = true; + is_decoding_ = true; th_decoding_ = std::thread(&can_bus_t::can_decode_message, this); if(!th_decoding_.joinable()) is_decoding_ = false; @@ -263,9 +263,9 @@ std::vector<std::string> can_bus_t::read_conf() } /** -* @brief return new_can_message_ member +* @brief return new_can_message_cv_ member * -* @return return new_can_message_ member +* @return return new_can_message_cv_ member */ std::condition_variable& can_bus_t::get_new_can_message_cv() { @@ -518,7 +518,7 @@ void can_bus_dev_t::can_reader(can_bus_t& can_bus) std::lock_guard<std::mutex> can_message_lock(can_bus.get_can_message_mutex()); can_bus.push_new_can_message(can_message); } - can_bus.get_new_can_message_cv_().notify_one(); + can_bus.get_new_can_message_cv().notify_one(); } } diff --git a/src/can/can-bus.hpp b/src/can/can-bus.hpp index bf0bdd3..0fa13b2 100644 --- a/src/can/can-bus.hpp +++ b/src/can/can-bus.hpp @@ -83,7 +83,7 @@ class can_bus_t { can_message_t next_can_message(); void push_new_can_message(const can_message_t& can_msg); std::mutex& get_can_message_mutex(); - std::condition_variable& get_new_can_message_cv_(); + std::condition_variable& get_new_can_message_cv(); openxc_VehicleMessage next_vehicle_message(); void push_new_vehicle_message(const openxc_VehicleMessage& v_msg); diff --git a/src/can/can-message.cpp b/src/can/can-message.cpp index ad03202..71e4879 100644 --- a/src/can/can-message.cpp +++ b/src/can/can-message.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "can-message.hpp" +#include "can/can-message.hpp" #include <cstring> diff --git a/src/can/can-signals.cpp b/src/can/can-signals.cpp index 07689a0..64980b0 100644 --- a/src/can/can-signals.cpp +++ b/src/can/can-signals.cpp @@ -15,13 +15,13 @@ * limitations under the License. */ -#include "can-signals.hpp" +#include "can/can-signals.hpp" #include <fnmatch.h> -#include "signals.hpp" -#include "obd2-signals.hpp" -#include "can-decoder.hpp" +#include "utils/signals.hpp" +#include "can/can-decoder.hpp" +#include "obd2/obd2-signals.hpp" #include "low-can-binding.hpp" std::vector<std::vector<CanMessageDefinition>> CAN_MESSAGES = { diff --git a/src/diagnostic/diagnostic-message.cpp b/src/diagnostic/diagnostic-message.cpp index bfca85b..c358aae 100644 --- a/src/diagnostic/diagnostic-message.cpp +++ b/src/diagnostic/diagnostic-message.cpp @@ -15,9 +15,11 @@ * limitations under the License. */ -#include "obd2-signals.hpp" +#include "obd2/obd2-signals.hpp" -#include "signals.hpp" +#include "utils/signals.hpp" + +#define OBD2_FUNCTIONAL_BROADCAST_ID 0x7df const char *UNIT_NAMES[10] = { "POURCENT", @@ -62,16 +64,9 @@ obd2_signals_t::obd2_signals_t(uint8_t pid, const char* generic_name, const int { } -void obd2_signals_t::init_diagnostic_shims(can_bus_dev_t& can_bus_dev) +std::vector<obd2_signals_t>& get_obd2_signals() { - DiagnosticShims shims_ = diagnostic_init_shims(shims_logger, can_bus_dev.send_can_message, NULL); - - int n_pids_, i_; - - n_pids_ = size(Obd2Pid); - for(i_=0; i_<=n_pids_; i_++) - { - } + return OBD2_PIDS; } /** @@ -83,7 +78,7 @@ void obd2_signals_t::init_diagnostic_shims(can_bus_dev_t& can_bus_dev) * * @return std::vector<std::string> Vector of signals name found. */ -void obd2_signals_t::find_obd2_signals(const openxc_DynamicField &key, std::vector<Obd2Pid*>& found_signals) +void obd2_signals_t::find_obd2_signals(const openxc_DynamicField &key, std::vector<obd2_signals_t*>& found_signals) { switch(key.type) { @@ -100,11 +95,6 @@ void obd2_signals_t::find_obd2_signals(const openxc_DynamicField &key, std::vect DEBUG(binder_interface, "Found %d signal(s)", (int)found_signals.size()); } -std::vector<Obd2Pid>& get_obd2_signals() -{ - return OBD2_PIDS; -} - uint32_t get_signal_id(const Obd2Pid& sig) { return (uint32_t)sig.pid; @@ -156,7 +146,9 @@ bool obd2_signals_t::is_obd2_response(can_message_t can_message) { debug("Sent message ID is outside the valid range for emulator (7DF to 7E7)"); status=false; -}; + } + return false; +} void obd2_signals_t::add_request(int pid) { diff --git a/src/diagnostic/diagnostic-message.hpp b/src/diagnostic/diagnostic-message.hpp index 1ee9d96..5a19393 100644 --- a/src/diagnostic/diagnostic-message.hpp +++ b/src/diagnostic/diagnostic-message.hpp @@ -76,14 +76,13 @@ class obd2_signals_t { bool supported_; public: + const char* generic_name = generic_name_; obd2_signals_t(uint8_t pid, const char* generic_name, const int min_, const int max_, enum UNIT unit, int frequency, bool supported); - void init_diagnostic_shims(can_bus_dev_t& can_bus_dev); void add_request(int pid); - std::vector<Obd2Pid>& get_obd2_signals(); uint32_t get_signal_id(const Obd2Pid& sig); - void find_obd2_signals(const openxc_DynamicField &key, std::vector<Obd2Pid*>& found_signals); + void find_obd2_signals(const openxc_DynamicField &key, std::vector<obd2_signals_t*>& found_signals); bool is_obd2_response(can_message_t can_message); @@ -91,4 +90,6 @@ class obd2_signals_t { bool is_obd2_signal(const char *name); float decode_obd2_response(const DiagnosticResponse* response, float parsedPayload); -};
\ No newline at end of file +}; + +std::vector<obd2_signals_t>& get_obd2_signals();
\ No newline at end of file diff --git a/src/utils/openxc-utils.cpp b/src/utils/openxc-utils.cpp index 40745a0..527f725 100644 --- a/src/utils/openxc-utils.cpp +++ b/src/utils/openxc-utils.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "openxc-utils.hpp" +#include "utils/openxc-utils.hpp" openxc_VehicleMessage build_VehicleMessage_with_SimpleMessage(openxc_DynamicField_Type type, const openxc_SimpleMessage& message) { diff --git a/src/utils/signals.cpp b/src/utils/signals.cpp index 6e2f396..a7510dc 100644 --- a/src/utils/signals.cpp +++ b/src/utils/signals.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "signals.hpp" +#include "utils/signals.hpp" /** * @brief Can signal event map making access to afb_event diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp index 01fd763..8dec706 100644 --- a/src/utils/timer.cpp +++ b/src/utils/timer.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "timer.hpp" +#include "utils/timer.hpp" long long int systemTimeMs() { |