Introduction into Modbus protocol and creation of simple server-client application.
- OS: Ubuntu 20.04
- C compiler: gcc 9.3.0
- Third party libraries: libmodbus
There are some steps required to perfom before You will be able to compile this project:
- Clone the libmodbus Github repository.
$ mkdir -p ~/workspace/third_party && cd ~/workspace/third_party/
$ git clone https://github.com/stephane/libmodbus
- Install
libmodbus
library:
$ cd libmodbus/
$ ./autogen.sh
$ ./configure && make install
- Create
modbus.conf
file in/etc/ld.so.conf.d/
:
$ sudo touch /etc/ld.so.conf.d/modbus.conf
Use your favourite text editor (e.g. Vim) and populate it with
/usr/local/lib/
(or other path, where libmodbus.so
is placed):
$ sudo vi /etc/ld.so.conf.d/modbus.conf
Update your system linker:
$ sudo ldconfig
Now You should be able to compile the application using attached Makefile
.
To build the application, just run single command:
$ make all
The application executables should be placed inside ./build/
directory.
To remove them, run:
$ make clean