Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Communication driver multi protocol API
Qt 6.11 is out! See what's new in the release blog

Communication driver multi protocol API

Scheduled Pinned Locked Moved Solved C++ Gurus
4 Posts 3 Posters 1.2k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Francis Chapet
    wrote on last edited by
    #1

    Hello,

    I have to develop some drivers to communicate with industrial machines. These machines use different protocol (ModBus, OpenProtocol, ...) and different interface (Ethernet, RS232, RS422, USB, ...).
    I want to have a common API for my drivers to communicate with these machines.
    I want that because I will have to add a new communication driver to my system to manage a new machine.

    Do you know some examples of open source project or have some codes that can inspire me to solve my problem. Or if you think that my idea is absolutely stupid, please, explain me why and guide me on the good way.

    Thanks.

    1 Reply Last reply
    0
    • Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @Francis-Chapet That's not stupid. That's a common thing. What you need is a common interface from which you inherit in the classes where you implement your communication protocols. Like QAbstract... classes in Qt framework. You can take inspiration of QIODevice which is typically the base of all communication in Qt (QSerialPort, QAbstractSocket, QBuffer, QFileDevice, QLocalSocket, QNetworkReply, QProcess and probably more.. )

      But that's basically always the same thing:

      • open
      • close
      • read
      • write
      • events (ready read, connection state changed,...)
      • setconfig

      For the content of your data, you can use raw data like string or byte array, or a use the same principle of the base interface (abstract class) with specific implementation for each protocol. But as everything is always represented by bits at the end, byte arrays are usually enough to cover all the needs, you can always provide methods in your protocol's classes to convert the data to another format and vice versa.

      F 1 Reply Last reply
      3
      • Gojir4G Gojir4

        @Francis-Chapet That's not stupid. That's a common thing. What you need is a common interface from which you inherit in the classes where you implement your communication protocols. Like QAbstract... classes in Qt framework. You can take inspiration of QIODevice which is typically the base of all communication in Qt (QSerialPort, QAbstractSocket, QBuffer, QFileDevice, QLocalSocket, QNetworkReply, QProcess and probably more.. )

        But that's basically always the same thing:

        • open
        • close
        • read
        • write
        • events (ready read, connection state changed,...)
        • setconfig

        For the content of your data, you can use raw data like string or byte array, or a use the same principle of the base interface (abstract class) with specific implementation for each protocol. But as everything is always represented by bits at the end, byte arrays are usually enough to cover all the needs, you can always provide methods in your protocol's classes to convert the data to another format and vice versa.

        F Offline
        F Offline
        Francis Chapet
        wrote on last edited by
        #3

        @Gojir4 Thank you

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          You might want to check the QtSerialBus module.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved