Adds CAN FD flag on message object. 59/18659/3
authorRomain Forlot <romain.forlot@iot.bzh>
Wed, 28 Nov 2018 12:49:08 +0000 (13:49 +0100)
committerRomain Forlot <romain.forlot@iot.bzh>
Tue, 11 Dec 2018 10:25:38 +0000 (10:25 +0000)
Adds CAN FD flag on message object when generating CPP file for the
low-can service. So with this commit you are now able to use a new flags
in your JSON CAN message definitions. This will imply that messages
received from a certain CAN ID will be handled as CAN FD.

Bug-AGL: SPEC-1980

Change-Id: Ia5fb573711742591c068928aee914ba708c802df
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
src/main.cpp
src/openxc/can_message.cpp
src/openxc/can_message.hpp

index 0929d8f..0608f16 100644 (file)
@@ -173,6 +173,7 @@ std::ostream& operator<<(std::ostream& o, const generator<openxc::can_message>&
                << "{std::make_shared<can_message_definition_t>(can_message_definition_t{"\r
                << gen(v.v_.bus()) << ","\r
                << v.v_.id() << ","\r
+               << v.v_.is_fd() << ","\r
                << "can_message_format_t::STANDARD,"\r
                << "frequency_clock_t(" << gen(v.v_.max_frequency()) << "),"\r
                << gen(v.v_.force_send_changed()) << ",\n";\r
index 40e897b..77418d8 100755 (executable)
@@ -17,6 +17,16 @@ namespace openxc
                return bus_;\r
        }\r
        \r
+       void can_message::is_fd(const bool is_fd)\r
+       {\r
+               is_fd_ = is_fd;\r
+       }\r
+\r
+       bool can_message::is_fd() const\r
+       {\r
+               return is_fd_;\r
+       }\r
+\r
        bool can_message::bit_numbering_inverted() const\r
        {\r
                return bit_numbering_inverted_;\r
@@ -65,6 +75,7 @@ namespace openxc
        void can_message::from_json(const nlohmann::json& j)\r
        {\r
                bus_ = j.count("bus") ? j["bus"].get<std::string>() : "";\r
+               is_fd_ = j.count("is_fd") ? j["is_fd"].get<bool>() : false;\r
                bit_numbering_inverted_ = j.count("bit_numbering_inverted") ? j["bit_numbering_inverted"].get<bool>() : false;\r
                name_ = j.count("name") ? j["name"].get<std::string>() : "";\r
                handlers_ = j.count("handlers") ? j["handlers"].get<std::vector<std::string>>() : std::vector<std::string>();\r
@@ -96,6 +107,7 @@ namespace openxc
        {\r
                nlohmann::json j;\r
                j["bus"] = bus_;\r
+               j["is_fd"] = is_fd_;\r
                j["bit_numbering_inverted"] = bit_numbering_inverted_;\r
                j["signals"] = signals_;\r
                j["name"] = name_;\r
index 3f7b018..f2d1b6e 100755 (executable)
@@ -22,10 +22,13 @@ namespace openxc
                float                                                   max_signal_frequency_;\r
                bool                                                    force_send_changed_;\r
                bool                                                    force_send_changed_signals_;\r
+               bool                            is_fd_;\r
 \r
        public:\r
                std::string id() const;\r
                void id(const std::string& id);\r
+               void is_fd(const bool is_fd);\r
+               bool is_fd() const;\r
                std::string     bus() const;\r
                bool bit_numbering_inverted() const;\r
                const std::vector<signal>& signals() const;\r