Including Modbus RTU/TCP library

I’m a bit confused on how to correctly include an external library into RIOT.

My goal is to have a Modbus library supporting RTU and TCP. I found an appropriate library on

I’m not sure which requirements it fulfills and if I have to add it as a module

or as an (external) package

I would be very grateful for a few hints :slight_smile:

Since it’s an external library, you would want to add it as a package. You’ll probably need a thin adaption layer for it to work with RIOT. Alternatively you could try to add RIOT support to the library, seeing that it already provides support for different operating systems.

There is also a PR for a native Modbus RTU implementation. Unfortunately that’s a bit stalled, likely due to lack of experience with Modbus experience in the RIOT community.

If you could test this and add your comments, that would be great.

Okay, I’m not very experienced in that, so I will take the easiest way, which I guess is adding it as a package.

Can you give me a short explanation what exactly you think of, when you talk about a “thin adaption layer”? Where do I have to place that? Is there maybe something similiar existing in RIOT which I could refer to as kind of a template?

Well libmodbus expects the Linux / Windows / QNX API, so you either can patch it to call the RIOT API instead or provide the missing API functions in RIOT.

Check out packages with contrib/ and patches/ for an example.

A good first approach would be to just try to add it as a package, then build it with the RIOT build system and see what breaks.