summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-26 16:07:13 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2019-11-26 16:07:13 +0100
commit839bbf458685383634c03e8cec2238f70c6f0382 (patch)
tree4241b584cbc6ce57a6d0683645f4357295eb1d0f
parenta34022eba3e81e2f1dcce398b88eeb7d17cf8280 (diff)
Change enum type to flag and add iso tp protocol
This commits changes all enum types to flag. And adds management of iso tp protocol. Bug-AGL: SPEC-2779 Bug-AGL: SPEC-2976 Change-Id: I84cb315a99b1b1913fd1bdb24ef388fa391dc742 Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--src/main.cpp52
-rwxr-xr-xsrc/openxc/can_message.cpp14
-rwxr-xr-xsrc/openxc/can_message.hpp3
3 files changed, 59 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 9961105..b35f9e3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -33,6 +33,20 @@
#define EXIT_COMMAND_LINE_ERROR 2
#define EXIT_PROGRAM_ERROR 3
+
+/**
+ * FLAGS
+ */
+
+#define INVALID_FLAG 0x0001
+#define STANDARD_ID 0x0002
+#define EXTENDED_ID 0x0004
+#define BCM_PROTOCOL 0x0008
+#define J1939_PROTOCOL 0x0010
+#define J1939_ADDR_CLAIM_PROTOCOL 0x0020
+#define ISOTP_PROTOCOL 0x0040
+#define FD_FRAME 0x0800
+
template <typename T>
struct generator
{
@@ -185,18 +199,40 @@ std::ostream& operator<<(std::ostream& o, const generator<openxc::can_message>&
<< gen(v.v_.bus()) << ","
<< v.v_.id() << ","
<< "\"" << v.v_.name() << "\","
- << v.v_.length() << ","
- << gen(v.v_.is_fd()) << ",";
- if(v.v_.is_j1939()){
- o << "message_format_t::J1939,";
+ << v.v_.length() << ",";
+ uint32_t flags = 0;
+ if(v.v_.is_fd())
+ {
+ flags = flags|FD_FRAME;
}
- else if(v.v_.is_extended())
+
+ if(v.v_.is_j1939())
{
- o << "message_format_t::EXTENDED,";
+ flags = flags|J1939_PROTOCOL;
}
- else{
- o << "message_format_t::STANDARD,";
+
+ if(v.v_.is_isotp())
+ {
+ flags = flags|ISOTP_PROTOCOL;
}
+
+ if(v.v_.is_extended())
+ {
+ flags = flags|EXTENDED_ID;
+ }
+ else
+ {
+ flags = flags|STANDARD_ID;
+ }
+
+
+ if(v.v_.is_fd())
+ {
+ flags = flags|FD_FRAME;
+ }
+
+ o << gen(flags) << ",";
+
o << "frequency_clock_t(" << gen(v.v_.max_frequency()) << "),"
<< gen(v.v_.force_send_changed()) << ",";
std::uint32_t index = 0;
diff --git a/src/openxc/can_message.cpp b/src/openxc/can_message.cpp
index 70b98a7..700896a 100755
--- a/src/openxc/can_message.cpp
+++ b/src/openxc/can_message.cpp
@@ -46,6 +46,16 @@ namespace openxc
return is_j1939_;
}
+ void can_message::is_isotp(const bool is_isotp)
+ {
+ is_isotp_ = is_isotp;
+ }
+
+ bool can_message::is_isotp() const
+ {
+ return is_isotp_;
+ }
+
bool can_message::bit_numbering_inverted() const
{
return bit_numbering_inverted_;
@@ -102,6 +112,7 @@ namespace openxc
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;
+ is_isotp_ = j.count("is_isotp") ? j["is_isotp"].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>();
@@ -135,10 +146,9 @@ namespace openxc
nlohmann::json j;
j["bus"] = bus_;
j["is_fd"] = is_fd_;
-
j["is_extended"] = is_extended_;
-
j["is_j1939"] = is_j1939_;
+ j["is_isotp"] = is_isotp_;
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 98b38a5..555b47d 100755
--- a/src/openxc/can_message.hpp
+++ b/src/openxc/can_message.hpp
@@ -25,6 +25,7 @@ namespace openxc
bool is_fd_;
bool is_extended_;
bool is_j1939_;
+ bool is_isotp_;
uint32_t length_;
float min_value;
float max_value;
@@ -38,6 +39,8 @@ namespace openxc
bool is_extended() const;
void is_j1939(const bool is_j1939);
bool is_j1939() const;
+ void is_isotp(const bool is_isotp);
+ bool is_isotp() const;
std::string bus() const;
bool bit_numbering_inverted() const;
const std::vector<signal>& signals() const;