Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: ModbusTCP undefined reference to delayMicroseconds

  1. #1
    Junior Member
    Join Date
    Nov 2020
    Posts
    9

    ModbusTCP undefined reference to delayMicroseconds

    I am trying get the EthernetModbusServerLED example to run on the Teensy4.1.
    The example code is included in the ModbusTPC library: https://github.com/arduino-libraries...verLED.ino#L16
    The only change I think is required is this line to NativeEthernet.h
    I am using v1.0.5 of ArduinoModbus and have tried other versions.

    The compilation errors on
    C:\Users\bung\Documents\Arduino\libraries\ArduinoM odbus\src\libmodbus/modbus.c:162: undefined reference to `delayMicroseconds'

    Code:
    In file included from C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\ModbusRTUClient.cpp:27:0:
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\ModbusRTUClient.h: In constructor 'ModbusRTUClientClass::ModbusRTUClientClass(RS485Class&)':
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\ModbusRTUClient.h:44:25: warning: 'ModbusRTUClientClass::_rs485' will be initialized after [-Wreorder]
       RS485Class* _rs485 = &RS485;
                             ^
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\ModbusRTUClient.cpp:35:36: warning:   base 'ModbusClient' [-Wreorder]
       _rs485(&rs485), ModbusClient(1000)
                                        ^
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\ModbusRTUClient.cpp:34:1: warning:   when initialized here [-Wreorder]
     ModbusRTUClientClass::ModbusRTUClientClass(RS485Class& rs485) :
     ^
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\libmodbus\modbus.c: In function '_sleep_response_timeout':
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\libmodbus\modbus.c:161:5: warning: implicit declaration of function 'delay' [-Wimplicit-function-declaration]
         delay(ctx->response_timeout.tv_sec * 1000);
         ^
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\libmodbus\modbus.c:162:5: warning: implicit declaration of function 'delayMicroseconds' [-Wimplicit-function-declaration]
         delayMicroseconds(ctx->response_timeout.tv_usec);
         ^
    C:\Users\bung\AppData\Local\Temp\arduino_build_329130\libraries\ArduinoModbus\libmodbus\modbus.c.o: In function `_sleep_response_timeout':
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\libmodbus/modbus.c:162: undefined reference to `delayMicroseconds'
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\libmodbus/modbus.c:162: undefined reference to `delayMicroseconds'
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\libmodbus/modbus.c:162: undefined reference to `delayMicroseconds'
    C:\Users\bung\Documents\Arduino\libraries\ArduinoModbus\src\libmodbus/modbus.c:162: undefined reference to `delayMicroseconds'
    collect2.exe: error: ld returned 1 exit status
    Error compiling for board Teensy 4.1.
    Here is the offending line https://github.com/arduino-libraries.../modbus.c#L162

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,077
    It's a bug in ArduinoModbus. Here's a fixed copy.

    https://github.com/PaulStoffregen/ArduinoModbus

  3. #3
    Junior Member
    Join Date
    Nov 2020
    Posts
    9
    Confirmed, thanks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •