aboutsummaryrefslogtreecommitdiffstats
path: root/src/openxc
diff options
context:
space:
mode:
Diffstat (limited to 'src/openxc')
-rwxr-xr-xsrc/openxc/can_message.cpp64
-rwxr-xr-xsrc/openxc/can_message.hpp16
-rwxr-xr-xsrc/openxc/signal.cpp63
-rwxr-xr-xsrc/openxc/signal.hpp13
4 files changed, 135 insertions, 21 deletions
diff --git a/src/openxc/can_message.cpp b/src/openxc/can_message.cpp
index 77418d8..70b98a7 100755
--- a/src/openxc/can_message.cpp
+++ b/src/openxc/can_message.cpp
@@ -6,17 +6,17 @@ namespace openxc
{
return id_;
}
-
+
void can_message::id(const std::string& id)
{
id_ = id;
}
-
+
std::string can_message::bus() const
{
return bus_;
}
-
+
void can_message::is_fd(const bool is_fd)
{
is_fd_ = is_fd;
@@ -26,56 +26,82 @@ namespace openxc
{
return is_fd_;
}
+ void can_message::is_extended(const bool is_extended)
+ {
+ is_extended_ = is_extended;
+ }
+
+ bool can_message::is_extended() const
+ {
+ return is_extended_;
+ }
+
+ void can_message::is_j1939(const bool is_j1939)
+ {
+ is_j1939_ = is_j1939;
+ }
+
+ bool can_message::is_j1939() const
+ {
+ return is_j1939_;
+ }
bool can_message::bit_numbering_inverted() const
{
return bit_numbering_inverted_;
}
-
+
const std::vector<signal>& can_message::signals() const
{
return signals_;
}
-
+
std::string can_message::name() const
{
return name_;
}
-
+
std::vector<std::string> can_message::handlers() const
{
return handlers_;
}
-
+
bool can_message::enabled() const
{
return enabled_;
}
-
+
float can_message::max_frequency() const
{
return max_frequency_;
}
-
+
float can_message::max_signal_frequency() const
{
return max_signal_frequency_;
}
-
+
bool can_message::force_send_changed() const
{
return force_send_changed_;
}
-
+
bool can_message::force_send_changed_signals() const
{
return force_send_changed_;
}
-
+
+ uint32_t can_message::length() const
+ {
+ return length_;
+ }
+
void can_message::from_json(const nlohmann::json& j)
{
bus_ = j.count("bus") ? j["bus"].get<std::string>() : "";
is_fd_ = j.count("is_fd") ? j["is_fd"].get<bool>() : false;
+ is_extended_ = j.count("is_extended") ? j["is_extended"].get<bool>() : false;
+ is_j1939_ = j.count("is_j1939") ? j["is_j1939"].get<bool>() : false;
bit_numbering_inverted_ = j.count("bit_numbering_inverted") ? j["bit_numbering_inverted"].get<bool>() : false;
name_ = j.count("name") ? j["name"].get<std::string>() : "";
handlers_ = j.count("handlers") ? j["handlers"].get<std::vector<std::string>>() : std::vector<std::string>();
@@ -84,7 +110,8 @@ namespace openxc
max_signal_frequency_ = j.count("max_signal_frequency") ? j["max_signal_frequency"].get<float>() : 5;
force_send_changed_ = j.count("force_send_changed") ? j["force_send_changed"].get<bool>() : true;
force_send_changed_signals_ = j.count("force_send_changed_signals") ? j["force_send_changed_signals"].get<bool>() : false;
-
+ length_ = j.count("length") ? j["length"].get<uint32_t>() : 0;
+
if(j.count("signals"))
{
std::map<std::string, nlohmann::json> signals = j["signals"];
@@ -95,9 +122,9 @@ namespace openxc
signals_.push_back(sig);
}
}
-
+
}
-
+
std::uint32_t can_message::get_signals_count() const
{
return (uint32_t)signals_.size();
@@ -108,6 +135,10 @@ namespace openxc
nlohmann::json j;
j["bus"] = bus_;
j["is_fd"] = is_fd_;
+
+ j["is_extended"] = is_extended_;
+
+ j["is_j1939"] = is_j1939_;
j["bit_numbering_inverted"] = bit_numbering_inverted_;
j["signals"] = signals_;
j["name"] = name_;
@@ -117,6 +148,7 @@ namespace openxc
j["max_signal_frequency"] = max_signal_frequency_;
j["force_send_changed"] = force_send_changed_;
j["force_send_changed_signals"] = force_send_changed_signals_;
+ j["length"] = length_;
return j;
}
@@ -124,7 +156,7 @@ namespace openxc
{
j = p.to_json();
}
-
+
void from_json(const nlohmann::json& j, can_message& p)
{
p.from_json(j);
diff --git a/src/openxc/can_message.hpp b/src/openxc/can_message.hpp
index f2d1b6e..98b38a5 100755
--- a/src/openxc/can_message.hpp
+++ b/src/openxc/can_message.hpp
@@ -22,13 +22,22 @@ namespace openxc
float max_signal_frequency_;
bool force_send_changed_;
bool force_send_changed_signals_;
- bool is_fd_;
+ bool is_fd_;
+ bool is_extended_;
+ bool is_j1939_;
+ uint32_t length_;
+ float min_value;
+ float max_value;
public:
std::string id() const;
void id(const std::string& id);
void is_fd(const bool is_fd);
bool is_fd() const;
+ void is_extended(const bool is_extended);
+ bool is_extended() const;
+ void is_j1939(const bool is_j1939);
+ bool is_j1939() const;
std::string bus() const;
bool bit_numbering_inverted() const;
const std::vector<signal>& signals() const;
@@ -39,10 +48,11 @@ namespace openxc
float max_signal_frequency() const;
bool force_send_changed() const;
bool force_send_changed_signals() const;
-
+ uint32_t length() const;
+
void from_json(const nlohmann::json& j);
nlohmann::json to_json() const;
-
+
std::uint32_t get_signals_count() const;
};
diff --git a/src/openxc/signal.cpp b/src/openxc/signal.cpp
index e9c1088..e60c3ee 100755
--- a/src/openxc/signal.cpp
+++ b/src/openxc/signal.cpp
@@ -83,6 +83,23 @@ namespace openxc
{
return encoder_;
}
+
+ std::pair<bool,int> signal::multiplex() const{
+ return multiplex_;
+ }
+
+ bool signal::is_big_endian() const{
+ return is_big_endian_;
+ }
+
+ bool signal::is_signed() const{
+ return is_signed_;
+ }
+
+ std::string signal::unit() const{
+ return unit_;
+ }
+
void signal::from_json(const nlohmann::json& j)
{
@@ -99,6 +116,29 @@ namespace openxc
force_send_changed_ = j.count("force_send_changed") ? j["force_send_changed"].get<bool>() : false;
writable_ = j.count("writable") ? j["writable"].get<bool>() : false;
encoder_ = j.count("encoder") ? j["encoder"].get<std::string>() : "";
+ if(j.count("multiplex"))
+ {
+ std::string mult = j["multiplex"].get<std::string>();
+ bool first = false;
+ int second = 0 ;
+ if(mult.compare("Multiplexor") == 0){
+ first = true;
+ }
+ else if (mult.compare("") != 0)
+ {
+ second = std::stoi(mult);
+ }
+ multiplex_ = std::make_pair(first,second);
+ }
+ else
+ {
+ multiplex_ = std::make_pair(false,0);
+ }
+ is_big_endian_ = j.count("is_big_endian") ? j["is_big_endian"].get<bool>() : false;
+ is_signed_ = j.count("is_signed") ? j["is_signed"].get<bool>() : false;
+ unit_ = j.count("unit") ? j["unit"].get<std::string>() : "";
+
+
if (j.count("states"))
{
@@ -127,6 +167,29 @@ namespace openxc
j["force_send_changed"] = force_send_changed_;
j["writable"] = writable_;
j["encoder"] = encoder_;
+
+ std::string multi = "";
+
+ if(multiplex_.first)
+ {
+ multi = "Multiplexor";
+ }
+ else if(multiplex_.second != 0)
+ {
+ multi = std::to_string(multiplex_.second);
+ }
+ else
+ {
+ multi = "";
+ }
+
+ j["multiplex"] = multi;
+
+
+
+ j["is_big_endian"] = is_big_endian_;
+ j["is_signed"] = is_signed_;
+ j["unit"] = unit_;
return j;
}
diff --git a/src/openxc/signal.hpp b/src/openxc/signal.hpp
index e0124c3..750926b 100755
--- a/src/openxc/signal.hpp
+++ b/src/openxc/signal.hpp
@@ -21,11 +21,16 @@ namespace openxc
bool ignore_;
bool enabled_;
std::map<std::string, std::vector<std::uint32_t>> states_;
- float max_frequency_;
+ float max_frequency_;
bool send_same_;
bool force_send_changed_;
bool writable_;
std::string encoder_;
+ std::pair<bool,int> multiplex_;
+ bool is_big_endian_;
+ bool is_signed_;
+ std::string unit_;
+
public:
std::string id() const;
void id(const std::string& id);
@@ -43,7 +48,11 @@ namespace openxc
bool force_send_changed() const;
bool writable() const;
std::string encoder() const;
-
+ std::pair<bool,int> multiplex() const;
+ bool is_big_endian() const;
+ bool is_signed() const;
+ std::string unit() const;
+
void from_json(const nlohmann::json& j);
nlohmann::json to_json() const;
};