Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. QtonPi
  4. QModbusServer on Raspberry Pi: Address is Protected
QtWS25 Last Chance

QModbusServer on Raspberry Pi: Address is Protected

Scheduled Pinned Locked Moved Solved QtonPi
raspberry pi 3modbusserver
4 Posts 3 Posters 1.6k Views
  • 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.
  • aniketRoxyA Offline
    aniketRoxyA Offline
    aniketRoxy
    wrote on last edited by
    #1

    Hi,
    I have created QModbusServer (TCP) in my application.
    Following code is for create tcp modbus server.

    const QUrl url = QUrl::fromUserInput("127.0.0.1:502");
    modbusDevice->setConnectionParameter(QModbusDevice::NetworkAddressParameter, url.host());```
    modbusDevice->setConnectionParameter(QModbusDevice::NetworkPortParameter, url.port());
    modbusDevice->setServerAddress(1);
    

    When I tried to run on raspberry pi, It shows an error.
    Address is protected!!

    Aniket Gadekar

    jsulmJ KroMignonK 2 Replies Last reply
    0
    • aniketRoxyA aniketRoxy

      Hi,
      I have created QModbusServer (TCP) in my application.
      Following code is for create tcp modbus server.

      const QUrl url = QUrl::fromUserInput("127.0.0.1:502");
      modbusDevice->setConnectionParameter(QModbusDevice::NetworkAddressParameter, url.host());```
      modbusDevice->setConnectionParameter(QModbusDevice::NetworkPortParameter, url.port());
      modbusDevice->setServerAddress(1);
      

      When I tried to run on raspberry pi, It shows an error.
      Address is protected!!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @aniketRoxy said in QModbusServer on Raspberry Pi: Address is Protected:

      Address is protected!!

      Use a port above 1024. Smaller port numbers require root privileges.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • aniketRoxyA aniketRoxy

        Hi,
        I have created QModbusServer (TCP) in my application.
        Following code is for create tcp modbus server.

        const QUrl url = QUrl::fromUserInput("127.0.0.1:502");
        modbusDevice->setConnectionParameter(QModbusDevice::NetworkAddressParameter, url.host());```
        modbusDevice->setConnectionParameter(QModbusDevice::NetworkPortParameter, url.port());
        modbusDevice->setServerAddress(1);
        

        When I tried to run on raspberry pi, It shows an error.
        Address is protected!!

        KroMignonK Offline
        KroMignonK Offline
        KroMignon
        wrote on last edited by
        #3

        @aniketRoxy said in QModbusServer on Raspberry Pi: Address is Protected:

        When I tried to run on raspberry pi, It shows an error.

        On Linux system ports below 1024 are "privileged ports" and requires super user rights (root).

        ==> if you need to use port 502, you have to run as root.

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        1 Reply Last reply
        2
        • aniketRoxyA Offline
          aniketRoxyA Offline
          aniketRoxy
          wrote on last edited by
          #4

          Thank you @jsulm & @KroMignon !!
          :)

          Ports 0-1024 are "protected" for "known" services and By "protected", they must be used by system daemons. Thus, a regular user cannot start them.

          Solution 1:
          Run application using terminal:

          sudo \path\to\app
          

          Solution 2:
          Use a port above 1024
          So i changed port from 502 to 1502:

          const QUrl url = QUrl::fromUserInput("127.0.0.1:1502");
          

          Working now!!
          <3 Qt

          Aniket Gadekar

          1 Reply Last reply
          2

          • Login

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