@@ -111,13 +111,12 @@ bool ModbusRTU::rawSend(uint8_t slaveId, uint8_t* frame, uint8_t len) {
111111 _port->write (frame, len); // Send PDU
112112 _port->write (newCrc >> 8 ); // Send CRC
113113 _port->write (newCrc & 0xFF );// Send CRC
114- #ifdef ESP32
115- portEXIT_CRITICAL (&mux);
116- #endif
117114 _port->flush ();
118115 if (_txPin >= 0 )
119116 digitalWrite (_txPin, _direct?LOW:HIGH);
120- // delay(_t);
117+ #ifdef ESP32
118+ portEXIT_CRITICAL (&mux);
119+ #endif
121120 return true ;
122121}
123122
@@ -264,12 +263,12 @@ bool ModbusRTU::cleanup() {
264263
265264uint16_t ModbusRTU::writeHreg (uint8_t slaveId, uint16_t offset, uint16_t value, cbTransaction cb) {
266265 readSlave (offset, value, FC_WRITE_REG);
267- return send (slaveId, HREG (offset), cb, nullptr , cb );
266+ return send (slaveId, HREG (offset), cb, nullptr );
268267}
269268
270269uint16_t ModbusRTU::writeCoil (uint8_t slaveId, uint16_t offset, bool value, cbTransaction cb) {
271270 readSlave (offset, COIL_VAL (value), FC_WRITE_COIL);
272- return send (slaveId, COIL (offset), cb, nullptr , cb );
271+ return send (slaveId, COIL (offset), cb, nullptr );
273272}
274273
275274uint16_t ModbusRTU::readCoil (uint8_t slaveId, uint16_t offset, bool * value, uint16_t numregs, cbTransaction cb) {
@@ -282,14 +281,14 @@ uint16_t ModbusRTU::readCoil(uint8_t slaveId, uint16_t offset, bool* value, uint
282281uint16_t ModbusRTU::writeCoil (uint8_t slaveId, uint16_t offset, bool * value, uint16_t numregs, cbTransaction cb) {
283282 if (numregs < 0x0001 || numregs > 0x07D0 ) return false ;
284283 writeSlaveBits (COIL (offset), offset, numregs, FC_WRITE_COILS, value);
285- return send (slaveId, COIL (offset), cb, nullptr , cb );
284+ return send (slaveId, COIL (offset), cb, nullptr );
286285}
287286
288287
289288uint16_t ModbusRTU::writeHreg (uint8_t slaveId, uint16_t offset, uint16_t * value, uint16_t numregs, cbTransaction cb) {
290289 if (numregs < 0x0001 || numregs > 0x007D ) return false ;
291290 writeSlaveWords (HREG (offset), offset, numregs, FC_WRITE_REGS, value);
292- return send (slaveId, HREG (offset), cb, nullptr , cb );
291+ return send (slaveId, HREG (offset), cb, nullptr );
293292}
294293
295294
0 commit comments