aboutsummaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-22 10:28:38 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-05-22 10:28:38 +0200
commite78758eab6b6582af0d1a86f3a56012499fb2308 (patch)
treef213c9e3518698459e7b0c654d45e2cdaa2c8f8c /CAN-binder/low-can-binding
parenta3d0e020d00c4b213a688ba29ef27d994b6245ac (diff)
Logical bus name mapped to device name using conf file.
Store CAN device map without prefixed section name and add methods to get the mapped device name. Change-Id: I03ebc175c67b2251016863b0d69a45a816a81d25 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding')
-rw-r--r--CAN-binder/low-can-binding/binding/configuration-generated.cpp10
-rw-r--r--CAN-binder/low-can-binding/can/can-message-definition.cpp8
-rw-r--r--CAN-binder/low-can-binding/can/can-message-definition.hpp1
-rw-r--r--CAN-binder/low-can-binding/can/can-signals.cpp2
-rw-r--r--CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp12
-rw-r--r--CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp3
-rw-r--r--CAN-binder/low-can-binding/utils/openxc-utils.cpp2
7 files changed, 27 insertions, 11 deletions
diff --git a/CAN-binder/low-can-binding/binding/configuration-generated.cpp b/CAN-binder/low-can-binding/binding/configuration-generated.cpp
index bce469e5..2939fc8b 100644
--- a/CAN-binder/low-can-binding/binding/configuration-generated.cpp
+++ b/CAN-binder/low-can-binding/binding/configuration-generated.cpp
@@ -6,7 +6,7 @@ configuration_t::configuration_t()
, 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{"can0",0x3D9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
+ {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",
@@ -64,7 +64,7 @@ configuration_t::configuration_t()
})}
} // end can_signals vector
})} // end can_message_definition entry
-, {std::make_shared<can_message_definition_t>(can_message_definition_t{"can0",0x3E9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
+, {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",
@@ -86,7 +86,7 @@ configuration_t::configuration_t()
})}
} // end can_signals vector
})} // end can_message_definition entry
-, {std::make_shared<can_message_definition_t>(can_message_definition_t{"can0",0x4D1,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
+, {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",
@@ -126,7 +126,7 @@ configuration_t::configuration_t()
})}
} // end can_signals vector
})} // end can_message_definition entry
-, {std::make_shared<can_message_definition_t>(can_message_definition_t{"can0",0x620,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
+, {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",
@@ -480,7 +480,7 @@ configuration_t::configuration_t()
const std::string configuration_t::get_diagnostic_bus() const
{
- return "can0";
+ return "hs";
}
diff --git a/CAN-binder/low-can-binding/can/can-message-definition.cpp b/CAN-binder/low-can-binding/can/can-message-definition.cpp
index ec6292af..e0f55a6d 100644
--- a/CAN-binder/low-can-binding/can/can-message-definition.cpp
+++ b/CAN-binder/low-can-binding/can/can-message-definition.cpp
@@ -17,6 +17,8 @@
#include "can-message-definition.hpp"
+#include "../binding/configuration.hpp"
+
can_message_definition_t::can_message_definition_t(const std::string bus)
: parent_{nullptr}, bus_{bus}, last_value_{CAN_MESSAGE_SIZE}
{}
@@ -71,6 +73,12 @@ const std::string can_message_definition_t::get_bus_name() const
return bus_;
}
+const std::string can_message_definition_t::get_bus_device_name() const
+{
+ return configuration_t::instance().get_can_bus_manager()
+ .get_can_device_name(bus_);
+}
+
uint32_t can_message_definition_t::get_id() const
{
return id_;
diff --git a/CAN-binder/low-can-binding/can/can-message-definition.hpp b/CAN-binder/low-can-binding/can/can-message-definition.hpp
index 233d8ce8..3e150369 100644
--- a/CAN-binder/low-can-binding/can/can-message-definition.hpp
+++ b/CAN-binder/low-can-binding/can/can-message-definition.hpp
@@ -60,6 +60,7 @@ public:
can_message_definition_t(const std::string bus, uint32_t id, can_message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed, const std::vector<std::shared_ptr<can_signal_t> >& can_signals);
const std::string get_bus_name() const;
+ const std::string get_bus_device_name() const;
uint32_t get_id() const;
std::vector<std::shared_ptr<can_signal_t> >& get_can_signals();
diff --git a/CAN-binder/low-can-binding/can/can-signals.cpp b/CAN-binder/low-can-binding/can/can-signals.cpp
index 9a876136..e49c7274 100644
--- a/CAN-binder/low-can-binding/can/can-signals.cpp
+++ b/CAN-binder/low-can-binding/can/can-signals.cpp
@@ -228,7 +228,7 @@ int can_signal_t::create_rx_filter()
// Make sure that socket has been opened.
if(! socket_)
socket_.open(
- get_message()->get_bus_name());
+ get_message()->get_bus_device_name());
uint32_t can_id = get_message()->get_id();
diff --git a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp
index 1a382af9..199054b5 100644
--- a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp
+++ b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.cpp
@@ -86,7 +86,7 @@ int diagnostic_manager_t::add_rx_filter(uint32_t can_id)
{
// Make sure that socket has been opened.
if(! socket_)
- socket_.open(bus_);
+ socket_.open(get_bus_device_name());
struct utils::simple_bcm_msg bcm_msg;
memset(&bcm_msg.msg_head, 0, sizeof(bcm_msg.msg_head));
@@ -142,7 +142,7 @@ bool diagnostic_manager_t::shims_send(const uint32_t arbitration_id, const uint8
// Make sure that socket has been opened.
if(! tx_socket)
tx_socket.open(
- dm.get_can_bus());
+ dm.get_bus_device_name());
struct utils::simple_bcm_msg bcm_msg;
struct can_frame cfd;
@@ -191,11 +191,17 @@ void diagnostic_manager_t::shims_logger(const char* format, ...)
void diagnostic_manager_t::shims_timer()
{}
-std::string diagnostic_manager_t::get_can_bus()
+const std::string diagnostic_manager_t::get_bus_name() const
{
return bus_;
}
+const std::string diagnostic_manager_t::get_bus_device_name() const
+{
+ return configuration_t::instance().get_can_bus_manager()
+ .get_can_device_name(bus_);
+}
+
active_diagnostic_request_t* diagnostic_manager_t::get_last_recurring_requests() const
{
return recurring_requests_.back();
diff --git a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp
index 894cf630..9f19b016 100644
--- a/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp
+++ b/CAN-binder/low-can-binding/diagnostic/diagnostic-manager.hpp
@@ -67,7 +67,8 @@ public:
bool initialize();
utils::socketcan_bcm_t& get_socket();
- std::string get_can_bus();
+ const std::string get_bus_name() const;
+ const std::string get_bus_device_name() const;
active_diagnostic_request_t* get_last_recurring_requests() const;
DiagnosticShims& get_shims();
diff --git a/CAN-binder/low-can-binding/utils/openxc-utils.cpp b/CAN-binder/low-can-binding/utils/openxc-utils.cpp
index 286b2f53..5f065047 100644
--- a/CAN-binder/low-can-binding/utils/openxc-utils.cpp
+++ b/CAN-binder/low-can-binding/utils/openxc-utils.cpp
@@ -41,7 +41,7 @@ openxc_VehicleMessage build_VehicleMessage(active_diagnostic_request_t* request,
message.has_diagnostic_response = true;
message.diagnostic_response.has_bus = true;
message.diagnostic_response.bus = conf.get_can_bus_manager().get_can_device_index(
- conf.get_diagnostic_manager().get_can_bus());
+ conf.get_diagnostic_manager().get_bus_name());
message.diagnostic_response.has_message_id = true;
if(request->get_id() != OBD2_FUNCTIONAL_BROADCAST_ID)