Skip to content

Python Interface for libmodbus written with CFFI (Python 2 and Python 3)

License

Notifications You must be signed in to change notification settings

marcosgatcomputer/pylibmodbus

 
 

Repository files navigation

pylibmodbus Rpi GPIO

Original code: https://github.com/stephane/pylibmodbus

Changes: Added support to use Raspberry Pi GPIO pins to toggle a Drive Enable / ~ Read Enable signal for RS485 devices that don't have a hardware TX Enable signal.

First install libmodbus from this branch: https://github.com/dhruvvyas90/libmodbus

Configure, compile and install with:

$ ./autogen.sh && ./configure --prefix=/usr && make && sudo make install

Then clone and install pylibmodbus with GPIO support:

$ sudo python setup.py install

Required packages:

  • python-dev and libffi-dev (these can be installed with pip)
  • libmodbus (from https://github.com/dhruvvyas90/libmodbus do NOT install with apt-get)
  • libmodbus-dev (original package, it can be installed with sudo aptg-get install libmodbus-dev)

Licensed under BSD 3-Clause (see LICENSE file for details).

Tests

See test.py for a Modbus client basic example

See also wiki for more details on testing the libmodbus library with GPIO support: https://github.com/marcosgatcomputer/pylibmodbus/wiki/Libmodbus-tests-with-Raspberry-Pi-server---Pocket-Chip-Client

Background

See https://stackoverflow.com/questions/56036578/pymodbus-read-input-register-of-energy-meter-over-rs485-on-uart-of-raspberry-p/

About

Python Interface for libmodbus written with CFFI (Python 2 and Python 3)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Roff 54.8%
  • Shell 26.5%
  • C 10.1%
  • Makefile 7.8%
  • Python 0.4%
  • M4 0.2%
  • Other 0.2%