devicesbus modbus rtu
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <functional>
|
||||
|
||||
#include "message_bus/pipeline/stages/1_framers/ModbusRtuFraming.h"
|
||||
#include "message_bus/pipeline/stages/3_filters/ProtocolParseFilter.h"
|
||||
#include "utils/logs/logging.h"
|
||||
|
||||
namespace softbus::message_bus::pipeline
|
||||
@@ -360,16 +361,7 @@ void PipelineEngine::parseWorkerLoop()
|
||||
}
|
||||
continue;
|
||||
}
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << std::setfill('0');
|
||||
for (std::size_t i = 0; i < ctx.payload.block->size; ++i) {
|
||||
oss << std::setw(2) << static_cast<int>(ctx.payload.block->data[i]);
|
||||
if (i + 1 < ctx.payload.block->size) {
|
||||
oss << ' ';
|
||||
}
|
||||
}
|
||||
const QString hexPreview = QString::fromStdString(oss.str());
|
||||
LOG_INFO() << "the data is"<< hexPreview;
|
||||
|
||||
|
||||
const bool ok = runStages234(ctx);
|
||||
if (m_rtConfig.orderedEgress && m_mergeQ) {
|
||||
@@ -449,9 +441,39 @@ bool PipelineEngine::runStages234(PipelineContext& ctx)
|
||||
if (ctx.frameKind != FrameKind::CompleteFrame) {
|
||||
return false;
|
||||
}
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << std::setfill('0');
|
||||
for (std::size_t i = 0; i < ctx.payload.block->size; ++i) {
|
||||
oss << std::setw(2) << static_cast<int>(ctx.payload.block->data[i]);
|
||||
if (i + 1 < ctx.payload.block->size) {
|
||||
oss << ' ';
|
||||
}
|
||||
}
|
||||
const QString hexPreview = QString::fromStdString(oss.str());
|
||||
LOG_INFO() << "the data is"<< hexPreview;
|
||||
LOG_INFO() << "the protocol hint is"<< ctx.protocolHint;
|
||||
const QString directionText = (ctx.direction == BusDirection::Upstream)
|
||||
? QStringLiteral("Upstream")
|
||||
: (ctx.direction == BusDirection::Downstream)
|
||||
? QStringLiteral("Downstream")
|
||||
: QStringLiteral("Unknown");
|
||||
LOG_INFO() << "the direction is" << directionText;
|
||||
if (!stage2Parser(ctx)) {
|
||||
return false;
|
||||
}
|
||||
QJsonObject parsed = ctx.parsed;
|
||||
LOG_INFO() << "the parsed is"<< parsed;
|
||||
|
||||
softbus::message_bus::pipeline::protocol::ProtocolEnvelope protocol = ctx.protocol;
|
||||
if (const auto* modbusPdu = std::get_if<softbus::message_bus::pipeline::protocol::ModbusRtuPdu>(&protocol.pdu)) {
|
||||
LOG_INFO() << "the protocol text is" << softbus::message_bus::pipeline::protocol::toText(*modbusPdu);
|
||||
} else {
|
||||
LOG_INFO() << "the protocol text is" << QStringLiteral("ProtocolEnvelopePdu::monostate");
|
||||
}
|
||||
|
||||
m_count++;
|
||||
LOG_INFO() << "the count of command is" << m_count;
|
||||
|
||||
if (!stage3Filter(ctx)) {
|
||||
return false;
|
||||
}
|
||||
@@ -504,8 +526,8 @@ bool PipelineEngine::stage2Parser(PipelineContext& ctx)
|
||||
|
||||
bool PipelineEngine::stage3Filter(PipelineContext& ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
return true;
|
||||
static softbus::message_bus::pipeline::stages::filters::ProtocolParseFilter s_filter;
|
||||
return s_filter.apply(ctx);
|
||||
}
|
||||
|
||||
} // namespace softbus::message_bus::pipeline
|
||||
|
||||
Reference in New Issue
Block a user