Modbus tcp client linux

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

License

adpuckett87/modbus-client-server

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

  • modbus-client is a standalone command line Modbus TCP client
  • modbus-server is a Modbus TCP server that uses mysql to store register values
modbus-client ip_address slave_id r reg_type address [num_reg format] 
modbus-client ip_address slave_id w reg_type address value [format] 
  • a — floating point abcd
  • b — floating point badc
  • c — floating point cdab
  • d — floating point dcba
  • (s)1 — 16-bit register. Optionally signed. Default.
  • (s)3 — 32-bit register. Optionally signed.
  • (s)6 — 64-bit register. Optionally signed.
  • (s)k — 32-bit Mod10k. Optionally signed.
  • (s)l — 48-bit Mod10k. Optionally signed.
  • (s)m — 64-bit Mod10k. Optionally signed.

From libmodbus documentation:

chmod +x ./autogen.sh ./autogen.sh ./configure make install 

May need to do this depending on distribution

cp src/.libs/libmodbus.so* /usr/lib/ ln -s -f /usr/lib/libmodbus.so.5.1.0 /usr/lib/libmodbus.so.5 ln -s -f /usr/lib/libmodbus.so.5.1.0 /usr/lib/libmodbus.so 
gcc modbus-client.c -o modbus-client `pkg-config --libs --cflags libmodbus` 
gcc inih/ini.c modbus-server.c -o modbus-server -std=gnu99 `mysql_config --cflags --libs` `pkg-config --libs --cflags libmodbus` cp modbus-server /usr/bin/ 

Make sure mysql is installed with libmysqlclient-dev

Читайте также:  Чистка логов astra linux

Choose a database and create the following table

CREATE TABLE IF NOT EXISTS `modbusServer` ( `id` int(11) NOT NULL AUTO_INCREMENT, `regType` int(11) NOT NULL, `address` int(11) NOT NULL, `val` int(11) NOT NULL DEFAULT '0', `modifiedCount` int(11) NOT NULL DEFAULT '0', `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY (`regType`), KEY (`address`), UNIQUE KEY (`regType`, `address`) ) ENGINE=InnoDB; 

Copy ini to /etc and fill in mysql information. Mysql user should have read/write access

Optionally install modbus-server as a service

Install runit and execute the following commands

mkdir -p /etc/sv/modbus-server/log mkdir /var/log/modbus-server cat > /etc/sv/modbus-server/run &1 EOM cat > /etc/sv/modbus-server/log/run  

About

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A Modbus TCP communication CLI and web server

License

3kyro/modbus-client

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Modbus Client is an interactive Modbus communication tool. Modbus Client can be used as:

    A command line interactive repl. The repl can be started using the -r command line flag. The following command will start a repl connected to a Modbus TCP server listening to IP address 192.168.1.2 and Port 502

> modbus-client -r --TCP --ip 192.168.2.1 --port 502
> modbus-client -t --TCP --ip 192.168.2.1 --port 502 --i input.csv -o output.csv

For more information on availiable commands and options, use the -h, --help flags

Modbus Client uses a registers table format to make working with multiple registers easier.

The registers table is a colon seperated csv file. You can find a sample table in the in the installation folder called sample.csv .

The following raw csv file

Name;Register Type;Register Address;Data Type;Data Value;Unit Id;Description status;input register;10;Word;1;1;0 = device is stopped, 1 = device is running command;holding register;10;Word;0;1;0 = stop device, 1 = start device setpoint;holding register;15;Float;;1;power setpoint temperature;input register;20;Double;35.2;1;device temperature alarms;input register;22;Bits;0001100100110101;1;alarms 

corresponds to the register table below:

Name Register Type Register Address Data Type Data Value Unit Id Description
status Input Register 10 Word 1 0 = device is stopped, 1 = device is running
command Holding Register 10 Word 1 1 0 = stop device, 1 = start device
setpoint Holding Register 15 Float 3.14 1 power setpoint
temperature Input Register 20 Double 1 device temperature
alarms Input Register 22 Bits 1 device alarms

The first line of a registers table csv file is always ignored and is only used as column header information. Each subsequent row is parsed by Modbus Client using the parsing rules described below:

The name field serves as an identifier for the register. The following naming rules apply:

  • A name field cannot start with a numeric value
  • No special characters are allowed, except an underscore "_"
  • Only uppercase or lowercase alphabetic ASCII characters are allowed

Capitalization is ignored when parsing the register type field, eg INPUT REGISTER and input register are both valid fields.

For more information on Modbus register types see the Modbus Application Protocol

Modbus protocol based address for the register. In the case of registers with multiple addresses (eg Float or Double) the address field defines the lowest address.

  • Word : A 16-bit Word
  • Float : A 32-bit floating point number (2 words)
  • Double : A 64-bit floating point number (4 words)

Capitalization is ignored when parsing the data type field, eg Word , word and WORD are valid fields.

For word ordering on types with more than one word represenatation, see Word Ordering

Initial value for a register. The field can be left empty. Only usefull when defining default values. When reading registers, this value will be overwritten, so keeping the field empty is usually sufficient.

Unit Id of the Modbus Server assigned to the register.

Description of the register. Cannot contain line breaks or a colon character (;).

Word order defines the order of input words for data values that require multiple words for thei represenatation (eg. Float Word). According to the Modbus Application Protocol:

MODBUS uses a ‘big-Endian’ representation for addresses and data items. This means that when a numerical quantity larger than a single byte is transmitted, the most significant byte is sent first.

Conforming to this requirement, Modbus Client always uses a 'big-endian' representaion for the 16-bit word type. In order to allow for some flexibility, for data values requiring more than one word value, a choice between 'little-endian' and 'big-endian' representation can be made.

Four word values layout out in four input registers as follows:

Word Address 0 1 2 3
Word 0x01 0x23 0x45 0x67

will be interpreted as a Double value:

Modbus-Client is an open source project. You can download and built the project at the source repository.

To build Modbus Client on Linux and Windows you will need the following tools installed:

  • The Haskell Tool Stack - version >=2.5.1
  • Elm - version 0.19.1
  • Rust - version >= 1.47.0 . Only for building the Modbus test server
  • NSIS. Only for building Modbus Client on Windows. You will need to add the NSIS folder to your path after installation

You can use the provided build.hs script to build Modbus Client backend and frontend along with a Modbus test server, as well as Linux and Windows installers. The script can only be run inside the application's root folder.

Источник

Оцените статью
Adblock
detector