其他分享
首页 > 其他分享> > RT-Thread 应用笔记 - libmodbus RTU 编译问题的解决

RT-Thread 应用笔记 - libmodbus RTU 编译问题的解决

作者:互联网

前言

Keil MDK5 解决方法

Build started: Project: project
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'rt-thread'
compiling modbus.c...
packages\libmodbus-latest\inc\modbus-private.h(84): error:  #20: identifier "fd_set" is undefined
      int (*select) (modbus_t *ctx, fd_set *rset, struct timeval *tv, int msg_length);
packages\libmodbus-latest\src\modbus.c(150): warning:  #68-D: integer conversion resulted in a change of sign
          return MSG_LENGTH_UNDEFINED;
packages\libmodbus-latest\src\modbus.c(184): error:  #20: identifier "EBADF" is undefined
                  if ((errno == EBADF || errno == ECONNRESET || errno == EPIPE)) {
packages\libmodbus-latest\src\modbus.c(184): error:  #20: identifier "ECONNRESET" is undefined
                  if ((errno == EBADF || errno == ECONNRESET || errno == EPIPE)) {
packages\libmodbus-latest\src\modbus.c(184): error:  #20: identifier "EPIPE" is undefined
                  if ((errno == EBADF || errno == ECONNRESET || errno == EPIPE)) {
packages\libmodbus-latest\src\modbus.c(339): error:  #20: identifier "fd_set" is undefined
      fd_set rset;
packages\libmodbus-latest\src\modbus.c(355): warning:  #223-D: function "FD_ZERO" declared implicitly
      FD_ZERO(&rset);
packages\libmodbus-latest\src\modbus.c(356): warning:  #223-D: function "FD_SET" declared implicitly
      FD_SET(ctx->s, &rset);
packages\libmodbus-latest\src\modbus.c(381): error:  #20: identifier "ETIMEDOUT" is undefined
                  if (errno == ETIMEDOUT) {
packages\libmodbus-latest\src\modbus.c(384): error:  #20: identifier "EBADF" is undefined
                  } else if (errno == EBADF) {
packages\libmodbus-latest\src\modbus.c(395): error:  #20: identifier "ECONNRESET" is undefined
              errno = ECONNRESET;
packages\libmodbus-latest\src\modbus.c(402): error:  #20: identifier "ECONNRESET" is undefined
                  (errno == ECONNRESET || errno == ECONNREFUSED ||
packages\libmodbus-latest\src\modbus.c(402): error:  #20: identifier "ECONNREFUSED" is undefined
                  (errno == ECONNRESET || errno == ECONNREFUSED ||
packages\libmodbus-latest\src\modbus.c(403): error:  #20: identifier "EBADF" is undefined
                   errno == EBADF)) {
packages\libmodbus-latest\src\modbus.c(910): error:  #20: identifier "ENOPROTOOPT" is undefined
          errno = ENOPROTOOPT;
packages\libmodbus-latest\src\modbus.c(912): warning:  #111-D: statement is unreachable
          break;
packages\libmodbus-latest\src\modbus.c: 4 warnings, 12 errors
compiling modbus-rtu.c...
packages\libmodbus-latest\src\modbus-rtu.c(18): error:  #5: cannot open source input file "dfs_select.h": No such file or directory
  #include <dfs_select.h>
packages\libmodbus-latest\src\modbus-rtu.c: 0 warnings, 1 error
compiling serial.c...
..\..\..\components\drivers\serial\serial.c(890): error:  #20: identifier "speed_t" is undefined
      speed_t speed;
..\..\..\components\drivers\serial\serial.c(896): error:  #20: identifier "B2400" is undefined
      {B2400, BAUD_RATE_2400},
..\..\..\components\drivers\serial\serial.c(897): error:  #20: identifier "B4800" is undefined
      {B4800, BAUD_RATE_4800},
..\..\..\components\drivers\serial\serial.c(898): error:  #20: identifier "B9600" is undefined
      {B9600, BAUD_RATE_9600},
..\..\..\components\drivers\serial\serial.c(899): error:  #20: identifier "B19200" is undefined
      {B19200, BAUD_RATE_19200},
..\..\..\components\drivers\serial\serial.c(900): error:  #20: identifier "B38400" is undefined
      {B38400, BAUD_RATE_38400},
..\..\..\components\drivers\serial\serial.c(901): error:  #20: identifier "B57600" is undefined
      {B57600, BAUD_RATE_57600},
..\..\..\components\drivers\serial\serial.c(902): error:  #20: identifier "B115200" is undefined
      {B115200, BAUD_RATE_115200},
..\..\..\components\drivers\serial\serial.c(903): error:  #20: identifier "B230400" is undefined
      {B230400, BAUD_RATE_230400},
..\..\..\components\drivers\serial\serial.c(904): error:  #20: identifier "B460800" is undefined
      {B460800, BAUD_RATE_460800},
..\..\..\components\drivers\serial\serial.c(905): error:  #20: identifier "B921600" is undefined
      {B921600, BAUD_RATE_921600},
..\..\..\components\drivers\serial\serial.c(906): error:  #20: identifier "B2000000" is undefined
      {B2000000, BAUD_RATE_2000000},
..\..\..\components\drivers\serial\serial.c(907): error:  #20: identifier "B3000000" is undefined
      {B3000000, BAUD_RATE_3000000},
..\..\..\components\drivers\serial\serial.c(910): error:  #20: identifier "speed_t" is undefined
  static speed_t _get_speed(int baudrate)
..\..\..\components\drivers\serial\serial.c(920): error:  #20: identifier "B0" is undefined
      return B0;
..\..\..\components\drivers\serial\serial.c(923): error:  #20: identifier "speed_t" is undefined
  static int _get_baudrate(speed_t speed)
..\..\..\components\drivers\serial\serial.c(950): error:  #20: identifier "TCIFLUSH" is undefined
          case TCIFLUSH:
..\..\..\components\drivers\serial\serial.c(951): error:  #20: identifier "TCIOFLUSH" is undefined
          case TCIOFLUSH:
..\..\..\components\drivers\serial\serial.c(974): error:  #20: identifier "TCOFLUSH" is undefined
           case TCOFLUSH:
..\..\..\components\drivers\serial\serial.c(910): warning:  #177-D: function "_get_speed"  was declared but never referenced
  static speed_t _get_speed(int baudrate)
..\..\..\components\drivers\serial\serial.c(923): warning:  #177-D: function "_get_baudrate"  was declared but never referenced
  static int _get_baudrate(speed_t speed)
..\..\..\components\drivers\serial\serial.c(936): warning:  #177-D: function "_tc_flush"  was declared but never referenced
  static void _tc_flush(struct rt_serial_device *serial, int queue)
..\..\..\components\drivers\serial\serial.c: 3 warnings, 19 errors
".\build\keil\Obj\rt-thread.axf" - 32 Error(s), 7 Warning(s).
Target not created.
Build Time Elapsed:  00:00:01

2021-12-24_094940.png

libmodbus软件包修改如下:

小结

参考例程

https://gitee.com/zhangsz0516/nucleo_l476rg_pm/tree/master/libmodbus_master

标签:RT,libmodbus,20,Thread,..,error,serial,identifier,undefined
来源: https://blog.csdn.net/tcjy1000/article/details/122137773