emelianov / modbus-esp8266

Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.
Other
534 stars 188 forks source link

direction pin #266

Closed hedva92 closed 1 year ago

hedva92 commented 1 year ago

Hi, could you implement direction control pin to begin? I have a max485 board installed, but I don't have hardware control of the data direction, I need to add the direction control pin attribute to the begin function, which is mapped to the physical port of the microprocessor.

emelianov commented 1 year ago

This is already have implemented:

bool begin(SoftwareSerial* port, int16_t txPin=-1, bool direct=true);
bool begin(HardwareSerial* port, int16_t txPin=-1, bool direct=true);
bool begin(Stream* port, int16_t txPin=-1, bool direct=true);

Assing Serial port. txPin controls transmit enable for MAX-485. Pass direct=false if txPin uses inverse logic.

rob040 commented 1 year ago

For "txPin", a better name would be "txEnablePin" to describe its function. The TX pin is normally the UART transmit data pin, not an enable pin. For "direct", a better name would be "txEnableInvert" to describe its function.

emelianov commented 1 year ago

Naming changed in 0bc538d1eb43b2416733154c2fbc546c15b68858. Just txEnableDirect used as using Invert notation will break API.

rob040 commented 11 months ago

Agree about "txEnableInvert" would break the API, however, "Direct" is a non-descript name. The logic alternative would be "txEnableNoninvert"