Also initialize the id_ renamed address_ member. This member
authorRomain Forlot <romain.forlot@iot.bzh>
Fri, 10 Mar 2017 14:14:05 +0000 (15:14 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 16 Mar 2017 16:10:40 +0000 (17:10 +0100)
is mapped to the address node from json

Change-Id: Ied13067723552c2396337a9f85fe5e1418ba8caf
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
src/can/can-bus-dev.cpp
src/can/can-bus-dev.hpp
src/can/can-bus.cpp

index 32a8906..3aafff3 100644 (file)
 
 /// @brief Class constructor
 /// @param dev_name String representing the device name into the linux /dev tree
-can_bus_dev_t::can_bus_dev_t(const std::string& dev_name)
-       : device_name_{dev_name}
-{
-}
+can_bus_dev_t::can_bus_dev_t(const std::string& dev_name, int32_t address)
+       : device_name_{dev_name}, address_{address}
+{}
 
 std::string can_bus_dev_t::get_device_name() const
 {
index 5907c58..affcb34 100644 (file)
@@ -36,7 +36,7 @@ private:
        std::string device_name_;
        utils::socket_t can_socket_;
 
-       int32_t id_; /// < an identifier used through binding that refer to that device
+       int32_t address_; /// < an identifier used through binding that refer to that device
 
        bool is_fdmode_on_; /// < boolean telling if whether or not the can socket use fdmode.
        struct sockaddr_can txAddress_; /// < internal member using to bind to the socket
@@ -46,7 +46,7 @@ private:
        void can_reader(can_bus_t& can_bus);
 
 public:
-       can_bus_dev_t(const std::string& dev_name);
+       can_bus_dev_t(const std::string& dev_name, int32_t address);
 
        std::string get_device_name() const;
 
index 93de2a3..4ddf6c8 100644 (file)
@@ -186,7 +186,7 @@ int can_bus_t::init_can_dev()
 
                for(const auto& device : devices_name)
                {
-                       can_devices_m_[device] = std::make_shared<can_bus_dev_t>(device);
+                       can_devices_m_[device] = std::make_shared<can_bus_dev_t>(device, i);
                        if (can_devices_m_[device]->open() == 0)
                        {
                                i++;