mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
can debugger
fix message disappearing
This commit is contained in:
+12
-14
@@ -24,13 +24,15 @@ UI_can::UI_can(const json &j, QObject *parent) : UI_item(UI_CAN_TYPE, parent)
|
|||||||
|
|
||||||
void UI_can::add_send_message(QCanBusFrame msg)
|
void UI_can::add_send_message(QCanBusFrame msg)
|
||||||
{
|
{
|
||||||
m_can_send_messages.push_back(msg);
|
CanFrame frame(msg.frameId(), (uint8_t)msg.payload().size(), ByteArrayToStdArray<std::array<uint8_t, 8>>(msg.payload()));
|
||||||
|
m_can_send_messages.push_back(frame);
|
||||||
emit value_changed();
|
emit value_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI_can::add_received_message(QCanBusFrame msg)
|
void UI_can::add_received_message(QCanBusFrame msg)
|
||||||
{
|
{
|
||||||
m_can_received_messages.push_back(msg);
|
CanFrame frame(msg.frameId(), (uint8_t)msg.payload().size(), ByteArrayToStdArray<std::array<uint8_t, 8>>(msg.payload()));
|
||||||
|
m_can_received_messages.push_back(frame);
|
||||||
emit value_changed();
|
emit value_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,16 +61,12 @@ void UI_can::from_json(const json &j)
|
|||||||
m_can_received_messages.clear();
|
m_can_received_messages.clear();
|
||||||
for (const auto &msg : j.at("send_msgs"))
|
for (const auto &msg : j.at("send_msgs"))
|
||||||
{
|
{
|
||||||
QCanBusFrame can_msg;
|
CanFrame can_msg(msg.at("id"), msg.at("dlc"), msg.at("payload"));
|
||||||
can_msg.setFrameId(msg.at("id"));
|
|
||||||
can_msg.setPayload(QByteArray(msg.at("payload"), msg.at("dlc")));
|
|
||||||
m_can_send_messages.push_back(can_msg);
|
m_can_send_messages.push_back(can_msg);
|
||||||
}
|
}
|
||||||
for (const auto &msg : j.at("rcvd_msgs"))
|
for (const auto &msg : j.at("rcvd_msgs"))
|
||||||
{
|
{
|
||||||
QCanBusFrame can_msg;
|
CanFrame can_msg(msg.at("id"), msg.at("dlc"), msg.at("payload"));
|
||||||
can_msg.setFrameId(msg.at("id"));
|
|
||||||
can_msg.setPayload(QByteArray(msg.at("payload"), msg.at("dlc")));
|
|
||||||
m_can_received_messages.push_back(can_msg);
|
m_can_received_messages.push_back(can_msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,9 +79,9 @@ json UI_can::to_json(size_t id) const
|
|||||||
for (const auto &msg : m_can_send_messages)
|
for (const auto &msg : m_can_send_messages)
|
||||||
{
|
{
|
||||||
json can_msg;
|
json can_msg;
|
||||||
can_msg["id"] = (uint32_t)msg.frameId();
|
can_msg["id"] = (uint32_t)msg.m_SID;
|
||||||
can_msg["dlc"] = msg.payload().size();
|
can_msg["dlc"] = msg.m_DLC;
|
||||||
can_msg["payload"] = ByteArrayToStdArray<std::array<uint8_t, 8>>(msg.payload());
|
can_msg["payload"] = msg.m_payload;
|
||||||
|
|
||||||
can_send_messages.push_back(can_msg);
|
can_send_messages.push_back(can_msg);
|
||||||
}
|
}
|
||||||
@@ -91,9 +89,9 @@ json UI_can::to_json(size_t id) const
|
|||||||
for (const auto &msg : m_can_received_messages)
|
for (const auto &msg : m_can_received_messages)
|
||||||
{
|
{
|
||||||
json can_msg;
|
json can_msg;
|
||||||
can_msg["id"] = (uint32_t)msg.frameId();
|
can_msg["id"] = (uint32_t)msg.m_SID;
|
||||||
can_msg["dlc"] = msg.payload().size();
|
can_msg["dlc"] = msg.m_DLC;
|
||||||
can_msg["payload"] = ByteArrayToStdArray<std::array<uint8_t, 8>>(msg.payload());
|
can_msg["payload"] = msg.m_payload;
|
||||||
|
|
||||||
can_received_messages.push_back(can_msg);
|
can_received_messages.push_back(can_msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,19 @@
|
|||||||
|
|
||||||
#define UI_CAN_TYPE std::string("UI_can")
|
#define UI_CAN_TYPE std::string("UI_can")
|
||||||
|
|
||||||
|
class CanFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CanFrame(uint32_t sid, uint8_t dlc, std::array<uint8_t, 8> payload)
|
||||||
|
: m_SID(sid), m_DLC(dlc), m_payload(payload)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
uint32_t m_SID;
|
||||||
|
uint8_t m_DLC;
|
||||||
|
std::array<uint8_t, 8> m_payload;
|
||||||
|
};
|
||||||
|
|
||||||
class UI_can : public UI_item
|
class UI_can : public UI_item
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -25,6 +38,6 @@ class UI_can : public UI_item
|
|||||||
signals:
|
signals:
|
||||||
void on_send(QCanBusFrame msg);
|
void on_send(QCanBusFrame msg);
|
||||||
private:
|
private:
|
||||||
std::vector<QCanBusFrame> m_can_send_messages;
|
std::vector<CanFrame> m_can_send_messages;
|
||||||
std::vector<QCanBusFrame> m_can_received_messages;
|
std::vector<CanFrame> m_can_received_messages;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user