代码拉取完成,页面将自动刷新
Basic 'Bridge'. Indeed this sample pulling data from Modbus Server and stores it to local registers. Local registers can be accessed via Modbus Client instance that running aside.
Fullfunctional ModbusRTU to ModbusTCP bridge.
Respond for multiple ModbusRTU IDs from single device
Fullfunctional ModbusTCP to ModbusRTU bridge with on-device ModbusRTU simulator
uint16_t rawRequest(id_ip, uint8_t* data, uint16_t len, cbTransaction cb = nullptr, uint8_t unit = MODBUSIP_UNIT);
uint16_t rawResponce(id_ip, uint8_t* data, uint16_t len, uint8_t unit = MODBUSIP_UNIT);
uint16_t errorResponce(id_ip, Modbus::FunctionCode fn, Modbus::ResultCode excode, uint8_t unit = MODBUSIP_UNIT);
id_ip
SlaveId (uint8_t
) or server IP address (IPAddress
)data
Pointer to data buffer to sendlen
Byte count to sendunit
UnitId (ModbusTCP/TLS only)fn
function code in responceexcode
Exception code in responceuint16_t setTransactionId(uint16_t id);
id
Value to replace transaction id sequence (ModbusTCP/TLS only)union frame_arg_t {
struct frame_arg_t {
bool to_server; // true if frame is responce for local Modbus server/slave
union {
// For ModbusRTU
uint8_t slaveId;
// For ModbusTCP/TLS
struct {
uint8_t unitId; // UnitId as passed in MBAP header
uint32_t ipaddr; // IP address from which frame is received
uint16_t transactionId; // TransactionId as passed in MBAP header
};
};
};
typedef std::function<ResultCode(uint8_t*, uint8_t, void*)> cbRaw; // Callback function Type for STL
typedef ResultCode (*cbRaw)(uint8_t* frame, uint8 len, void* data); // Callback function Type
bool onRaw(cbRaw cb = nullptr);
frame
Modbus payload frame with stripped MBAP/slaveid and crclen
frame size in bytesdata
Pointer to frame_arg_t filled with frame header informationReturns:
Modbus::EX_PASSTHROUGH
returned frame will be processed normallyModbus::EX_FORCE_PROCESS
returned frame will be processed even if addressed to another Modbus unit此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。