Sign inSign up

edgepro/modbusd

By edgepro

•Updated over 9 years ago

Modbus master daemon based on libmodbus. Maintainer: Taka Wang

Image
4

3.7K

edgepro/modbusd repository overview

⁠modbusd⁠

Docker API

Modbus master daemon

  • Support doxygen style comments.
  • ZeroMQ is a high-level message library, you can replace it with your own data bus implementations without losing the core functionalities.

⁠Continuous Integration

I do continuous integration and build docker images after git push by self-hosted drone.io⁠ server for armhf platform , circleci⁠ server for x86 platform and dockerhub⁠ service.

CI ServerTargetStatus
TravisAPIBuild Status
CircleCIx86CircleCI
DronearmhfBuild Status

⁠Design

⁠Implemented libmodbus function codes
⁠Coil/register number and address table
Coil/Register numbersdata addresstypetable nameoffsetfunction code
1-99990000 to 270E (9998)Read-WriteDiscrete Output Coils11, 5, 15
10001-199990000 to 270E (9998)Read-OnlyDiscrete Input Contacts100012
30001-399990000 to 270E (9998)Read-OnlyAnalog Input Registers300014
40001-499990000 to 270E (9998)Read-WriteAnalog Output Holding Registers400013, 6, 16
⁠Command mapping table
CommandNumberDescription
fc11modbus fc 1
fc22modbus fc 2
fc33modbus fc 3
fc44modbus fc 4
fc55modbus fc 5
fc66modbus fc 6
fc1515modbus fc 15
fc1616modbus fc 16
set_tcp_timeout50set tcp timeout
get_tcp_timeout51get tcp timeout

⁠Configuration File
{
    "syslog": 1,
    "zmq":
    {
        "sub": "ipc:///tmp/to.modbus",
        "pub": "ipc:///tmp/from.modbus"
    },
    "mbtcp":
    {
        "connect_timeout": 200000
    }
}
⁠Modbus TCP command format

Please refer to command definition⁠.

⁠External libraries

⁠Library documentations
⁠Flow Chart

flow


⁠Setup

⁠Setup development dependencies
sudo apt-get update
sudo apt-get install -y git build-essential autoconf libtool pkg-config cmake

⁠Setup OSS libs dependencies
⁠Install libmodbus library (3.1.4)
git clone https://github.com/stephane/libmodbus/
cd libmodbus
./autogen.sh
./configure
make
sudo make install
sudo ldconfig
⁠Install libzmq (3.2.5)
wget https://github.com/zeromq/zeromq3-x/releases/download/v3.2.5/zeromq-3.2.5.tar.gz
tar xvzf zeromq-3.2.5.tar.gz
cd zeromq-3.2.5
./configure
make
sudo make install
sudo ldconfig
⁠Install czmq (high-level C binding for zeromq)
git clone git://github.com/zeromq/czmq.git
cd czmq
./autogen.sh
./configure
make
sudo make install
sudo ldconfig
⁠Build from source code
git clone modbusd
cd modbusd
mkdir build
cd build
cmake ..
make
./modbusd ../modbusd.json # load external configuration file

⁠Test Cases

  • Test holding registers (4x)
    • 4X Table: 60000 Read/Write uint16 value test: FC6, FC3
    • 4X Table: 30000 Read/Write int16 value test: FC6, FC3
    • 4X Table Multiple read/write test: FC16, FC3
    • 4X Table Multiple read/write test: FC16, FC3
  • Test coils (0x)
    • 0X Table Single read/write test:FC5, FC1
    • 0X Table Multiple read/write test: FC15, FC1
  • Test Discrete Input (1x)
    • 1X Table read test: FC2
  • Test Input Registers (3x)
    • 3X Table read test:FC4
  • Test TCP Timeout
    • Set timeout test
    • Get timeout test

ci

⁠Images and testing from the scratch

docker pull edgepro/c-modbus-slave:x86
docker build -t takawang/modbusd .
docker build -t takawang/dummy-psmbtcp test/dummy-psmbtcp/.

docker run -itd --name=slave edgepro/c-modbus-slave:x86
docker run -v /tmp:/tmp --link slave -it --name=modbusd takawang/modbusd
docker run -v /tmp:/tmp -it --link slave takawang/dummy-psmbtcp
⁠Docker compose
docker-compose up --abort-on-container-exit
⁠Deployment Diagram

uml


⁠Documentations


⁠License

MIT

Tag summary

Content type

Image

Digest

Size

6.4 MB

Last updated

over 9 years ago

docker pull edgepro/modbusd