Giter Club home page Giter Club logo

libmodbus's Introduction

Raspberry Pi fork of libmodbus with GPIO rx-tx functionality with RS485 chips or similar

When it should be used :

If you're using an UART to RS485 conversion chip like 75176 or anything similar and using one of the RPi GPIO to switch rx - tx functionality of the chip.

In addition to standard libmodbus API, addtional APIs are included to support GPIO based rx-tx switching

Additional APIs :

  • modbus_enable_rpi : Sets an enable Rpi integer in ctx data structure.
  • modbus_configure_rpi_bcm_pin : Configures GPIO BCM pin to be used for rx-tx switching (if the RE and DE are the same)
  • modbus_configure_rpi_bcm_pins : Configures GPIO BCM pins (RE & DE) to be used for rx-tx switching (if the RE and DE are not on the same pin)
  • modbus_rpi_pin_export_direction : export configured GPIO, configures it as an output.
  • modbus_rpi_pin_unexport_direction : unexport configured GPIO, configures it as an input.

Usage :

While initializing :

  • modbus_enable_rpi(ctx);
  • modbus_configure_rpi_bcm_pin(ctx,18); // configures BCM pin # 18 for DE & RE used for switching
  • modbus_configure_rpi_bcm_pins(ctx,17,18); // configures BCM pin # 17 for DE and # 18 for RE used for switching
  • modbus_rpi_pin_export_direction(ctx); // exports configured BCM pin #

While clean up :

  • modbus_rpi_pin_unexport_direction(ctx); //unexport configured BCM pin #

Examples

See test.c in rpi-test folder for template.

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.