conson-xp 1.0.1__py3-none-any.whl → 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: conson-xp
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: XP Protocol Communication Tools
5
5
  Author-Email: ldvchosal <ldvchosal@github.com>
6
6
  License: MIT License
@@ -1,8 +1,8 @@
1
- conson_xp-1.0.1.dist-info/METADATA,sha256=wo_NyCrK54bsHkSF0LihKlfeDtxR02DHb8ONbd-Wv_I,9296
2
- conson_xp-1.0.1.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
- conson_xp-1.0.1.dist-info/entry_points.txt,sha256=1OcdIcDM1hz3ljCXgybaPUh1IOFEwkaTgLIW9u9zGeg,50
4
- conson_xp-1.0.1.dist-info/licenses/LICENSE,sha256=rxj6woMM-r3YCyGq_UHFtbh7kHTAJgrccH6O-33IDE4,1419
5
- xp/__init__.py,sha256=vAQhsuRRkcqth5YA78Q1OHLSN5KKxSPyl7s7tokrbis,175
1
+ conson_xp-1.1.0.dist-info/METADATA,sha256=KNX3bIZASGxhb2Jhka3QNunZP3mYShzXHmoq1KwMMJ8,9296
2
+ conson_xp-1.1.0.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
+ conson_xp-1.1.0.dist-info/entry_points.txt,sha256=1OcdIcDM1hz3ljCXgybaPUh1IOFEwkaTgLIW9u9zGeg,50
4
+ conson_xp-1.1.0.dist-info/licenses/LICENSE,sha256=rxj6woMM-r3YCyGq_UHFtbh7kHTAJgrccH6O-33IDE4,1419
5
+ xp/__init__.py,sha256=xf8lEjT8dAYyPp5o_Owqe-WYUCt94T7RPlhhUrh5Tr0,175
6
6
  xp/api/__init__.py,sha256=fCWjkuTzDlyJ8hIpU_QEBNcah3BB2bqVSfZwmP4ee5k,51
7
7
  xp/api/main.py,sha256=8OMXUYKnpsqjjnLChokC_M0DXZy-whrxY2dU4QTvr8A,3389
8
8
  xp/api/models/__init__.py,sha256=Xl8j2qiHc-Vb8b1ZmNZaMj7RtMvk0G_2SOvMgQumYzs,54
@@ -35,7 +35,7 @@ xp/cli/commands/conbus/conbus_msactiontable_commands.py,sha256=n1g-ZKjjjbCQqTPGC
35
35
  xp/cli/commands/conbus/conbus_output_commands.py,sha256=Y98-ibcgGB_L52VtczyJqtkGLKESzZjeGvwdLdwM35E,3900
36
36
  xp/cli/commands/conbus/conbus_raw_commands.py,sha256=NRST1cg9tO7zVUwiTKqCBpwfwP1-yvnKTDrwwIMaz68,1572
37
37
  xp/cli/commands/conbus/conbus_receive_commands.py,sha256=jV5zAmiIKK3_oDpTs9yF1YklIRcJNvOrkI6O2deb1eQ,1380
38
- xp/cli/commands/conbus/conbus_scan_commands.py,sha256=HjZMhU1hPRuUSWMURB9UUeZt8aNMDlBYCktwrXUgsCY,4190
38
+ xp/cli/commands/conbus/conbus_scan_commands.py,sha256=5SeRL-RZaXkqgKEGA4wt9zayS8GHiPU3yMHBb1kNfj8,1329
39
39
  xp/cli/commands/file_commands.py,sha256=YEkho5HU5-SEVqTKKWoYPYXI0qWDr9PZaAuEt8fIXak,4855
40
40
  xp/cli/commands/homekit/__init__.py,sha256=qqwY8ulxTx1S74Mzpb6EKjBLT6fWTNdf9PQ3HKuERKY,50
41
41
  xp/cli/commands/homekit/homekit.py,sha256=EOaGvXybNlxYxRr4gtml7OtRWbOIV5wVaYfMrpIFJk4,3355
@@ -133,7 +133,7 @@ xp/services/conbus/conbus_linknumber_set_service.py,sha256=cmCP8zZ8Szb-vwYHvDbZU
133
133
  xp/services/conbus/conbus_output_service.py,sha256=w2yBeMdZn3g3wbwUoUnv3gKbqUuGcabeEaH8qw1AyUs,6689
134
134
  xp/services/conbus/conbus_raw_service.py,sha256=riANTAiXTdSzOWbp_g-IQjdRhAf8CzZnNJtlT-aDvRs,3746
135
135
  xp/services/conbus/conbus_receive_service.py,sha256=k6hzxh-D4piizb3e5Vsz-2Mfft_5KnAXoov4xk9wVY0,3123
