aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--low-can-binding/can/message-definition.cpp8
-rw-r--r--low-can-binding/can/message-definition.hpp5
-rwxr-xr-xlow-can-binding/can/signals.cpp7
-rwxr-xr-xlow-can-binding/can/signals.hpp1
-rw-r--r--low-can-binding/utils/converter.cpp30
-rw-r--r--low-can-binding/utils/converter.hpp1
-rw-r--r--plugins/agl-signals.cpp12
7 files changed, 57 insertions, 7 deletions
diff --git a/low-can-binding/can/message-definition.cpp b/low-can-binding/can/message-definition.cpp
index 114307e5..80609827 100644
--- a/low-can-binding/can/message-definition.cpp
+++ b/low-can-binding/can/message-definition.cpp
@@ -23,6 +23,7 @@ message_definition_t::message_definition_t(
const std::string bus,
uint32_t id,
uint32_t flags,
+ bool frame_layout_is_little,
frequency_clock_t frequency_clock,
bool force_send_changed,
const vect_ptr_signal_t& signals)
@@ -30,6 +31,7 @@ message_definition_t::message_definition_t(
bus_{bus},
id_{id},
flags_{flags},
+ frame_layout_is_little_{frame_layout_is_little},
frequency_clock_{frequency_clock},
force_send_changed_{force_send_changed},
last_value_{CAN_MESSAGE_SIZE},
@@ -41,6 +43,7 @@ message_definition_t::message_definition_t(const std::string bus,
const std::string name,
uint32_t length,
uint32_t flags,
+ bool frame_layout_is_little,
frequency_clock_t frequency_clock,
bool force_send_changed,
const vect_ptr_signal_t& signals)
@@ -50,6 +53,7 @@ message_definition_t::message_definition_t(const std::string bus,
name_{name},
length_{length},
flags_{flags},
+ frame_layout_is_little_{frame_layout_is_little},
frequency_clock_{frequency_clock},
force_send_changed_{force_send_changed},
last_value_{CAN_MESSAGE_SIZE},
@@ -112,3 +116,7 @@ uint32_t message_definition_t::get_flags() const
{
return flags_;
}
+
+bool message_definition_t::frame_layout_is_little() const{
+ return frame_layout_is_little_;
+}
diff --git a/low-can-binding/can/message-definition.hpp b/low-can-binding/can/message-definition.hpp
index ca264b7e..9d615ff0 100644
--- a/low-can-binding/can/message-definition.hpp
+++ b/low-can-binding/can/message-definition.hpp
@@ -49,6 +49,8 @@ private:
frequency_clock_t frequency_clock_; ///< clock_ - an optional frequency clock to control the output of this
/// message, if sent raw, or simply to mark the max frequency for custom
/// handlers to retrieve.*/
+ bool frame_layout_is_little_; ///<frame_layout_is_little_ Defines if the can frame layout is little endian or big endian.
+ /// Default is true;
bool force_send_changed_; ///< force_send_changed_ - If true, regardless of the frequency, it will send CAN
/// message if it has changed when using raw passthrough.*/
std::vector<uint8_t> last_value_; ///< last_value_ - The last received value of the message. Defaults to undefined.
@@ -64,6 +66,7 @@ public:
message_definition_t(const std::string bus,
uint32_t id,
uint32_t flags,
+ bool frame_layout_is_little,
frequency_clock_t frequency_clock,
bool force_send_changed,
const vect_ptr_signal_t& signals);
@@ -72,6 +75,7 @@ public:
std::string name,
uint32_t length,
uint32_t flags,
+ bool frame_layout_is_little,
frequency_clock_t frequency_clock,
bool force_send_changed,
const vect_ptr_signal_t& signals);
@@ -87,6 +91,7 @@ public:
vect_ptr_signal_t& get_signals();
uint32_t get_length() const;
uint32_t get_flags() const;
+ bool frame_layout_is_little() const;
void set_parent(std::shared_ptr<message_set_t> parent);
void set_last_value(std::shared_ptr<message_t> m);
diff --git a/low-can-binding/can/signals.cpp b/low-can-binding/can/signals.cpp
index 57aefa55..2b87dc6f 100755
--- a/low-can-binding/can/signals.cpp
+++ b/low-can-binding/can/signals.cpp
@@ -220,7 +220,12 @@ void signal_t::set_timestamp(uint64_t timestamp)
frequency_.tick(timestamp);
}
-std::pair<bool, int> signal_t::get_multiplex() const
+void signal_t::set_bit_position(uint32_t bit_position)
+{
+ bit_position_=bit_position;
+}
+
+std::pair<bool,int> signal_t::get_multiplex() const
{
return multiplex_;
}
diff --git a/low-can-binding/can/signals.hpp b/low-can-binding/can/signals.hpp
index 32cd7606..d9453c50 100755
--- a/low-can-binding/can/signals.hpp
+++ b/low-can-binding/can/signals.hpp
@@ -171,4 +171,5 @@ public:
void set_received(bool r);
void set_last_value(float val);
void set_timestamp(uint64_t timestamp);
+ void set_bit_position(uint32_t bit_position);
};
diff --git a/low-can-binding/utils/converter.cpp b/low-can-binding/utils/converter.cpp
index e3db7f33..f790fc00 100644
--- a/low-can-binding/utils/converter.cpp
+++ b/low-can-binding/utils/converter.cpp
@@ -55,3 +55,33 @@ void converter_t::signal_to_bits_bytes(uint32_t bit_position, uint32_t bit_size,
new_end_byte = (bit_position + bit_size - 1) >> 3;
new_end_bit = (bit_position + bit_size - 1) % 8;
}
+
+
+/**
+ * @brief This is to use when you have a big endian CAN frame layout.
+ * It converts the bit position so it matches with little endiant CAN frame layout.
+ *
+ * @param bit_position Original bit position.
+ * @param bit_size Size of the data.
+ * @return uint32_t New little endian bit position.
+ */
+uint32_t converter_t::bit_position_swap(uint32_t bit_position,uint32_t bit_size)
+{
+ uint32_t start_byte_position = (uint32_t)(bit_position/8);
+ uint32_t bit_size_rest = bit_size;
+ if(bit_size<=8 && ((bit_position+bit_size)%8==bit_size || (bit_position+bit_size)%8==0))
+ {
+ return (uint32_t)(start_byte_position*8 + (8-bit_size));
+ }
+ else
+ {
+ do
+ {
+ bit_size_rest = bit_size_rest - ((start_byte_position+1)*8-bit_position);
+ start_byte_position--;
+ bit_position = start_byte_position*8;
+ } while (bit_size_rest>8);
+ return (uint32_t)(start_byte_position*8 + (8-bit_size_rest));
+ }
+
+}
diff --git a/low-can-binding/utils/converter.hpp b/low-can-binding/utils/converter.hpp
index d24096a6..45233268 100644
--- a/low-can-binding/utils/converter.hpp
+++ b/low-can-binding/utils/converter.hpp
@@ -24,4 +24,5 @@ class converter_t
public:
static std::string to_hex(const uint8_t data[], const size_t length);
static void signal_to_bits_bytes(uint32_t bit_position, uint32_t bit_size, int &new_start_byte, int &new_end_byte, uint8_t &new_start_bit, uint8_t &new_end_bit);
+ static uint32_t bit_position_swap(uint32_t bit_position,uint32_t bit_size);
};
diff --git a/plugins/agl-signals.cpp b/plugins/agl-signals.cpp
index 28a8cce3..e02b61ff 100644
--- a/plugins/agl-signals.cpp
+++ b/plugins/agl-signals.cpp
@@ -12,7 +12,7 @@ CTLP_LUA_REGISTER("TO-EDIT");
std::shared_ptr<message_set_t> message_set =
std::make_shared<message_set_t>(message_set_t{0,"AGL Virtual Car",
{ // beginning message_definition_ vector
- {std::make_shared<message_definition_t>(message_definition_t{"ls", 0x30,"", 0, false, frequency_clock_t(5.00000f), true,
+ {std::make_shared<message_definition_t>(message_definition_t{"ls", 0x30,"", 0, 0 ,false, frequency_clock_t(5.00000f), true,
{ // beginning signals vector
{std::make_shared<signal_t> (signal_t{
"hvac.fan.speed",// generic_name
@@ -104,7 +104,7 @@ std::shared_ptr<message_set_t> message_set =
})}
} // end signals vector
})} // end message_definition entry
-, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x3D9,"", 0, true, frequency_clock_t(5.00000f), true,
+, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x3D9,"", 0, 0, true, frequency_clock_t(5.00000f), true,
{ // beginning signals vector
{std::make_shared<signal_t> (signal_t{
"engine.speed",// generic_name
@@ -174,7 +174,7 @@ std::shared_ptr<message_set_t> message_set =
})}
} // end signals vector
})} // end message_definition entry
-, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x3E9,"", 0, false, frequency_clock_t(5.00000f), true,
+, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x3E9,"", 0, 0,false, frequency_clock_t(5.00000f), true,
{ // beginning signals vector
{std::make_shared<signal_t> (signal_t{
"vehicle.average.speed",// generic_name
@@ -200,7 +200,7 @@ std::shared_ptr<message_set_t> message_set =
})}
} // end signals vector
})} // end message_definition entry
-, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x4D1,"", 0, false, frequency_clock_t(5.00000f), true,
+, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x4D1,"", 0, 0, false, frequency_clock_t(5.00000f), true,
{ // beginning signals vector
{std::make_shared<signal_t> (signal_t{
"engine.oil.temp",// generic_name
@@ -248,7 +248,7 @@ std::shared_ptr<message_set_t> message_set =
})}
} // end signals vector
})} // end message_definition entry
-, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x620,"", 0, false, frequency_clock_t(5.00000f), true,
+, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x620,"", 0, 0, false, frequency_clock_t(5.00000f), true,
{ // beginning signals vector
{std::make_shared<signal_t> (signal_t{
"doors.boot.open",// generic_name
@@ -362,7 +362,7 @@ std::shared_ptr<message_set_t> message_set =
})}
} // end signals vector
})} // end message_definition entry
-, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x799,"", 0, false, frequency_clock_t(5.00000f), true,
+, {std::make_shared<message_definition_t>(message_definition_t{"hs", 0x799,"", 0, 0, false, frequency_clock_t(5.00000f), true,
{ // beginning signals vector
{std::make_shared<signal_t> (signal_t{
"windows.front_left.open",// generic_name