Giter Site home page Giter Site logo

device-modbus's Introduction

NAME Device-Modbus version 0.022

This distribution aims towards implementing Modbus communications in Perl. It makes it possible to write Modbus TCP and RTU clients and servers. Please refer to Device::Modbus::RTU and Device::Modbus::TCP for the client and server implementations.

More information

You will find examples and further discussions over my blog, at http://www.7mavida.com/tag/Device::Modbus

INSTALLATION

To install this module type the following:

perl Makefile.PL
make
make test
make install

DEPENDENCIES

The only requirement for the base Device::Modbus is Try::Tiny. The RTU and TCP variants have other requirements of their own, most notably Device::SerialPort for Device::Modbus::RTU and Net::Server for Modbus TCP.

SEE ALSO

The main documentation for the distribution is in Device::Modbus. Please see Device::Modbus::RTU and Device::Modbus::TCP for serial or TCP/IP based communications.

I am working on an asynchronous server for Modbus TCP. It is not yet ready for CPAN, but you can find it in GitHub, https://github.com/jfraire/AnyEvent-Modbus-Server.

In Perl, you can find other Modbus related distributions. I think the leading one would be Protocol::Modbus, by Cossimo, which implements Modbus TCP clients. While there is code for RTU clients, it is not as mature.

There are also some scripts that implement both a server and clients. A couple worth looking at is formed by MBclient and mbserved. The later is available in GitHub only and they were both written by the same author, l.lefebre https://github.com/sourceperl.

COPYRIGHT AND LICENCE

Copyright (C) 2015-2016 by Julio Fraire

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.

device-modbus's People

Contributors

jfraire avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rage311

device-modbus's Issues

modbus function 4 not consistent values

Here is another simple example how I read values from one device with different results

root@raspberrypi:/opt/kronometrix/bin# ./rs485rec_2
^@Unit number is invalid at /opt/kronometrix/perl/lib/site_perl/5.20.3/Device/Modbus/RTU.pm line 105.
root@raspberrypi:/opt/kronometrix/bin# ./rs485rec_2
<-$VAR1 = bless( {
                 'unit' => 1,
                 'crc' => 22239,
                 'message' => bless( {
                                       'values' => [
                                                     17386,
                                                     32768,
                                                     16553,
                                                     39322,
                                                     16834,
                                                     26214,
                                                     16916,
                                                     26214,
                                                     469,
                                                     53,
                                                     243,
                                                     371
                                                   ],
                                       'code' => 4,
                                       'bytes' => 24,
                                       'function' => 'Read Input Registers'
                                     }, 'Device::Modbus::Response' )
               }, 'Device::Modbus::RTU::ADU' );

Raspberry Pi support

Im planning to build a Raspberry Pi as a modbus server. I have some questions, maybe you can help me, please:

  • how big, as disk footprint, is Device::Modbus including all dependencies ?
  • do I need to install ibmodbus5 libmodbus-dev in order to use Device::Modbus, or your module is a pure Perl module ?
  • do I really need Net::Server to have support for modbus server side ?
  • do I really need Moo ?

Thanks

default speed breaking up RBPI Tongdy IAQ

Im not sure I do understand yet but I see the following, if I set in my client the device default speed, 19200 my client almost never succeeds in getting any values from the device, but rather some sporadic errors:

  • Unimplemented function: <0> at /opt/kronometrix/bin/rs485rec line 24.

If I set on my client 9600, Im starting to see light:

$VAR1 = bless( {
                 'crc' => 57400,
                 'unit' => 1,
                 'message' => bless( {
                                       'function' => 'Read Input Registers',
                                       'bytes' => 24,
                                       'values' => [
                                                     17360,
                                                     0,
                                                     16585,
                                                     39322,
                                                     16859,
                                                     13107,
                                                     16901,
                                                     39322,
                                                     416,
                                                     63,
                                                     274,
                                                     334
                                                   ],
                                       'code' => 4
                                     }, 'Device::Modbus::Response' )
               }, 'Device::Modbus::RTU::ADU' );

modbus function 3 not consistent values

When trying to read data from an IAQ senzor, Im getting these, different results, all the time. Sometimes it does work, sometimes not.

root@raspberrypi:/opt/kronometrix/bin# ./rs485rec_2
<-$VAR1 = bless( {
                 'message' => bless( {
                                       'values' => [
                                                     1,
                                                     4,
                                                     1,
                                                     49152,
                                                     0,
                                                     0,
                                                     0,
                                                     16752,
                                                     0,
                                                     0,
                                                     1,
                                                     0,
                                                     0,
                                                     16968,
                                                     0,
                                                     0,
                                                     0,
                                                     17096,
                                                     0,
                                                     0,
                                                     0,
                                                     16880,
                                                     0,
                                                     0,
                                                     5000
                                                   ],
                                       'bytes' => 50,
                                       'function' => 'Read Holding Registers',
                                       'code' => 3
                                     }, 'Device::Modbus::Response' ),
                 'unit' => 1,
                 'crc' => 40150
               }, 'Device::Modbus::RTU::ADU' );
root@raspberrypi:/opt/kronometrix/bin# ./rs485rec_2
Unimplemented function: <0> at ./rs485rec_2 line 25.
root@raspberrypi:/opt/kronometrix/bin# ./rs485rec_2
^@Unit number is invalid at /opt/kronometrix/perl/lib/site_perl/5.20.3/Device/Modbus/RTU.pm line 105.

reading data from Tongdy IAQ very slow

We are experimenting with a MODBUS device, for Indoor Air Quality. The device works nice and supports MODBUS RTU.

For some reason it takes forever until I see some values back from this device on screen. Not sure why.
Can I somehow put a debug on the RTU line and see more about whats happening within ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.