From 9a441dad97539ec696d33eabb8ac36c222790e7f Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Wed, 28 Nov 2018 13:49:08 +0100 Subject: Adds CAN FD flag on message object. 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 --- src/main.cpp | 1 + src/openxc/can_message.cpp | 12 ++++++++++++ src/openxc/can_message.hpp | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 0929d8f..0608f16 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -173,6 +173,7 @@ std::ostream& operator<<(std::ostream& o, const generator& << "{std::make_shared(can_message_definition_t{" << gen(v.v_.bus()) << "," << v.v_.id() << "," + << v.v_.is_fd() << "," << "can_message_format_t::STANDARD," << "frequency_clock_t(" << gen(v.v_.max_frequency()) << ")," << gen(v.v_.force_send_changed()) << ",\n"; diff --git a/src/openxc/can_message.cpp b/src/openxc/can_message.cpp index 40e897b..77418d8 100755 --- a/src/openxc/can_message.cpp +++ b/src/openxc/can_message.cpp @@ -17,6 +17,16 @@ namespace openxc return bus_; } + void can_message::is_fd(const bool is_fd) + { + is_fd_ = is_fd; + } + + bool can_message::is_fd() const + { + return is_fd_; + } + bool can_message::bit_numbering_inverted() const { return bit_numbering_inverted_; @@ -65,6 +75,7 @@ namespace openxc void can_message::from_json(const nlohmann::json& j) { bus_ = j.count("bus") ? j["bus"].get() : ""; + is_fd_ = j.count("is_fd") ? j["is_fd"].get() : false; bit_numbering_inverted_ = j.count("bit_numbering_inverted") ? j["bit_numbering_inverted"].get() : false; name_ = j.count("name") ? j["name"].get() : ""; handlers_ = j.count("handlers") ? j["handlers"].get>() : std::vector(); @@ -96,6 +107,7 @@ namespace openxc { nlohmann::json j; j["bus"] = bus_; + j["is_fd"] = is_fd_; j["bit_numbering_inverted"] = bit_numbering_inverted_; j["signals"] = signals_; j["name"] = name_; diff --git a/src/openxc/can_message.hpp b/src/openxc/can_message.hpp index 3f7b018..f2d1b6e 100755 --- a/src/openxc/can_message.hpp +++ b/src/openxc/can_message.hpp @@ -22,10 +22,13 @@ namespace openxc float max_signal_frequency_; bool force_send_changed_; bool force_send_changed_signals_; + bool is_fd_; public: std::string id() const; void id(const std::string& id); + void is_fd(const bool is_fd); + bool is_fd() const; std::string bus() const; bool bit_numbering_inverted() const; const std::vector& signals() const; -- cgit 1.2.3-korg