136
- xp/services/conbus/conbus_scan_service.py,sha256=ODKXqD84aSkT6z_B7KHolUx2o5yuLP0gpTCAR-UoHOk,4505
136
+ xp/services/conbus/conbus_scan_service.py,sha256=faiSeaNGYRPb9qWsmFE4cjiz3Tkv6vQVZHdwIlPzU9s,4494
137
137
  xp/services/homekit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
138
138
  xp/services/homekit/homekit_cache_service.py,sha256=XMZBTz2ZVTq8OZM3h0Fxu738XPlPRdvq6JLaWMbAS4Q,10289
139
139
  xp/services/homekit/homekit_conbus_service.py,sha256=71JeM-phBTiGMRr2bEfCiF85eHNIzmxtkCi2Zn0B5uA,2595
@@ -151,7 +151,7 @@ xp/services/homekit/homekit_service.py,sha256=yksnbcqbrckxWTqtJkaaPh_wd2xYH9yCOt
151
151
  xp/services/log_file_service.py,sha256=E2CSVbw5W_uk13efILb6OGqeERbxCBWjIsCbHjeps_0,10401
152
152
  xp/services/module_type_service.py,sha256=Q3TFZdiknF24OqGAP6Op1F8_SL8aslkHwPh6o_M7wxM,7010
153
153
  xp/services/protocol/__init__.py,sha256=XUj54if_nJTfqrEDZfj40nfLr-2xjfKm4CIgHMabp-o,719
154
- xp/services/protocol/conbus_protocol.py,sha256=GKmEB4hXAJO4sr3QHfhS_zF-J5BqV3Yi7QNexeSfzLg,7610
154
+ xp/services/protocol/conbus_protocol.py,sha256=ePDP3O-xmEFROaOJ-2ndSUpN0TMrVGhodWT66spfdlE,7676
155
155
  xp/services/protocol/protocol_factory.py,sha256=c3CkMoWAuk9lmHdXIG51B5-S0aIaB7-mHuyULyr_jS4,1248
156
156
  xp/services/protocol/telegram_protocol.py,sha256=4mybR5gFreN_Kxw04fujt1gKIvr3Mg6O_6WwoTXe2i8,8568
157
157
  xp/services/reverse_proxy_service.py,sha256=OIPm-9y2I-xf1tESZBfgiLd_hgfGQdgrsxAFdhotmJ0,13231
@@ -178,4 +178,4 @@ xp/utils/dependencies.py,sha256=PbdI30ug3JCNn1IS9B1jGDEq5wQ_3hDrTLE2Pr-f7AA,1960
178
178
  xp/utils/event_helper.py,sha256=W-A_xmoXlpWZBbJH6qdaN50o3-XrwFsDgvAGMJDiAgo,1001
179
179
  xp/utils/serialization.py,sha256=hZcrpzaBOe3a2wS_RFCIRs9PvnYsrbK7Ulq6s1rU0q4,4456
180
180
  xp/utils/time_utils.py,sha256=Yi3JxHrHsd9ZZxTBRIqlTOz1FYTCeE1IZbefDaXIop8,3800
181
- conson_xp-1.0.1.dist-info/RECORD,,
181
+ conson_xp-1.1.0.dist-info/RECORD,,
xp/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  """conson-xp"""
4
4
 
5
- __version__ = "1.0.1"
5
+ __version__ = "1.1.0"
6
6
  __manufacturer__ = "salchichon"
7
7
  __model__ = "xp.cli"
8
8
  __serial__ = "2025.09.23.000"
@@ -1,7 +1,6 @@
1
1
  """Conbus client operations CLI commands."""
2
2
 
3
3
  import json
4
- import threading
5
4
 
6
5
  import click
7
6
  from click import Context
@@ -16,18 +15,9 @@ from xp.services.conbus.conbus_scan_service import ConbusScanService
16
15
  @conbus.command("scan")
17
16
  @click.argument("serial_number", type=SERIAL)
18
17
  @click.argument("function_code", type=str)
19
- @click.option(
20
- "--background",
21
- "-b",
22
- default=True,
23
- is_flag=True,
24
- help="Run scan in background with live output",
25
- )
26
18
  @click.pass_context
27
19
  @connection_command()
28
- def scan_module(
29
- ctx: Context, serial_number: str, function_code: str, background: bool
30
- ) -> None:
20
+ def scan_module(ctx: Context, serial_number: str, function_code: str) -> None:
31
21
  """
32
22
  Scan all datapoints of a function_code for a module.
33
23
 
@@ -36,90 +26,20 @@ def scan_module(
36
26
  \b
37
27
  xp conbus scan 0012345011 02 # Scan all datapoints of function Read data points (02)
38
28
  """
