From 35984a6e6b8cebba7cd3ca861d1feb5c7b8bcb50 Mon Sep 17 00:00:00 2001 From: Stefan Scherzinger Date: Fri, 19 Jul 2024 11:20:44 +0200 Subject: [PATCH] Update system parameters Also support comments in the `system_parameter_codes` file when reading system parameters from hardware. --- .flake8 | 3 ++ schunk_egu_egk_gripper_dummy/config/data.json | 23 ++++++++---- schunk_egu_egk_gripper_dummy/config/enum.json | 36 ++++++++++++++++++- .../config/read_system_parameters.py | 7 ++++ .../config/system_parameter_codes | 9 +++-- 5 files changed, 67 insertions(+), 11 deletions(-) diff --git a/.flake8 b/.flake8 index f578405..f40261f 100644 --- a/.flake8 +++ b/.flake8 @@ -2,3 +2,6 @@ [flake8] # Use black's line length (default 88) instead of the flake8 default of 79: max-line-length = 88 + +per-file-ignores = + schunk_egu_egk_gripper_dummy/*.py:E203 diff --git a/schunk_egu_egk_gripper_dummy/config/data.json b/schunk_egu_egk_gripper_dummy/config/data.json index f34d7a9..6f6eabe 100644 --- a/schunk_egu_egk_gripper_dummy/config/data.json +++ b/schunk_egu_egk_gripper_dummy/config/data.json @@ -1,6 +1,6 @@ { "0x0040": [ - "210000800000A2800000000000000000" + "800000800000A25800000000000000EF" ], "0x0048": [ "05000000000000000000000000000000" @@ -9,7 +9,7 @@ "0000" ], "0x0118": [ - "00" + "EF" ], "0x0120": [ "00" @@ -18,10 +18,13 @@ "001F" ], "0x0130": [ - "3238333A34303A3534203C307837323E206C6F67696320766F6C746167652031362E343336203C2031392E3230302056202876616C75655F6D6F6E69746F722E6370703A3A32312900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "3238343A32363A3532203C307846343E206D6F766520626C6F636B6564206F6363757272656420696E2063757272656E74207374617465203420286170706C69636174696F6E5F73746174655F6D616368696E652E683A3A313334392900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ], + "0x0210": [ + "00000000" ], "0x0230": [ - "4226667D" + "42263D87" ], "0x0238": [ "00000000" @@ -102,10 +105,10 @@ "42AA0000" ], "0x0840": [ - "41F5DC60" + "421EAE6D" ], "0x0870": [ - "41BA7D40" + "41BA5871" ], "0x0878": [ "41C04897" @@ -149,6 +152,12 @@ "0x1118": [ "352E322E302E38313839360000000000000000000000" ], + "0x1120": [ + "322E312E3100000000000000" + ], + "0x1130": [ + "01" + ], "0x1138": [ "0030114844C7" ], @@ -156,6 +165,6 @@ "01" ], "0x1400": [ - "00000080" + "00000A69" ] } diff --git a/schunk_egu_egk_gripper_dummy/config/enum.json b/schunk_egu_egk_gripper_dummy/config/enum.json index faa406e..8fe8663 100644 --- a/schunk_egu_egk_gripper_dummy/config/enum.json +++ b/schunk_egu_egk_gripper_dummy/config/enum.json @@ -1013,7 +1013,7 @@ "string": "ERR_SW_COMM" } ], - "0x120": [ + "0x0120": [ { "value": 0, "string": "ERR_NONE" @@ -2140,5 +2140,39 @@ "value": 27, "string": "EGU_80_M_SD" } + ], + "0x1130": [ + { + "value": 0, + "string": "UNKNOWN" + }, + { + "value": 1, + "string": "PROFINET" + }, + { + "value": 2, + "string": "EtherNet/IP (TM)" + }, + { + "value": 3, + "string": "EtherCAT" + }, + { + "value": 4, + "string": "Modbus TCP" + }, + { + "value": 5, + "string": "Common Ethernet" + }, + { + "value": 6, + "string": "IOLink" + }, + { + "value": 7, + "string": "Modbus RTU" + } ] } diff --git a/schunk_egu_egk_gripper_dummy/config/read_system_parameters.py b/schunk_egu_egk_gripper_dummy/config/read_system_parameters.py index 302d282..dd73ef4 100755 --- a/schunk_egu_egk_gripper_dummy/config/read_system_parameters.py +++ b/schunk_egu_egk_gripper_dummy/config/read_system_parameters.py @@ -17,9 +17,16 @@ def read_parameter_codes(filepath: str) -> list[str]: def contains_hex(line: str) -> bool: return True if "0x" in line and line[0] != "#" else False + def remove_comments(line: str) -> str: + if line.find("#") != -1: + line = line[0 : line.find("#")] + line = line.strip() + return line + with open(filepath, "r") as f: lines = f.read().split("\n") lines = list(filter(contains_hex, lines)) + lines = list(map(remove_comments, lines)) return lines diff --git a/schunk_egu_egk_gripper_dummy/config/system_parameter_codes b/schunk_egu_egk_gripper_dummy/config/system_parameter_codes index 446e853..0b38c21 100644 --- a/schunk_egu_egk_gripper_dummy/config/system_parameter_codes +++ b/schunk_egu_egk_gripper_dummy/config/system_parameter_codes @@ -6,17 +6,18 @@ 0x0040 0x0048 0x0100 -0x0118 -0x0120 +0x0118 # enum +0x0120 # enum 0x0128 0x0130 +0x0210 0x0230 0x0238 0x0380 0x03A8 0x03B0 0x03B8 -0x0500 +0x0500 # enum 0x0528 0x0540 0x0580 @@ -53,6 +54,8 @@ 0x1108 0x1110 0x1118 +0x1120 +0x1130 # enum 0x1138 0x1330 0x1400