summaryrefslogtreecommitdiffstats
path: root/examples/OBD2
diff options
context:
space:
mode:
Diffstat (limited to 'examples/OBD2')
-rw-r--r--examples/OBD2/application-generated.cpp274
-rw-r--r--examples/OBD2/signals.json158
2 files changed, 432 insertions, 0 deletions
diff --git a/examples/OBD2/application-generated.cpp b/examples/OBD2/application-generated.cpp
new file mode 100644
index 00000000..f66748b6
--- /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 00000000..89276298
--- /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"
+ }
+ ]
+}