Code Review
/
apps
/
agl-service-can-low-level.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
low-can-cb: Mark the end of the CtlSections array
[apps/agl-service-can-low-level.git]
/
low-can-binding
/
can
/
message
/
can-message.cpp
diff --git
a/low-can-binding/can/message/can-message.cpp
b/low-can-binding/can/message/can-message.cpp
index
8a04992
..
5c3e0f0
100644
(file)
--- a/
low-can-binding/can/message/can-message.cpp
+++ b/
low-can-binding/can/message/can-message.cpp
@@
-35,12
+35,11
@@
can_message_t::can_message_t()
can_message_t::can_message_t(uint32_t maxdlen,
uint32_t id,
uint32_t length,
can_message_t::can_message_t(uint32_t maxdlen,
uint32_t id,
uint32_t length,
- message_format_t format,
bool rtr_flag,
uint32_t flags,
std::vector<uint8_t>& data,
uint64_t timestamp)
bool rtr_flag,
uint32_t flags,
std::vector<uint8_t>& data,
uint64_t timestamp)
- : message_t(maxdlen, length, f
ormat, data, timestamp, flags
),
+ : message_t(maxdlen, length, f
lags, data, timestamp
),
id_{id},
rtr_flag_{rtr_flag}
{}
id_{id},
rtr_flag_{rtr_flag}
{}
@@
-56,13
+55,18
@@
uint32_t can_message_t::get_id() const
}
}
+void can_message_t::set_id(const canid_t id)
+{
+ id_ = id;
+}
+
/// @brief Control whether the object is correctly initialized
/// to be sent over the CAN bus
///
/// @return True if object correctly initialized and false if not.
bool can_message_t::is_correct_to_send()
{
/// @brief Control whether the object is correctly initialized
/// to be sent over the CAN bus
///
/// @return True if object correctly initialized and false if not.
bool can_message_t::is_correct_to_send()
{
- if (id_ != 0 && length_ != 0 &&
format_ != message_format_t::INVALID
)
+ if (id_ != 0 && length_ != 0 &&
!(flags_&INVALID_FLAG)
)
{
int i;
for(i=0;i<length_;i++)
{
int i;
for(i=0;i<length_;i++)
@@
-83,9
+87,8
@@
bool can_message_t::is_correct_to_send()
std::shared_ptr<can_message_t> can_message_t::convert_from_frame(const struct canfd_frame& frame, size_t nbytes, uint64_t timestamp)
{
uint32_t maxdlen = 0, length = 0;
std::shared_ptr<can_message_t> can_message_t::convert_from_frame(const struct canfd_frame& frame, size_t nbytes, uint64_t timestamp)
{
uint32_t maxdlen = 0, length = 0;
- uint
8
_t flags = 0;
+ uint
32
_t flags = 0;
uint32_t id;
uint32_t id;
- message_format_t format;
bool rtr_flag;
std::vector<uint8_t> data;
bool rtr_flag;
std::vector<uint8_t> data;
@@
-106,17
+109,15
@@
std::shared_ptr<can_message_t> can_message_t::convert_from_frame(const struct ca
if (frame.can_id & CAN_ERR_FLAG)
{
if (frame.can_id & CAN_ERR_FLAG)
{
- f
ormat = message_format_t::INVALID
;
+ f
lags = flags|INVALID_FLAG
;
id = frame.can_id & (CAN_ERR_MASK|CAN_ERR_FLAG);
}
else if (frame.can_id & CAN_EFF_FLAG)
{
id = frame.can_id & (CAN_ERR_MASK|CAN_ERR_FLAG);
}
else if (frame.can_id & CAN_EFF_FLAG)
{
- format = message_format_t::EXTENDED;
id = frame.can_id & CAN_EFF_MASK;
}
else
{
id = frame.can_id & CAN_EFF_MASK;
}
else
{
- format = message_format_t::STANDARD;
id = frame.can_id & CAN_SFF_MASK;
}
id = frame.can_id & CAN_SFF_MASK;
}
@@
-140,8
+141,8
@@
std::shared_ptr<can_message_t> can_message_t::convert_from_frame(const struct ca
length = (frame.len > maxdlen) ? maxdlen : frame.len;
/* Flags field only present for CAN FD frames*/
length = (frame.len > maxdlen) ? maxdlen : frame.len;
/* Flags field only present for CAN FD frames*/
- if(maxdlen == CANFD_MAX_DLEN)
- flags = frame.flags & 0xF;
+
/*
if(maxdlen == CANFD_MAX_DLEN)
+ flags = frame.flags & 0xF;
*/
if (data.capacity() < maxdlen)
data.reserve(maxdlen);
if (data.capacity() < maxdlen)
data.reserve(maxdlen);
@@
-155,10
+156,10
@@
std::shared_ptr<can_message_t> can_message_t::convert_from_frame(const struct ca
};
AFB_DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
};
AFB_DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
- id, (uint
8_t)format
, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
+ id, (uint
32_t)flags
, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
}
}
- return std::make_shared<can_message_t>(can_message_t(maxdlen, id, length,
format,
rtr_flag, flags, data, timestamp));
+ return std::make_shared<can_message_t>(can_message_t(maxdlen, id, length, rtr_flag, flags, data, timestamp));
}
/// @brief Take all initialized class members and build a
}
/// @brief Take all initialized class members and build a
@@
-203,12
+204,12
@@
struct std::vector<canfd_frame> can_message_t::convert_to_canfd_frame_vector()
std::vector<uint8_t> data = get_data_vector((i*64),(i*64)+63);
if(data.size()<64)
{
std::vector<uint8_t> data = get_data_vector((i*64),(i*64)+63);
if(data.size()<64)
{
- ::memset(frame.data,
0,
sizeof(frame.data));
- ::memcpy(frame.data,
data.data(),
data.size());
+ ::memset(frame.data,
0,
sizeof(frame.data));
+ ::memcpy(frame.data,
data.data(),
data.size());
}
else
{
}
else
{
- ::memcpy(frame.data,
data.data(),
64);
+ ::memcpy(frame.data,
data.data(),
64);
}
ret.push_back(frame);
i++;
}
ret.push_back(frame);
i++;
@@
-225,13
+226,13
@@
struct std::vector<canfd_frame> can_message_t::convert_to_canfd_frame_vector()
std::vector<uint8_t> data = get_data_vector(i*8,(i*8)+7);
if(data.size()<8)
{
std::vector<uint8_t> data = get_data_vector(i*8,(i*8)+7);
if(data.size()<8)
{
- ::memset(frame.data,
0,
sizeof(frame.data));
- ::memcpy(frame.data,
data.data(),
data.size());
+ ::memset(frame.data,
0,
sizeof(frame.data));
+ ::memcpy(frame.data,
data.data(),
data.size());
}
else
{
}
else
{
- ::memset(frame.data,
0,
sizeof(frame.data));
- ::memcpy(frame.data,
data.data(),
8);
+ ::memset(frame.data,
0,
sizeof(frame.data));
+ ::memcpy(frame.data,
data.data(),
8);
}
ret.push_back(frame);
i++;
}
ret.push_back(frame);
i++;