11#!/usr/bin/env python3
2- """Cumulocity IoT Modbus device operation handler"""
2+ """Cumulocity Modbus device operation handler"""
33import logging
44from dataclasses import dataclass
55import requests
@@ -77,12 +77,12 @@ def get_device_from_mapping(target: ModebusDevice, mapping):
7777def parse_arguments (arguments ) -> ModebusDevice :
7878 """Parse operation arguments"""
7979 return ModebusDevice (
80- modbus_type = arguments [2 ], # Only works for TCP.
81- modbus_address = arguments [3 ],
82- child_name = arguments [4 ],
83- modbus_server = arguments [5 ],
84- device_id = arguments [6 ],
85- mapping_path = arguments [7 ],
80+ modbus_type = arguments [0 ],
81+ modbus_address = arguments [1 ],
82+ child_name = arguments [2 ],
83+ modbus_server = arguments [3 ],
84+ device_id = arguments [4 ],
85+ mapping_path = arguments [5 ],
8686 )
8787
8888
@@ -92,12 +92,8 @@ def run(arguments, context: Context):
9292 logger .setLevel (getattr (logging , loglevel .upper (), logging .INFO ))
9393 logger .info ("New c8y_ModbusDevice operation" )
9494 # Check and store arguments
95- if len (arguments ) != 8 :
96- raise ValueError (
97- "Expected 8 arguments in smart rest template. Got "
98- + str (len (arguments ))
99- + "."
100- )
95+ if len (arguments ) != 6 :
96+ raise ValueError ("Expected 6 arguments. Got " + str (len (arguments )) + "." )
10197 config_path = context .config_dir / "devices.toml"
10298 target = parse_arguments (arguments )
10399
0 commit comments