39
- service = ctx.obj.get("container").get_container().resolve(ConbusScanService)
40
-
41
- # Shared state for results collection and live output
42
- results = []
43
- successful_count = 0
44
- failed_count = 0
45
-
46
- def progress_callback(response: ConbusResponse, total: int, count: int) -> None:
47
- nonlocal successful_count, failed_count
48
- results.append(response)
49
-
50
- if count % 10 == 0:
51
- click.echo(f"{count}/{total} datapoints scanned.")
52
-
53
- # Count results for JSON output
54
- if response.success:
55
- successful_count += 1
56
- else:
57
- failed_count += 1
58
-
59
- try:
60
- with service:
61
- if background:
62
- # Background processing
63
-
64
- # Use background scanning with progress callback
65
- scan_complete = threading.Event()
66
-
67
- def background_scan() -> None:
68
- try:
69
- service.scan_module(
70
- serial_number, function_code, progress_callback
71
- )
72
- except (ValueError, KeyError, ConnectionError):
73
- pass # Will be handled by outer error handling
74
- finally:
75
- scan_complete.set()
76
-
77
- # Start background thread
78
- scan_thread = threading.Thread(target=background_scan, daemon=True)
79
- scan_thread.start()
80
-
81
- # Wait for completion or user interrupt
82
- try:
83
- while not scan_complete.is_set():
84
- scan_complete.wait(1.0) # Check every second
85
- except KeyboardInterrupt:
86
- # Output partial results in JSON format
87
- output = {
88
- "serial_number": serial_number,
89
- "total_scans": len(results),
90
- "successful_scans": successful_count,
91
- "failed_scans": failed_count,
92
- "background_mode": background,
93
- "interrupted": True,
94
- "results": [result.to_dict() for result in results],
95
- }
96
- click.echo(json.dumps(output, indent=2))
97
- raise click.Abort()
98
-
99
- # Wait for thread to complete
100
- scan_thread.join(timeout=1.0)
101
-
102
- else:
103
- # Traditional synchronous scanning
104
- results = service.scan_module(
105
- serial_number,
106
- function_code,
107
- progress_callback,
108
- )
109
- successful_count = len([r for r in results if r.success])
110
- failed_count = len([r for r in results if not r.success])
111
-
112
- # Final output
113
- output = {
114
- "serial_number": serial_number,
115
- "total_scans": len(results),
116
- "successful_scans": successful_count,
117
- "failed_scans": failed_count,
118
- "background_mode": background,
119
- "results": [result.to_dict() for result in results],
120
- }
121
- click.echo(json.dumps(output, indent=2))
122
-
123
- except click.Abort:
124
- # User interrupted the scan
125
- raise
29
+ service: ConbusScanService = (
30
+ ctx.obj.get("container").get_container().resolve(ConbusScanService)
31
+ )
32
+
33
+ def on_progress(progress: str) -> None:
34
+ click.echo(progress)
35
+
36
+ def on_finish(service_response: ConbusResponse) -> None:
37
+ click.echo(json.dumps(service_response.to_dict(), indent=2))
38
+
39
+ with service:
40
+ service.scan_module(
41
+ serial_number=serial_number,
42
+ function_code=function_code,
43
+ progress_callback=on_progress,
44
+ finish_callback=on_finish,
45
+ )
@@ -91,7 +91,7 @@ class ConbusScanService(ConbusProtocol):
91
91
  if self.finish_callback:
92
92
  self.finish_callback(self.service_response)
93
93
 
94
- def scan_module_background(
94
+ def scan_module(
95
95
  self,
96
96
  serial_number: str,
97
97
  function_code: str,
@@ -75,7 +75,7 @@ class ConbusProtocol(protocol.Protocol, protocol.ClientFactory):
75
75
  )
76
76
 
77
77
  self.logger.debug(
78
- f"frameReceived payload: {payload.decode()}, checksum: {checksum}"
78
+ f"frameReceived payload: {payload.decode('latin-1')}, checksum: {checksum}"
79
79
  )
80
80
 
81
81
  # Reset timeout on activity
@@ -83,9 +83,9 @@ class ConbusProtocol(protocol.Protocol, protocol.ClientFactory):
83
83
 
84
84
  telegram_received = TelegramReceivedEvent(
85
85
  protocol=self,
86
- frame=frame.decode(),
87
- telegram=telegram.decode(),
88
- payload=payload.decode(),
86
+ frame=frame.decode("latin-1"),
87
+ telegram=telegram.decode("latin-1"),
88
+ payload=payload.decode("latin-1"),
89
89
  telegram_type=telegram_type,
90
90
  serial_number=serial_number,
91
91
  checksum=checksum,
@@ -112,6 +112,7 @@ class ConbusProtocol(protocol.Protocol, protocol.ClientFactory):
112
112
  self.logger.debug(f"Sending frame: {frame.decode()}")
113
113
  self.transport.write(frame) # type: ignore
114
114
  self.telegram_sent(frame.decode())
115
+ self._reset_timeout()
115
116
 
116
117
  def send_telegram(
117
118
  self,