1 Star 0 Fork 0

NightBreeze/modbus-esp8266

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

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.

Concurrent thread-safe access to Modbus object

Simple ModbusRTU master

Simple ModbusRTU slave

Sync ModbusRTU master

Modbus RTU Specific API

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 port
  • txEnablePin RX/TX control pin. Not assigned (assume auto RX/TX) by default
  • txEnableDirect 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
  • Slave mode: Returns configured slave id.
  • Master mode: Returns slave id for active request or 0 if no request in progress.

Modbus Library for Arduino

ModbusRTU, ModbusTCP and ModbusTCP Security

(c)2020 Alexander Emelianov

The code in this repo is licensed under the BSD New License. See LICENSE.txt for more info.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/d__xin/modbus-esp8266.git
git@gitee.com:d__xin/modbus-esp8266.git
d__xin
modbus-esp8266
modbus-esp8266
master

搜索帮助