Add Modbus with isaac SDK

anyway to add Modbus to isaac SDK?
I want to include <modbus.h> into my cpp codelet, after I did
sudo apt install libmodbus5

what else should I include into the bazel file, is isaac sdk able to use this kind of library?

Bazel will need to know where that header file is in your system. Either you can add to the toolchain config the include directory of where modbus gets installed as a cxx_system_include_dir (not recommended) OR you can configure a third_party target like sdk/third_party/modbus.BUILD (see sdk/third_party/opencv.BUILD for an example) which your cpp codelet target would depend on which merely adds linkopts and specifies where the header is.

I able to solve that when running on local machine but when deploy I get the error
INFO: Analyzed target //apps/AMV_BOT/Apps:teleop-pkg (0 packages loaded, 0 targets configured).
INFO: Found 1 target…
ERROR: /home/hongyee/isaac-sdk-20210609-e336b5195/sdk/apps/AMV_BOT/Packages/motorDriver/BUILD:3:1: Couldn’t build file apps/AMV_BOT/Packages/motorDriver/_objs/_modlib_motorDriver_components/motorDriver.o: C++ compilation of rule ‘//apps/AMV_BOT/Packages/motorDriver:_modlib_motorDriver_components’ failed (Exit 1) crosstool_wrapper_driver_is_not_gcc.py failed: error executing command external/toolchain/crosstool/scripts/crosstool_wrapper_driver_is_not_gcc.py -MD -MF bazel-out/aarch64-opt/bin/apps/AMV_BOT/Packages/motorDriver/_objs/_modlib_motorDriver_components/motorDriver.d … (remaining 227 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
In file included from apps/AMV_BOT/Packages/motorDriver/motorDriver.cpp:1:0:
apps/AMV_BOT/Packages/motorDriver/motorDriver.hpp:3:10: fatal error: modbus/modbus.h: No such file or directory
#include “modbus/modbus.h”
^~~~~~~~~~~~~~~~~
compilation terminated.

I thought i already declare in the BUILD file?
I had declare this inside the codelet directory, not sure why im not able to do deployment on jetpack45 devices even i did install the same stuff on the jetpack machine like physically compile the library on the device.

load("//bzl:module.bzl", “isaac_app”, “isaac_cc_module”)

isaac_cc_module(
name = “motorDriver_components”,
srcs = [“motorDriver.cpp”],
hdrs = [“motorDriver.hpp”],
deps =[“libmodbus”,
“//messages/state:differential_base”,
“//packages/engine_gems/state:io”,
],

visibility = ["//visibility:public"],

)
cc_library(
name = “libmodbus”,
srcs = glob([“local/lib/libmodbus.so”,
“local/lib/libmodbus.so.5”,
“local/lib/libmodbus.so.5.1.0”]),
hdrs = glob([“local/include/modbus.h”,
“local/include/modbus-tcp.h”,
“local/include/modbus-rtu.h”,
“local/include/modbus-version.h”]),
linkopts = [
“-l:libmodbus.so.5”
],
visibility = ["//visibility:public"],
)

It looks like you copied the modbus headers into your Bazel workspace but in a relative path at local/include/modbus.h whereas your include in the implementation has modbus/modbus.h. Changing this to local/include might let the host system find those header files.

Hi,
inside this external library there has a file that contain “.h.in” which I’m not sure how to compiled that into bazel repository. This library was using “./configure && make install” method. which generate multiple of different file like config.h.

any example that able to help me generate with this method.

Here is my third_party/modbus.BUILD

cc_library(
    name = "lib_modbus",
    srcs = glob([
        "src/*.c",
        
    ]),
    hdrs = glob([
        "src/*.h"
    ]),
    includes = [
        "include",
        "src",
    ],
    visibility = ["//visibility:public"],
)
Here is my repository file
    isaac_new_git_repository(
        name = "lib_modbus",
        build_file = clean_dep("//third_party:modbus.BUILD"),
        remote = "https://github.com/stephane/libmodbus.git",
        commit = "27b90deddba7c4d7c5d7d8494f1aec9ef6d69cea",
        licenses = ["//:LICENSE"],
    )

ERROR: /home/hongyee/.cache/bazel/_bazel_hongyee/a3ad82d4311fb7a07eb81c635d91ab70/external/lib_modbus/BUILD.bazel:1:1: Couldn’t build file external/lib_modbus/_objs/lib_modbus/modbus-tcp.o: C++ compilation of rule ‘@lib_modbus//:lib_modbus’ failed (Exit 1) crosstool_wrapper_driver_is_not_gcc_host.py failed: error executing command external/toolchain/crosstool/scripts/crosstool_wrapper_driver_is_not_gcc_host.py -MD -MF bazel-out/k8-opt/bin/external/lib_modbus/_objs/lib_modbus/modbus-tcp.d … (remaining 34 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
In file included from external/lib_modbus/src/modbus-tcp.c:56:0:
external/lib_modbus/src/modbus-private.h:19:10: fatal error: config.h: No such file or directory
#include <config.h>
^~~~~~~~~~
compilation terminated.