aboutsummaryrefslogtreecommitdiffstats
path: root/src/openxc
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2020-09-23 16:07:53 -0400
committerScott Murray <scott.murray@konsulko.com>2020-09-23 16:25:30 -0400
commit0a3e354c3d81866e1a755367ab5592b3ced868bb (patch)
tree792c3af82a316af6c4dee98722548112cb843892 /src/openxc
parentd9c40fd96e31ce41166e2b846301335ed6fe5d37 (diff)
Update to match current binding expectationssandbox/walzert/low-level-can-generator
Changes: - Reworked header, footer, message structure definition, etc. to match the contents of the current generated files in the binding. - To enable the above, added some code to derive the API name for the app controller CAPI macro from the name given for the message set in the JSON. The name is lower-cased and spaces converted to dashes, this matches all the examples in the generated files in the binding. - Added logic to default message length to 8 if not set in JSON, this is required to match explicit checks and signal JSON changes in the binding. - Replaced is_bigendian and is_signed fields with new sign and bit_sign_position fields in JSON parsing and generated signal output. The sign field value enum has been copied from the binding to provide a reference for the values. - Update per-signal flags generation, to enable this updated flag #defines from binding's current can-message.hpp. Added a comment to document which flags are known to be used. - Removed "package" from "all" target in Makefile, as it is attached to widget packaging rules that are not applicable for the generator, which is built for host or toolchain usage. - Removed unused src/main.hpp header to avoid confusion. Bug-AGL: SPEC-3551 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I9ef3df0ebcfbddc23c789b50e1575fc42031970d
Diffstat (limited to 'src/openxc')
-rwxr-xr-xsrc/openxc/signal.cpp23
-rwxr-xr-xsrc/openxc/signal.hpp25
2 files changed, 28 insertions, 20 deletions
diff --git a/src/openxc/signal.cpp b/src/openxc/signal.cpp
index e60c3ee..858f64b 100755
--- a/src/openxc/signal.cpp
+++ b/src/openxc/signal.cpp
@@ -88,12 +88,14 @@ namespace openxc
return multiplex_;
}
- bool signal::is_big_endian() const{
- return is_big_endian_;
+ sign_t signal::sign() const
+ {
+ return sign_;
}
- bool signal::is_signed() const{
- return is_signed_;
+ std::int32_t signal::bit_sign_position() const
+ {
+ return bit_sign_position_;
}
std::string signal::unit() const{
@@ -134,11 +136,10 @@ namespace openxc
{
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>() : "";
-
+ bit_sign_position_ = j.count("bit_sign_position") ? j["bit_sign_position"].get<std::int32_t>() : -1;
+ sign_ = j.count("signed") ? (sign_t) j["signed"].get<std::uint32_t>() : sign_t::UNSIGNED;
+ unit_ = j.count("unit") ? j["unit"].get<std::string>() : "";
if (j.count("states"))
{
@@ -185,10 +186,8 @@ namespace openxc
j["multiplex"] = multi;
-
-
- j["is_big_endian"] = is_big_endian_;
- j["is_signed"] = is_signed_;
+ j["bit_sign_position"] = bit_sign_position_;
+ j["signed"] = static_cast<std::uint32_t>(sign_);
j["unit"] = unit_;
return j;
}
diff --git a/src/openxc/signal.hpp b/src/openxc/signal.hpp
index 750926b..ce0a2e1 100755
--- a/src/openxc/signal.hpp
+++ b/src/openxc/signal.hpp
@@ -8,27 +8,36 @@
namespace openxc
{
+ enum sign_t
+ {
+ UNSIGNED = 0,
+ SIGN_BIT = 1,
+ ONES_COMPLEMENT = 2,
+ TWOS_COMPLEMENT = 3,
+ SIGN_BIT_EXTERN = 4
+ };
+
class signal
{
private:
std::string id_;
std::string generic_name_;
- std::uint32_t bit_position_;
- std::uint32_t bit_size_;
+ std::uint32_t bit_position_;
+ std::uint32_t bit_size_;
float factor_;
float offset_;
std::string decoder_;
bool ignore_;
bool enabled_;
- std::map<std::string, std::vector<std::uint32_t>> states_;
+ std::map<std::string, std::vector<std::uint32_t>> states_;
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::pair<bool,int> multiplex_;
+ sign_t sign_;
+ std::int32_t bit_sign_position_;
std::string unit_;
public:
@@ -49,8 +58,8 @@ namespace openxc
bool writable() const;
std::string encoder() const;
std::pair<bool,int> multiplex() const;
- bool is_big_endian() const;
- bool is_signed() const;
+ sign_t sign() const;
+ std::int32_t bit_sign_position() const;
std::string unit() const;
void from_json(const nlohmann::json& j);