mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 17:13:34 +08:00
respected reviewer comments
This commit is contained in:
committed by
Julian Oes
parent
12687f7d8f
commit
d303b73bc3
@@ -399,9 +399,9 @@ private:
|
|||||||
MavlinkStreamStatustext &operator = (const MavlinkStreamStatustext &) = delete;
|
MavlinkStreamStatustext &operator = (const MavlinkStreamStatustext &) = delete;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int id;
|
int _id{0};
|
||||||
|
|
||||||
explicit MavlinkStreamStatustext(Mavlink *mavlink) : MavlinkStream(mavlink), id(0)
|
explicit MavlinkStreamStatustext(Mavlink *mavlink) : MavlinkStream(mavlink)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool send(const hrt_abstime t) override
|
bool send(const hrt_abstime t) override
|
||||||
@@ -417,16 +417,16 @@ protected:
|
|||||||
constexpr unsigned max_chunk_size = sizeof(msg.text);
|
constexpr unsigned max_chunk_size = sizeof(msg.text);
|
||||||
msg.severity = mavlink_log.severity;
|
msg.severity = mavlink_log.severity;
|
||||||
msg.chunk_seq = 0;
|
msg.chunk_seq = 0;
|
||||||
msg.id = id++;
|
msg.id = _id++;
|
||||||
unsigned text_size;
|
unsigned text_size;
|
||||||
|
|
||||||
while ((text_size = strlen(text)) > 0) {
|
while ((text_size = strlen(text)) > 0) {
|
||||||
unsigned chunk_size = math::min(text_size, max_chunk_size);
|
unsigned chunk_size = math::min(text_size, max_chunk_size);
|
||||||
|
|
||||||
if (chunk_size < max_chunk_size) {
|
if (chunk_size < max_chunk_size) {
|
||||||
memcpy(&msg.text[0], &text[0], chunk_size + 1);
|
memcpy(&msg.text[0], &text[0], chunk_size);
|
||||||
// pad with zeros
|
// pad with zeros
|
||||||
memset(&msg.text + chunk_size, 0, max_chunk_size - chunk_size);
|
memset(&msg.text[0] + chunk_size, 0, max_chunk_size - chunk_size);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
memcpy(&msg.text[0], &text[0], chunk_size);
|
memcpy(&msg.text[0], &text[0], chunk_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user