@@ -81,12 +81,12 @@ void ModbusIP::task() {
8181 while (millis () - readStart < MODBUSIP_MAX_READMS && tcpclient[n]->available () > sizeof (_MBAP)) {
8282 tcpclient[n]->readBytes (_MBAP.raw , sizeof (_MBAP.raw )); // Get MBAP
8383
84- if (__bswap_16 (_MBAP.protocolId ) != 0 ) { // Check if MODBUSIP packet. __bswap is usless there.
84+ if (__swap_16 (_MBAP.protocolId ) != 0 ) { // Check if MODBUSIP packet. __bswap is usless there.
8585 while (tcpclient[n]->available ()) // Drop all incoming if wrong packet
8686 tcpclient[n]->read ();
8787 continue ;
8888 }
89- _len = __bswap_16 (_MBAP.length );
89+ _len = __swap_16 (_MBAP.length );
9090 _len--; // Do not count with last byte from MBAP
9191 if (_len > MODBUSIP_MAXFRAME) { // Length is over MODBUSIP_MAXFRAME
9292 exceptionResponse ((FunctionCode)tcpclient[n]->read (), EX_SLAVE_FAILURE);
@@ -112,7 +112,7 @@ void ModbusIP::task() {
112112 } else {
113113 // Process reply to master request
114114 _reply = EX_SUCCESS;
115- TTransaction* trans = searchTransaction (__bswap_16 (_MBAP.transactionId ));
115+ TTransaction* trans = searchTransaction (__swap_16 (_MBAP.transactionId ));
116116 if (trans) { // if valid transaction id
117117 if ((_frame[0 ] & 0x7F ) == trans->_frame [0 ]) { // Check if function code the same as requested
118118 // Procass incoming frame as master
@@ -135,7 +135,7 @@ void ModbusIP::task() {
135135 }
136136 if (tcpclient[n]->localPort () != serverPort) _reply = REPLY_OFF; // No replay if it was responce to master
137137 if (_reply != REPLY_OFF) {
138- _MBAP.length = __bswap_16 (_len+1 ); // _len+1 for last byte from MBAP
138+ _MBAP.length = __swap_16 (_len+1 ); // _len+1 for last byte from MBAP
139139 size_t send_len = (uint16_t )_len + sizeof (_MBAP.raw );
140140 uint8_t sbuf[send_len];
141141 memcpy (sbuf, _MBAP.raw , sizeof (_MBAP.raw ));
@@ -164,9 +164,9 @@ uint16_t ModbusIP::send(IPAddress ip, TAddress startreg, cbTransaction cb, uint8
164164 return autoConnectMode?connect (ip):false ;
165165 transactionId++;
166166 if (!transactionId) transactionId = 1 ;
167- _MBAP.transactionId = __bswap_16 (transactionId);
168- _MBAP.protocolId = __bswap_16 (0 );
169- _MBAP.length = __bswap_16 (_len+1 ); // _len+1 for last byte from MBAP
167+ _MBAP.transactionId = __swap_16 (transactionId);
168+ _MBAP.protocolId = __swap_16 (0 );
169+ _MBAP.length = __swap_16 (_len+1 ); // _len+1 for last byte from MBAP
170170 _MBAP.unitId = unit;
171171 size_t send_len = _len + sizeof (_MBAP.raw );
172172 uint8_t sbuf[send_len];
0 commit comments