aboutsummaryrefslogtreecommitdiffstats
path: root/src/openxc
diff options
context:
space:
mode:
Diffstat (limited to 'src/openxc')
-rwxr-xr-xsrc/openxc/can_message.cpp21
-rwxr-xr-xsrc/openxc/can_message.hpp9
-rwxr-xr-xsrc/openxc/signal.cpp96
-rwxr-xr-xsrc/openxc/signal.hpp13
4 files changed, 118 insertions, 21 deletions
diff --git a/src/openxc/can_message.cpp b/src/openxc/can_message.cpp
index 77418d8..858540c 100755
--- a/src/openxc/can_message.cpp
+++ b/src/openxc/can_message.cpp
@@ -27,6 +27,16 @@ namespace openxc
return is_fd_;
}
+ 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_;
@@ -72,10 +82,16 @@ namespace openxc
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_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 +100,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"];
@@ -108,6 +125,7 @@ namespace openxc
nlohmann::json j;
j["bus"] = bus_;
j["is_fd"] = is_fd_;
+ j["is_j1939"] = is_j1939_;
j["bit_numbering_inverted"] = bit_numbering_inverted_;
j["signals"] = signals_;
j["name"] = name_;
@@ -117,6 +135,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;
}
diff --git a/src/openxc/can_message.hpp b/src/openxc/can_message.hpp
index f2d1b6e..3d92b18 100755
--- a/src/openxc/can_message.hpp
+++ b/src/openxc/can_message.hpp
@@ -22,13 +22,19 @@ namespace openxc
float max_signal_frequency_;
bool force_send_changed_;
bool force_send_changed_signals_;
- bool is_fd_;
+ bool is_fd_;
+ 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_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,6 +45,7 @@ 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;
diff --git a/src/openxc/signal.cpp b/src/openxc/signal.cpp
index e9c1088..1bcd869 100755
--- a/src/openxc/signal.cpp
+++ b/src/openxc/signal.cpp
@@ -6,84 +6,100 @@ namespace openxc
{
return id_;
}
-
+
void signal::id(const std::string& id)
{
id_ = id;
}
-
+
void id(const std::string& id);
-
+
std::string signal::generic_name() const
{
return generic_name_;
}
-
+
std::uint32_t signal::bit_position() const
{
return bit_position_;
}
-
+
std::uint32_t signal::bit_size() const
{
return bit_size_;
}
-
+
float signal::factor() const
{
return factor_;
}
-
+
float signal::offset() const
{
return offset_;
}
-
+
std::string signal::decoder() const
{
return decoder_;
}
-
+
bool signal::ignore() const
{
return ignore_;
}
-
+
bool signal::enabled() const
{
return enabled_;
}
-
+
const std::map<std::string, std::vector<std::uint32_t>>& signal::states() const
{
return states_;
}
-
+
float signal::max_frequency() const
{
return max_frequency_;
}
-
+
bool signal::send_same() const
{
return send_same_;
}
-
+
bool signal::force_send_changed() const
{
return force_send_changed_;
}
-
+
bool signal::writable() const
{
return writable_;
}
-
+
std::string signal::encoder() const
{
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)
{
generic_name_ = j.count("generic_name") ? j["generic_name"].get<std::string>() : "";
@@ -99,6 +115,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 +166,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;
};