Hello community,
I’m struggling since days to get a new power meter connected to OpenHAB running on my Raspi with ModBus binding. When activating the relevant things, I get in the log:
Could not get port identifier, maybe insufficient permissions.
To exclude HW or permission issues, I installed mbpoll on a second SD-Card after taking a fresh backup of the original and there the communication works. Meanwhile I’m lost and have no further clue to get it running. Any help would be highly appreciated.
My used setup:
- Hardware: Raspberry Pi4 with an RS485 USB dongle
- running serial communication on RS232 extention on GPIO14/15
- OS: latest openHABian
- Java openjdk version “11.0.12” (I did not change)
- openHAB version: 3.3
- SDM72DM-V2 power meter
Used thing configuration - no items defined so far:
Bridge modbus:serial:powermeter [ port="/dev/ttyUSB-RS485" ,id=1 , baud=9600, stopBits="1.0", parity="none", dataBits=8, encoding="rtu" ]{
Bridge poller inputRegisters [ start=0, length=4, refresh=30000, type="input" ] {
Thing data input1 [ readStart="0", readValueType="float32" ]
Thing data input2 [ readStart="2", readValueType="float32" ]
}
}
That’s the log I get after activating the things above:
2022-08-29 19:54:09.329 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powermeter.things'
==> /var/log/openhab/events.log <==
2022-08-29 19:54:09.414 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:serial:powermeter' changed from ONLINE to OFFLINE
2022-08-29 19:54:09.417 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:serial:powermeter' changed from OFFLINE to ONLINE
2022-08-29 19:54:09.432 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:powermeter:inputRegisters' changed from UNINITIALIZED to INITIALIZING
2022-08-29 19:54:09.447 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:powermeter:inputRegisters' changed from INITIALIZING to ONLINE
2022-08-29 19:54:09.469 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:powermeter:inputRegisters:input1' changed from UNINITIALIZED to INITIALIZING
==> /var/log/openhab/openhab.log <==
2022-08-29 19:54:09.470 [WARN ] [ing.ModbusSlaveConnectionFactoryImpl] - Connect reached max tries 1, throwing last error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection [m_SerialPort=null, m_Parameters.getPortName()=/dev/ttyUSB-RS485]. Endpoint ModbusSerialSlaveEndpoint [getPortName()=/dev/ttyUSB-RS485]
2022-08-29 19:54:09.472 [WARN ] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection [m_SerialPort=null, m_Parameters.getPortName()=/dev/ttyUSB-RS485] for endpoint ModbusSerialSlaveEndpoint [getPortName()=/dev/ttyUSB-RS485]: Could not get port identifier, maybe insufficient permissions. null
2022-08-29 19:54:09.476 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusSerialSlaveEndpoint [getPortName()=/dev/ttyUSB-RS485] -- aborting request ModbusReadRequestBlueprint [slaveId=1, functionCode=READ_INPUT_REGISTERS, start=0, length=4, maxTries=3] [operation ID d64221f2-0b36-45e2-adae-285ad155d2e8]
==> /var/log/openhab/events.log <==
2022-08-29 19:54:09.484 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:powermeter:inputRegisters' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.exception.ModbusConnectionException: Error connecting to endpoint ModbusSerialSlaveEndpoint [getPortName()=/dev/ttyUSB-RS485]
2022-08-29 19:54:09.490 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:powermeter:inputRegisters:input1' changed from INITIALIZING to ONLINE
2022-08-29 19:54:09.494 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:powermeter:inputRegisters:input2' changed from UNINITIALIZED to INITIALIZING
2022-08-29 19:54:09.502 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:data:powermeter:inputRegisters:input2' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE): No online bridge
==> /var/log/openhab/openhab.log <==
2022-08-29 19:54:15.955 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'powermeter.things'
As mentioned above, I installed mbpoll to check HW and permissions. Details for this tool can be found here if somebody needs it on his own ;-):
https://github.com/epsilonrt/mbpoll
When using mbpoll I get this:
openhabian@openhab:~ $ mbpoll -a 1 -b 9600 -P none -v -1 -t3 -c 2 -r 1 /dev/ttyUSB-RS485
debug enabled
Set function=3
Set number of values=2
Set start reference=1
Set mode to RTU for serial port
Set device=/dev/ttyUSB-RS485
mbpoll 1.4-12 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright © 2015-2019 Pascal JEAN, https://github.com/epsilonrt/mbpoll
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'mbpoll -w' for details.
Opening /dev/ttyUSB-RS485 at 9600 bauds (N, 8, 1)
Set response timeout to 1 sec, 0 us
Protocol configuration: Modbus RTU
Slave configuration...: address = [1]
start reference = 1, count = 2
Communication.........: /dev/ttyUSB-RS485, 9600-8N1
t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table
-- Polling slave 1...
[01][04][00][00][00][02][71][CB]
Waiting for a confirmation...
<01><04><04><43><62><58><FB><35><9D>
[1]: 17250
[2]: 22779
From this test with mbpoll I assume:
- HW and wiring is OK
- Symlink is working fine with ttyUSB-RS485
- configuration 9600 bauds (N, 8, 1) is correct for my power meter
- sufficient privileges for openhabian to communicate with ttyUSB-RS485 should be given
And now as said above, I’m at the end of my wisdom