QModbusServer on Raspberry Pi: Address is Protected
-
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!! -
@aniketRoxy said in QModbusServer on Raspberry Pi: Address is Protected:
Address is protected!!
Use a port above 1024. Smaller port numbers require root privileges.
-
@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.
-
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