Giter VIP home page Giter VIP logo

qmodbus's Introduction

QModBus is wrapper over libmodbus for Qt

Note

This class is deprecated. It was developed when Qt did not support the work with the ModBus protocol. Now you should use the standard Qt interface to work with ModBus(Since Qt 5.8):Qt Modbus.

Examples from Qt Documentation

Description

QModBus is abstract C++ class for Qt. QModBus is wrapper over libmodbus for Qt. From this abstract class inherited two specific classes: QModBus_TCP and QModBus_RTU. This class provides the opportunity to work with the library (libmodbus ver 3.1.2) in not blocking mode.

The class has the following public methods:

bool        is_connected() { return connect_done; }
const char *get_strerror() { return strerror; }


void set_slave(int new_slave);
int  get_slave() { return slave; }

void set_response_timeout(uint32_t sec, uint32_t usec);
void get_response_timeout(uint32_t *sec, uint32_t *usec);

The class has the following public signals:

signals:

    void connected();
    void disconnected();
    void error(QModBus::ModBusError error);

    void response_to_read_regs(int status);
    void response_to_write_reg(int status);
    void response_to_write_regs(int status);

The class has the following public slots:

public slots:

    virtual void connect();
    virtual void disconnect();

    virtual void read_regs(int addr, int num_regs, uint16_t *dest);
    virtual void write_reg(int addr, uint16_t value);
    virtual void write_regs(int addr, int num_regs, const uint16_t *data);

The class has the following public enums:

enum ModBusError
{
    NoConnectionError,
    CreateError,
    ConnectionError,
    SetSlaveError,
    ReadRegsError,
    WriteRegError,
    WriteRegsError,

    UnknownError = -1
};

More details see: qmodbus.h


Usage

To start working, perform the following steps:

  1. You need to include qmodbus.h file in your .cpp file.
  2. And add file qmodbus.cpp to list of source files to compile (to qmake project file). (see an example)

Examples

  1. test_tcp - how to work with the class QModBus_TCP

Test_TCP

  1. test_rtu - how to work with the class QModBus_RTU

Test_RTU

Note:

In OS Linux Device for test_rtu is: /dev/tty* default is: /dev/ttyUSB0

In OS Windows Device for test_rtu is: \\.\COM*

Build tests

qmake
make

License

BSD-3-Clause.

Copyright

Copyright (C) 2015 Koynov Stas - [email protected]

qmodbus's People

Contributors

koynovstas avatar

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.