#pragma once

#include <cstddef>
#include <cstdint>

#include <QByteArray>
#include <QString>

#include "plugins/protocols/modbus_rtu/types/ModbusRtuPdu.h"

namespace softbus::message_bus::pipeline
{
enum class BusDirection;
}

namespace softbus::message_bus::pipeline::protocol
{

bool decodeModbusRtu(softbus::message_bus::pipeline::BusDirection dir,
                     const std::uint8_t*                           p,
                     std::size_t                                   n,
                     ModbusRtuPdu&                                 out,
                     QString*                                      errMsg = nullptr);

bool encodeModbusRtu(const ModbusRtuPdu& pdu, QByteArray& out, QString* errMsg = nullptr);

} // namespace softbus::message_bus::pipeline::protocol
