This example introduces how to use the library for ModbusRTU (typicaly over RS-485) to act as master or slave. Additionally there is example of master device for multithread usage with ESP32.
bool begin(SoftwareSerial* port, int16_t txEnablePin=-1, bool txEnableDirect=true);
bool begin(HardwareSerial* port, int16_t txEnablePin=-1, bool txEnableDirect=true);
bool begin(Stream* port);
port
Pointer to Serial porttxEnablePin
RX/TX control pin. Not assigned (assume auto RX/TX) by defaulttxEnableDirect
Direct (true, default) or inverse (false) RX/TX pin control.Assign Serial port. txEnablePin controls transmit enable for MAX-485.
void setBaudrate(uint32 baud);
baud
New baudrate.Set or override Serial baudrate. Must be called after .begin() for Non-ESP devices.
void client();
void server(uint8_t slaveId);
void slave(); // Deprecated
void master(uint8_t slaveId); // Deprecated
slaveId
Modbus slave id to associate to.Select and initialize master or slave mode to work. Switching between modes is not supported. Call is not returning error in this case but behaviour is unpredictable.
uint8_t client();
uint8_t slave(); // Deprecated
(c)2020 Alexander Emelianov
The code in this repo is licensed under the BSD New License. See LICENSE.txt for more info.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。