Open main menu

DAVE Developer's Wiki β

Changes

no edit summary
===Enabling the connection to the PLC===
As described in MISC-TN-024, the PLC we want to talk to is connected to a different subnet, namely 192.168.30.0/24. For testing the connection to the PLC, after adding the required subnet configuration, the <code>modbus</code> command line tool was used, which is provided by the <code>modbus_cli</code> package. In the following example, the register mapped ad the address 300 is read.
<pre class="board-terminal">
</pre>
We then configured Fledge in order to read periodically a couple of PLC's registers. Please note that this is a no-code operation as it is carried out with the help of the native web-based Fledge UI. To access PLC exposed data, the Fledge's modbustcp plugin was used. Please note that also we had to patch it manually to solve a bug that prevented it from working properly. The patch is detailed [https://github.com/fledge-iot/fledge-south-modbustcp/pull/26/files here].
 
 
 
Riavviare south plugin disable/enable per via grafica.
Processing triggers for libc-bin (2.31-13+deb11u5) ...
 
armbian@sbcspg:~/devel/fledge$ pip install modbus_cli
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: modbus_cli in /home/armbian/.local/lib/python3.9/site-packages (0.1.8)
Requirement already satisfied: colorama in /home/armbian/.local/lib/python3.9/site-packages (from modbus_cli) (0.4.6)
Requirement already satisfied: umodbus in /home/armbian/.local/lib/python3.9/site-packages (from modbus_cli) (1.0.4)
Requirement already satisfied: pyserial~=3.4 in /usr/local/lib/python3.9/dist-packages (from umodbus->modbus_cli) (3.5)
 
[notice] A new release of pip is available: 23.0 -> 23.0.1
[notice] To update, run: python3 -m pip install --upgrade pip
armbian@sbcspg:~/devel/fledge$ ./.local/bin/modbus 192.168.30.42:502 300 Parsed 0 registers definitions from 1 files 300: 33 0x21^C
armbian@sbcspg:~/devel/fledge$ cd
armbian@sbcspg:~$ ./.local/bin/modbus 192.168.30.42:502 300 Parsed 0 registers definitions from 1 files 300: 33 0x21
Parsed 0 registers definitions from 1 files
0: 0 0x0
1: 256 0x100
33: 0 0x0
300: 34 0x22
Traceback (most recent call last):
File "/home/armbian/./.local/bin/modbus", line 109, in <module>
main()
File "/home/armbian/./.local/bin/modbus", line 102, in main
connect_to_device(args).perform_accesses(parse_accesses(args.access, definitions, args.byte_order), definitions).close()
File "/home/armbian/.local/lib/python3.9/site-packages/modbus_cli/modbus_tcp.py", line 64, in perform_accesses
access.print_values(definitions)
File "/home/armbian/.local/lib/python3.9/site-packages/modbus_cli/access.py", line 83, in print_values
logging.info('{}: {} {}'.format(label, value, self.present_value(value, presenter, definitions)))
File "/home/armbian/.local/lib/python3.9/site-packages/modbus_cli/access.py", line 93, in present_value
presentation.append(definitions.presenters[presenter][value])
KeyError: ':'
^C
 
 
https://github.com/fledge-iot/fledge-south-modbustcp/pull/26/files
Riavviare south plugin disable/enable per via grafica.
4,650
edits