diff options
author | 2017-07-20 16:40:35 +0200 | |
---|---|---|
committer | 2017-07-21 12:02:11 +0200 | |
commit | ab6a4a5eb285a1ca88b3ad87ee035b9956e253ed (patch) | |
tree | 00de00bb9722bfdbbf9d015ce691894f9a1eccde /examples | |
parent | e2af4a871c6a8bcab4733193948833aed9c5ceb8 (diff) |
Examples reorganization
Separated by protocols and created signals from reversed
engineered signals.
Meld all used signals into an "agl-vcar" folder to be used as
default.
Change-Id: I27f7bc227a6fcea3db6672819e6a4d7bbf09863b
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/OBD2/application-generated.cpp | 274 | ||||
-rw-r--r-- | examples/OBD2/signals.json | 158 | ||||
-rw-r--r-- | examples/agl-vcar/application-generated.cpp | 640 | ||||
-rw-r--r-- | examples/agl-vcar/signals.json | 323 | ||||
-rw-r--r-- | examples/basic/application-generated.cpp (renamed from examples/basic/generate_example.cpp) | 0 | ||||
-rw-r--r-- | examples/engine/application-generated.cpp | 163 | ||||
-rw-r--r-- | examples/engine/signals.json | 68 | ||||
-rw-r--r-- | examples/hvac/application-generated.cpp | 119 | ||||
-rw-r--r-- | examples/hvac/signals.json | 345 | ||||
-rw-r--r-- | examples/toyota/auris/application-generated.cpp | 564 | ||||
-rw-r--r-- | examples/toyota/auris/signals.json (renamed from examples/toyota/signals.json) | 0 | ||||
-rw-r--r-- | examples/toyota/configuration-generated.cpp | 339 |
12 files changed, 2341 insertions, 652 deletions
diff --git a/examples/OBD2/application-generated.cpp b/examples/OBD2/application-generated.cpp new file mode 100644 index 0000000..f66748b --- /dev/null +++ b/examples/OBD2/application-generated.cpp @@ -0,0 +1,274 @@ +#include "application.hpp" +#include "../can/can-decoder.hpp" + +application_t::application_t() + : can_bus_manager_{utils::config_parser_t{"/etc/dev-mapping.conf"}} + , can_message_set_{ + {std::make_shared<can_message_set_t>(can_message_set_t{0,"example", + { // beginning can_message_definition_ vector + + }, // end can_message_definition vector + { // beginning diagnostic_messages_ vector + {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 4, + "engine.load", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 5, + "engine.coolant.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 10, + "fuel.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 11, + "intake.manifold.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 12, + "engine.speed", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 13, + "vehicle.speed", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 15, + "intake.air.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 16, + "mass.airflow", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 17, + "throttle.position", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 31, + "running.time", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 45, + "EGR.error", + 0, + 0, + UNIT::INVALID, + 0.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 47, + "fuel.level", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 51, + "barometric.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 70, + "ambient.air.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 76, + "commanded.throttle.position", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 82, + "ethanol.fuel.percentage", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 90, + "accelerator.pedal.position", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 91, + "hybrid.battery-pack.remaining.life", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 92, + "engine.oil.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 94, + "engine.fuel.rate", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 99, + "engine.torque", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} + + } // end diagnostic_messages_ vector + })} // end can_message_set entry + } // end can_message_set vector +{ + for(auto& cms: can_message_set_) + { + std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition(); + for(auto& cmd : can_messages_definition) + { + cmd->set_parent(cms.get()); + std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals(); + for(auto& sig: can_signals) + { + sig->set_parent(cmd.get()); + } + } + + std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages(); + for(auto& dm : diagnostic_messages) + { + dm->set_parent(cms.get()); + } + } + } + +const std::string application_t::get_diagnostic_bus() const +{ + return "hs"; +} + + diff --git a/examples/OBD2/signals.json b/examples/OBD2/signals.json new file mode 100644 index 0000000..8927629 --- /dev/null +++ b/examples/OBD2/signals.json @@ -0,0 +1,158 @@ +{ "name": "example", + "extra_sources": [], + "initializers": [], + "loopers": [], + "buses": {}, + "commands": [], + "messages": { + }, +"diagnostic_messages": [ + { + "bus": "hs", + "pid": 4, + "name": "engine.load", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 5, + "name": "engine.coolant.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 10, + "name": "fuel.pressure", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 11, + "name": "intake.manifold.pressure", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 12, + "name": "engine.speed", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 13, + "name": "vehicle.speed", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 15, + "name": "intake.air.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 16, + "name": "mass.airflow", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 17, + "name": "throttle.position", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 31, + "name": "running.time", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 45, + "name": "EGR.error", + "frequency": 0, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 47, + "name": "fuel.level", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 51, + "name": "barometric.pressure", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 70, + "name": "ambient.air.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 76, + "name": "commanded.throttle.position", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 82, + "name": "ethanol.fuel.percentage", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 90, + "name": "accelerator.pedal.position", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 91, + "name": "hybrid.battery-pack.remaining.life", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 92, + "name": "engine.oil.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 94, + "name": "engine.fuel.rate", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 99, + "name": "engine.torque", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + } + ] +} diff --git a/examples/agl-vcar/application-generated.cpp b/examples/agl-vcar/application-generated.cpp new file mode 100644 index 0000000..876b95b --- /dev/null +++ b/examples/agl-vcar/application-generated.cpp @@ -0,0 +1,640 @@ +#include "application.hpp" +#include "../can/can-decoder.hpp" + +application_t::application_t() + : can_bus_manager_{utils::config_parser_t{"/etc/dev-mapping.conf"}} + , can_message_set_{ + {std::make_shared<can_message_set_t>(can_message_set_t{0,"example", + { // beginning can_message_definition_ vector + {std::make_shared<can_message_definition_t>(can_message_definition_t{"ls",0x30,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "hvac.fan.speed", + 32, + 8, + 23.5294f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "hvac.temperature.left", + 0, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "hvac.temperature.right", + 8, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "hvac.temperature.average", + 16, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3D9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.speed", + 16, + 16, + 0.250000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "fuel.level.low", + 55, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "fuel.level", + 8, + 8, + 0.392157f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3E9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "vehicle.average.speed", + 0, + 15, + 0.0156250f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x4D1,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.oil.temp", + 16, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.oil.temp.high", + 7, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x620,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.boot.open", + 47, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.front_left.open", + 43, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.front_right.open", + 44, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.rear_left.open", + 46, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.rear_right.open", + 45, + 4, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x799,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "windows.front_left.open", + 43, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "windows.front_right.open", + 44, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "windows.rear_left.open", + 46, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "windows.rear_right.open", + 45, + 4, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::decode_boolean, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry + + }, // end can_message_definition vector + { // beginning diagnostic_messages_ vector + {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 4, + "engine.load", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 5, + "engine.coolant.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 10, + "fuel.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 11, + "intake.manifold.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 12, + "engine.speed", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 13, + "vehicle.speed", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 15, + "intake.air.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 16, + "mass.airflow", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 17, + "throttle.position", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 31, + "running.time", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 45, + "EGR.error", + 0, + 0, + UNIT::INVALID, + 0.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 47, + "fuel.level", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 51, + "barometric.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 70, + "ambient.air.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 76, + "commanded.throttle.position", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 82, + "ethanol.fuel.percentage", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 90, + "accelerator.pedal.position", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 91, + "hybrid.battery-pack.remaining.life", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 92, + "engine.oil.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 94, + "engine.fuel.rate", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 99, + "engine.torque", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} + + } // end diagnostic_messages_ vector + })} // end can_message_set entry + } // end can_message_set vector +{ + for(auto& cms: can_message_set_) + { + std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition(); + for(auto& cmd : can_messages_definition) + { + cmd->set_parent(cms.get()); + std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals(); + for(auto& sig: can_signals) + { + sig->set_parent(cmd.get()); + } + } + + std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages(); + for(auto& dm : diagnostic_messages) + { + dm->set_parent(cms.get()); + } + } + } + +const std::string application_t::get_diagnostic_bus() const +{ + return "hs"; +} + + diff --git a/examples/agl-vcar/signals.json b/examples/agl-vcar/signals.json new file mode 100644 index 0000000..9fa9b30 --- /dev/null +++ b/examples/agl-vcar/signals.json @@ -0,0 +1,323 @@ +{ "name": "AGL Virtual Car", + "extra_sources": [], + "initializers": [], + "loopers": [], + "buses": {}, + "commands": [], + "messages": { + "0x620": { + "bus": "hs", + "signals": { + "doors.driver.open": { + "generic_name": "doors.front_left.open", + "bit_position": 43, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "decoder": "decoder_t::decode_boolean"}, + "doors.passenger.open": { + "generic_name": "doors.front_right.open", + "bit_position": 44, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "decoder": "decoder_t::booleanDecoder"}, + "doors.rearleft.open": { + "generic_name": "doors.rear_left.open", + "bit_position": 46, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "decoder": "decoder_t::booleanDecoder"}, + "doors.rearright.open": { + "generic_name": "doors.rear_right.open", + "bit_position": 45, + "bit_size": 4, + "factor": 1.0, + "offset": 0, + "decoder": "decoder_t::booleanDecoder"}, + "doors.coffer.open": { + "generic_name": "doors.boot.open", + "bit_position": 47, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "decoder": "decoder_t::booleanDecoder"} + } + }, + "0x799": { + "bus": "hs", + "signals": { + "windows.driver.open": { + "generic_name": "windows.front_left.open", + "bit_position": 43, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "decoder": "decoder_t::booleanDecoder"}, + "windows.passenger.open": { + "generic_name": "windows.front_right.open", + "bit_position": 44, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "decoder": "decoder_t::booleanDecoder"}, + "windows.rearleft.open": { + "generic_name": "windows.rear_left.open", + "bit_position": 46, + "bit_size": 1, + "factor": 1.0, + "offset": 0, + "decoder": "decoder_t::booleanDecoder"}, + "windows.rearright.open": { + "generic_name": "windows.rear_right.open", + "bit_position": 45, + "bit_size": 4, + "factor": 1.0, + "offset": 0, + "decoder": "decoder_t::booleanDecoder"} + } + }, + "0x3D9": { + "bus": "hs", + "signals": { + "PT_FuelLevelPct": { + "generic_name": "fuel.level", + "bit_position": 8, + "bit_size": 8, + "factor": 0.392157, + "offset": 0 + }, + "PT_EngineSpeed": { + "generic_name": "engine.speed", + "bit_position": 16, + "bit_size": 16, + "factor": 0.25, + "offset": 0 + }, + "PT_FuelLevelLow": { + "generic_name": "fuel.level.low", + "bit_position": 55, + "bit_size": 1, + "factor": 1, + "offset": 0, + "decoder": "decoder_t::booleanDecoder" + } + } + }, + "0x4D1": { + "bus": "hs", + "signals": { + "PT_EngineOilTempHigh": { + "generic_name": "engine.oil.temp.high", + "bit_position": 7, + "bit_size": 1, + "factor": 1, + "offset": 0, + "decoder": "decoder_t::booleanDecoder" + }, + "PT_EngineOilTemp": { + "generic_name": "engine.oil.temp", + "bit_position": 16, + "bit_size": 8, + "factor": 1, + "offset": 0 + } + } + }, + "0x3E9": { + "bus": "hs", + "signals": { + "PT_VehicleAvgSpeed": { + "generic_name": "vehicle.average.speed", + "bit_position": 0, + "bit_size": 15, + "factor": 0.015625, + "offset": 0 + } + } + }, + "0x30": { + "bus": "ls", + "signals": { + "LeftTemperature": { + "generic_name": "hvac.temperature.left", + "bit_position": 0, + "bit_size": 8, + "factor": 1, + "offset": 0 + }, + "RightTemperature": { + "generic_name": "hvac.temperature.right", + "bit_position": 8, + "bit_size": 8, + "factor": 1, + "offset": 0 + }, + "Temperature": { + "generic_name": "hvac.temperature.average", + "bit_position": 16, + "bit_size": 8, + "factor": 1, + "offset": 0 + }, + "FanSpeed": { + "generic_name": "hvac.fan.speed", + "bit_position": 32, + "bit_size": 8, + "factor": 23.529411765, + "offset": 0 + } + } + } +}, +"diagnostic_messages": [ + { + "bus": "hs", + "pid": 4, + "name": "engine.load", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 5, + "name": "engine.coolant.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 10, + "name": "fuel.pressure", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 11, + "name": "intake.manifold.pressure", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 12, + "name": "engine.speed", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 13, + "name": "vehicle.speed", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 15, + "name": "intake.air.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 16, + "name": "mass.airflow", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 17, + "name": "throttle.position", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 31, + "name": "running.time", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 45, + "name": "EGR.error", + "frequency": 0, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 47, + "name": "fuel.level", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 51, + "name": "barometric.pressure", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 70, + "name": "ambient.air.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 76, + "name": "commanded.throttle.position", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 82, + "name": "ethanol.fuel.percentage", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 90, + "name": "accelerator.pedal.position", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 91, + "name": "hybrid.battery-pack.remaining.life", + "frequency": 5, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 92, + "name": "engine.oil.temperature", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 94, + "name": "engine.fuel.rate", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + }, + { + "bus": "hs", + "pid": 99, + "name": "engine.torque", + "frequency": 1, + "decoder": "decoder_t::decode_obd2_response" + } + ] +} diff --git a/examples/basic/generate_example.cpp b/examples/basic/application-generated.cpp index 88ee94b..88ee94b 100644 --- a/examples/basic/generate_example.cpp +++ b/examples/basic/application-generated.cpp diff --git a/examples/engine/application-generated.cpp b/examples/engine/application-generated.cpp new file mode 100644 index 0000000..cc123b7 --- /dev/null +++ b/examples/engine/application-generated.cpp @@ -0,0 +1,163 @@ +#include "application.hpp" +#include "../can/can-decoder.hpp" + +application_t::application_t() + : can_bus_manager_{utils::config_parser_t{"/etc/dev-mapping.conf"}} + , can_message_set_{ + {std::make_shared<can_message_set_t>(can_message_set_t{0,"example", + { // beginning can_message_definition_ vector + {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3D9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.speed", + 16, + 16, + 0.250000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "fuel.level.low", + 55, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "fuel.level", + 8, + 8, + 0.392157f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3E9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "vehicle.average.speed", + 0, + 15, + 0.0156250f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x4D1,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.oil.temp", + 16, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.oil.temp.high", + 7, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry + + }, // end can_message_definition vector + { // beginning diagnostic_messages_ vector + + } // end diagnostic_messages_ vector + })} // end can_message_set entry + } // end can_message_set vector +{ + for(auto& cms: can_message_set_) + { + std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition(); + for(auto& cmd : can_messages_definition) + { + cmd->set_parent(cms.get()); + std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals(); + for(auto& sig: can_signals) + { + sig->set_parent(cmd.get()); + } + } + + std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages(); + for(auto& dm : diagnostic_messages) + { + dm->set_parent(cms.get()); + } + } + } + +const std::string application_t::get_diagnostic_bus() const +{ + return ""; +} + + diff --git a/examples/engine/signals.json b/examples/engine/signals.json new file mode 100644 index 0000000..5aaf656 --- /dev/null +++ b/examples/engine/signals.json @@ -0,0 +1,68 @@ +{ "name": "example", + "extra_sources": [], + "initializers": [], + "loopers": [], + "buses": {}, + "commands": [], + "messages": { + "0x3D9": { + "bus": "hs", + "signals": { + "PT_FuelLevelPct": { + "generic_name": "fuel.level", + "bit_position": 8, + "bit_size": 8, + "factor": 0.392157, + "offset": 0 + }, + "PT_EngineSpeed": { + "generic_name": "engine.speed", + "bit_position": 16, + "bit_size": 16, + "factor": 0.25, + "offset": 0 + }, + "PT_FuelLevelLow": { + "generic_name": "fuel.level.low", + "bit_position": 55, + "bit_size": 1, + "factor": 1, + "offset": 0, + "decoder": "decoder_t::booleanDecoder" + } + } + }, + "0x4D1": { + "bus": "hs", + "signals": { + "PT_EngineOilTempHigh": { + "generic_name": "engine.oil.temp.high", + "bit_position": 7, + "bit_size": 1, + "factor": 1, + "offset": 0, + "decoder": "decoder_t::booleanDecoder" + }, + "PT_EngineOilTemp": { + "generic_name": "engine.oil.temp", + "bit_position": 16, + "bit_size": 8, + "factor": 1, + "offset": 0 + } + } + }, + "0x3E9": { + "bus": "hs", + "signals": { + "PT_VehicleAvgSpeed": { + "generic_name": "vehicle.average.speed", + "bit_position": 0, + "bit_size": 15, + "factor": 0.015625, + "offset": 0 + } + } + } +} +} diff --git a/examples/hvac/application-generated.cpp b/examples/hvac/application-generated.cpp new file mode 100644 index 0000000..67b0924 --- /dev/null +++ b/examples/hvac/application-generated.cpp @@ -0,0 +1,119 @@ +#include "application.hpp" +#include "../can/can-decoder.hpp" + +application_t::application_t() + : can_bus_manager_{utils::config_parser_t{"/etc/dev-mapping.conf"}} + , can_message_set_{ + {std::make_shared<can_message_set_t>(can_message_set_t{0,"example", + { // beginning can_message_definition_ vector + {std::make_shared<can_message_definition_t>(can_message_definition_t{"ls",0x30,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "hvac.fan.speed", + 32, + 8, + 23.5294f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "hvac.temperature.left", + 0, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "hvac.temperature.right", + 8, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "hvac.temperature.average", + 16, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry + + }, // end can_message_definition vector + { // beginning diagnostic_messages_ vector + + } // end diagnostic_messages_ vector + })} // end can_message_set entry + } // end can_message_set vector +{ + for(auto& cms: can_message_set_) + { + std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition(); + for(auto& cmd : can_messages_definition) + { + cmd->set_parent(cms.get()); + std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals(); + for(auto& sig: can_signals) + { + sig->set_parent(cmd.get()); + } + } + + std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages(); + for(auto& dm : diagnostic_messages) + { + dm->set_parent(cms.get()); + } + } + } + +const std::string application_t::get_diagnostic_bus() const +{ + return ""; +} + + diff --git a/examples/hvac/signals.json b/examples/hvac/signals.json index 06dcd8b..81ad64b 100644 --- a/examples/hvac/signals.json +++ b/examples/hvac/signals.json @@ -5,319 +5,38 @@ "buses": {}, "commands": [], "messages": { - "0x620": { - "bus": "hs", - "signals": { - "doors.driver.open": { - "generic_name": "doors.front_left.open", - "bit_position": 43, - "bit_size": 1, - "factor": 1.0, - "offset": 0, - "decoder": "decoder_t::booleanDecoder"}, - "doors.passenger.open": { - "generic_name": "doors.front_right.open", - "bit_position": 44, - "bit_size": 1, - "factor": 1.0, - "offset": 0, - "decoder": "decoder_t::booleanDecoder"}, - "doors.rearleft.open": { - "generic_name": "doors.rear_left.open", - "bit_position": 46, - "bit_size": 1, - "factor": 1.0, - "offset": 0, - "decoder": "decoder_t::booleanDecoder"}, - "doors.rearright.open": { - "generic_name": "doors.rear_right.open", - "bit_position": 45, - "bit_size": 4, - "factor": 1.0, - "offset": 0, - "decoder": "decoder_t::booleanDecoder"}, - "doors.coffer.open": { - "generic_name": "doors.boot.open", - "bit_position": 47, - "bit_size": 1, - "factor": 1.0, - "offset": 0, - "decoder": "decoder_t::booleanDecoder"} - } - }, - "0x799": { - "bus": "hs", - "signals": { - "windows.driver.open": { - "generic_name": "windows.front_left.open", - "bit_position": 43, - "bit_size": 1, - "factor": 1.0, - "offset": 0, - "decoder": "decoder_t::booleanDecoder"}, - "windows.passenger.open": { - "generic_name": "windows.front_right.open", - "bit_position": 44, - "bit_size": 1, - "factor": 1.0, - "offset": 0, - "decoder": "decoder_t::booleanDecoder"}, - "windows.rearleft.open": { - "generic_name": "windows.rear_left.open", - "bit_position": 46, - "bit_size": 1, - "factor": 1.0, - "offset": 0, - "decoder": "decoder_t::booleanDecoder"}, - "windows.rearright.open": { - "generic_name": "windows.rear_right.open", - "bit_position": 45, - "bit_size": 4, - "factor": 1.0, - "offset": 0, - "decoder": "decoder_t::booleanDecoder"} - } - }, - "0x3D9": { - "bus": "hs", - "signals": { - "PT_FuelLevelPct": { - "generic_name": "fuel.level", - "bit_position": 8, - "bit_size": 8, - "factor": 0.392157, - "offset": 0 - }, - "PT_EngineSpeed": { - "generic_name": "engine.speed", - "bit_position": 16, - "bit_size": 16, - "factor": 0.25, - "offset": 0 - }, - "PT_FuelLevelLow": { - "generic_name": "fuel.level.low", - "bit_position": 55, - "bit_size": 1, - "factor": 1, - "offset": 0, - "decoder": "decoder_t::booleanDecoder" - } - } - }, - "0x4D1": { - "bus": "hs", - "signals": { - "PT_EngineOilTempHigh": { - "generic_name": "engine.oil.temp.high", - "bit_position": 7, - "bit_size": 1, - "factor": 1, - "offset": 0, - "decoder": "decoder_t::booleanDecoder" - }, - "PT_EngineOilTemp": { - "generic_name": "engine.oil.temp", - "bit_position": 16, - "bit_size": 8, - "factor": 1, - "offset": 0 - } - } - }, - "0x3E9": { - "bus": "hs", - "signals": { - "PT_VehicleAvgSpeed": { - "generic_name": "vehicle.average.speed", - "bit_position": 0, - "bit_size": 15, - "factor": 0.015625, - "offset": 0 + "0x30": { + "bus": "ls", + "signals": { + "LeftTemperature": { + "generic_name": "hvac.temperature.left", + "bit_position": 0, + "bit_size": 8, + "factor": 1, + "offset": 0 + }, + "RightTemperature": { + "generic_name": "hvac.temperature.right", + "bit_position": 8, + "bit_size": 8, + "factor": 1, + "offset": 0 + }, + "Temperature": { + "generic_name": "hvac.temperature.average", + "bit_position": 16, + "bit_size": 8, + "factor": 1, + "offset": 0 + }, + "FanSpeed": { + "generic_name": "hvac.fan.speed", + "bit_position": 32, + "bit_size": 8, + "factor": 23.529411765, + "offset": 0 + } } } - }, - "0x30": { - "bus": "ls", - "signals": { - "LeftTemperature": { - "generic_name": "hvac.temperature.left", - "bit_position": 0, - "bit_size": 8, - "factor": 1, - "offset": 0 - }, - "RightTemperature": { - "generic_name": "hvac.temperature.right", - "bit_position": 8, - "bit_size": 8, - "factor": 1, - "offset": 0 - }, - "Temperature": { - "generic_name": "hvac.temperature.average", - "bit_position": 16, - "bit_size": 8, - "factor": 1, - "offset": 0 - }, - "FanSpeed": { - "generic_name": "hvac.fan.speed", - "bit_position": 32, - "bit_size": 8, - "factor": 23.529411765, - "offset": 0 - } - } - } -}, -"diagnostic_messages": [ - { - "bus": "hs", - "pid": 4, - "name": "engine.load", - "frequency": 5, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 5, - "name": "engine.coolant.temperature", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 10, - "name": "fuel.pressure", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 11, - "name": "intake.manifold.pressure", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 12, - "name": "engine.speed", - "frequency": 5, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 13, - "name": "vehicle.speed", - "frequency": 5, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 15, - "name": "intake.air.temperature", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 16, - "name": "mass.airflow", - "frequency": 5, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 17, - "name": "throttle.position", - "frequency": 5, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 31, - "name": "running.time", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 45, - "name": "EGR.error", - "frequency": 0, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 47, - "name": "fuel.level", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 51, - "name": "barometric.pressure", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 70, - "name": "ambient.air.temperature", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 76, - "name": "commanded.throttle.position", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 82, - "name": "ethanol.fuel.percentage", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 90, - "name": "accelerator.pedal.position", - "frequency": 5, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 91, - "name": "hybrid.battery-pack.remaining.life", - "frequency": 5, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 92, - "name": "engine.oil.temperature", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 94, - "name": "engine.fuel.rate", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - }, - { - "bus": "hs", - "pid": 99, - "name": "engine.torque", - "frequency": 1, - "decoder": "decoder_t::decode_obd2_response" - } - ] +} } diff --git a/examples/toyota/auris/application-generated.cpp b/examples/toyota/auris/application-generated.cpp new file mode 100644 index 0000000..60a21f5 --- /dev/null +++ b/examples/toyota/auris/application-generated.cpp @@ -0,0 +1,564 @@ +#include "application.hpp" +#include "../can/can-decoder.hpp" + +application_t::application_t() + : can_bus_manager_{utils::config_parser_t{"/etc/dev-mapping.conf"}} + , can_message_set_{ + {std::make_shared<can_message_set_t>(can_message_set_t{0,"example", + { // beginning can_message_definition_ vector + {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3D9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.speed", + 16, + 16, + 0.250000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "fuel.level.low", + 55, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "fuel.level", + 8, + 8, + 0.392157f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3E9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "vehicle.average.speed", + 0, + 15, + 0.0156250f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x4D1,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.oil.temp", + 16, + 8, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + nullptr, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "engine.oil.temp.high", + 7, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x620,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.boot.open", + 47, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.front_left.open", + 43, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.front_right.open", + 44, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.rear_left.open", + 46, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "doors.rear_right.open", + 45, + 4, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry +, {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x799,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true, + { // beginning can_signals vector + {std::make_shared<can_signal_t> (can_signal_t{ + "windows.front_left.open", + 43, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "windows.front_right.open", + 44, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "windows.rear_left.open", + 46, + 1, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> (can_signal_t{ + "windows.rear_right.open", + 45, + 4, + 1.00000f, + 0.00000, + 0, + 0, + frequency_clock_t(0.00000f), + true, + false, + { + }, + false, + decoder_t::booleanDecoder, + nullptr, + false + })} + } // end can_signals vector + })} // end can_message_definition entry + + }, // end can_message_definition vector + { // beginning diagnostic_messages_ vector + {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 4, + "engine.load", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 5, + "engine.coolant.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 10, + "fuel.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 11, + "intake.manifold.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 12, + "engine.speed", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 13, + "vehicle.speed", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 15, + "intake.air.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 16, + "mass.airflow", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 17, + "throttle.position", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 31, + "running.time", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 45, + "EGR.error", + 0, + 0, + UNIT::INVALID, + 0.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 47, + "fuel.level", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 51, + "barometric.pressure", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 70, + "ambient.air.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 76, + "commanded.throttle.position", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 82, + "ethanol.fuel.percentage", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 90, + "accelerator.pedal.position", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 91, + "hybrid.battery-pack.remaining.life", + 0, + 0, + UNIT::INVALID, + 5.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 92, + "engine.oil.temperature", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 94, + "engine.fuel.rate", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} +, {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ + 99, + "engine.torque", + 0, + 0, + UNIT::INVALID, + 1.00000f, + decoder_t::decode_obd2_response, + nullptr, + true + })} + + } // end diagnostic_messages_ vector + })} // end can_message_set entry + } // end can_message_set vector +{ + for(auto& cms: can_message_set_) + { + std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition(); + for(auto& cmd : can_messages_definition) + { + cmd->set_parent(cms.get()); + std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals(); + for(auto& sig: can_signals) + { + sig->set_parent(cmd.get()); + } + } + + std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages(); + for(auto& dm : diagnostic_messages) + { + dm->set_parent(cms.get()); + } + } + } + +const std::string application_t::get_diagnostic_bus() const +{ + return "hs"; +} + + diff --git a/examples/toyota/signals.json b/examples/toyota/auris/signals.json index cd08918..cd08918 100644 --- a/examples/toyota/signals.json +++ b/examples/toyota/auris/signals.json diff --git a/examples/toyota/configuration-generated.cpp b/examples/toyota/configuration-generated.cpp deleted file mode 100644 index 61149c5..0000000 --- a/examples/toyota/configuration-generated.cpp +++ /dev/null @@ -1,339 +0,0 @@ -#include "application.hpp" -#include "can/can-decoder.hpp" - -application_t::application_t() - : can_message_set_{{0, "example", 0, 1, 5, 0, 19}} - , can_message_definition_ - { - { - can_message_definition_t(0, "can0", 0x620, can_message_format_t::STANDARD, frequency_clock_t(0.00000f), true) - } - } - , can_signals_ - { - { - { - 0, - 0, - "doors.coffer.open", - 88, - 1, - 0.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - true, - false, - { - }, - false, - decoder_t::decode_boolean, - nullptr, - false - }, - { - 0, - 0, - "doors.driver.open", - 78, - 1, - 0.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - true, - false, - { - }, - false, - decoder_t::decode_boolean, - nullptr, - false - }, - { - 0, - 0, - "doors.passenger.open", - 79, - 1, - 0.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - true, - false, - { - }, - false, - decoder_t::decode_boolean, - nullptr, - false - }, - { - 0, - 0, - "doors.rearleft.open", - 86, - 1, - 0.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - true, - false, - { - }, - false, - decoder_t::decode_boolean, - nullptr, - false - }, - { - 0, - 0, - "doors.rearright.open", - 85, - 4, - 0.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - true, - false, - { - }, - false, - decoder_t::decode_boolean, - nullptr, - false - } - } - } - , diagnostic_messages_ - { - { - { - 4, - "engine.load", - 0, - 0, - UNIT::INVALID, - 5.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 5, - "engine.coolant.temperature", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 10, - "fuel.pressure", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 11, - "intake.manifold.pressure", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 12, - "engine.speed", - 0, - 0, - UNIT::INVALID, - 5.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 13, - "vehicle.speed", - 0, - 0, - UNIT::INVALID, - 5.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 15, - "intake.air.temperature", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 16, - "mass.airflow", - 0, - 0, - UNIT::INVALID, - 5.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 17, - "throttle.position", - 0, - 0, - UNIT::INVALID, - 5.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 31, - "running.time", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 45, - "EGR.error", - 0, - 0, - UNIT::INVALID, - 0.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 47, - "fuel.level", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 51, - "barometric.pressure", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 76, - "commanded.throttle.position", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 82, - "ethanol.fuel.percentage", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 90, - "accelerator.pedal.position", - 0, - 0, - UNIT::INVALID, - 5.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 91, - "hybrid.battery-pack.remaining.life", - 0, - 0, - UNIT::INVALID, - 5.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 92, - "engine.oil.temperature", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - }, - { - 99, - "engine.torque", - 0, - 0, - UNIT::INVALID, - 1.00000f, - decoder_t::decode_obd2_response, - nullptr, - true - } - } - } -{ -} - -const std::string application_t::get_diagnostic_bus() const -{ - return "can0"; -} - - |