###########################################################################
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)
* limitations under the License.
*/
-#include "can-bus.hpp"
+#include "can/can-bus.hpp"
#include <map>
#include <cerrno>
#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"
{
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 */
*/
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;
}
/**
-* @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()
{
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();
}
}
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);
* limitations under the License.
*/
-#include "can-message.hpp"
+#include "can/can-message.hpp"
#include <cstring>
* 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 = {
* 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",
{
}
-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;
}
/**
*
* @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)
{
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;
{
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)
{
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);
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
* 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)
{
* limitations under the License.
*/
-#include "signals.hpp"
+#include "utils/signals.hpp"
/**
* @brief Can signal event map making access to afb_event
* limitations under the License.
*/
-#include "timer.hpp"
+#include "utils/timer.hpp"
long long int systemTimeMs()
{