py-uds-demo 25.0.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.
Potentially problematic release.
This version of py-uds-demo might be problematic. Click here for more details.
- py_uds_demo/__init__.py +0 -0
- py_uds_demo/__main__.py +57 -0
- py_uds_demo/core/__init__.py +0 -0
- py_uds_demo/core/client.py +80 -0
- py_uds_demo/core/server.py +227 -0
- py_uds_demo/core/utils/__init__.py +0 -0
- py_uds_demo/core/utils/helpers.py +314 -0
- py_uds_demo/core/utils/responses.py +55 -0
- py_uds_demo/core/utils/services/__init__.py +0 -0
- py_uds_demo/core/utils/services/data_transmission.py +398 -0
- py_uds_demo/core/utils/services/diagnostic_and_commmunication_management.py +755 -0
- py_uds_demo/core/utils/services/input_output_contol.py +63 -0
- py_uds_demo/core/utils/services/negative_response.py +1 -0
- py_uds_demo/core/utils/services/remote_activation_of_routine.py +80 -0
- py_uds_demo/core/utils/services/stored_data_transmission.py +132 -0
- py_uds_demo/core/utils/services/upload_download.py +189 -0
- py_uds_demo/interface/__init__.py +0 -0
- py_uds_demo/interface/api.py +30 -0
- py_uds_demo/interface/cli.py +51 -0
- py_uds_demo/interface/gui.py +83 -0
- py_uds_demo/interface/web.py +108 -0
- py_uds_demo-25.0.0.dist-info/METADATA +70 -0
- py_uds_demo-25.0.0.dist-info/RECORD +24 -0
- py_uds_demo-25.0.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import socket
|
|
2
|
+
import gradio as gr
|
|
3
|
+
|
|
4
|
+
from py_uds_demo.core.client import UdsClient
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Web:
|
|
8
|
+
"""
|
|
9
|
+
WebUi provides a Gradio-based web interface for interacting with the UDS (Unified Diagnostic Services) simulator.
|
|
10
|
+
|
|
11
|
+
This class manages the UI components, handles user input, processes diagnostic requests, and logs interactions.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self):
|
|
15
|
+
"""
|
|
16
|
+
Initialize the WebUi instance.
|
|
17
|
+
|
|
18
|
+
Sets up the UdsClient and default log file path.
|
|
19
|
+
"""
|
|
20
|
+
self.uds_client = UdsClient()
|
|
21
|
+
self.logger = self.uds_client.server.logger
|
|
22
|
+
|
|
23
|
+
def run(self):
|
|
24
|
+
"""
|
|
25
|
+
Launch the Gradio app for the UDS simulator UI.
|
|
26
|
+
|
|
27
|
+
Initializes the logger and starts the Gradio Blocks interface.
|
|
28
|
+
"""
|
|
29
|
+
uds_sim = gr.Blocks(title="UDS Simulator")
|
|
30
|
+
with uds_sim:
|
|
31
|
+
self.uds_simulator_ui()
|
|
32
|
+
uds_sim.launch(server_name=socket.getfqdn(), server_port=7865, share=False, debug=False)
|
|
33
|
+
|
|
34
|
+
def uds_simulator_ui(self):
|
|
35
|
+
"""
|
|
36
|
+
Build the Gradio UI for the UDS simulator.
|
|
37
|
+
|
|
38
|
+
Sets up the tester present checkbox, chatbot, and diagnostic request textbox.
|
|
39
|
+
"""
|
|
40
|
+
self.tester_present_checkbox = gr.Checkbox(label="tester_present", value=False)
|
|
41
|
+
self.uds_sim_chatbot = gr.Chatbot(type="messages", label="UDS Simulator(Chat Box)", show_label=True, show_copy_all_button=True, layout="bubble", value=[])
|
|
42
|
+
self.diag_req_textbox = gr.Textbox(label="Diagnostic Request", placeholder="Enter diagnostic request in hex format (e.g., 22 F1 87). No need to mention size.", show_label=True)
|
|
43
|
+
self.diag_req_textbox.submit(self.chat_bot_process, [self.diag_req_textbox, self.uds_sim_chatbot], [self.diag_req_textbox, self.uds_sim_chatbot])
|
|
44
|
+
self.tester_present_checkbox.change(self._update_tester_present, [self.tester_present_checkbox])
|
|
45
|
+
|
|
46
|
+
with gr.Row():
|
|
47
|
+
self.help_sid_textbox = gr.Textbox(label="Help with SID", placeholder="Enter SID (e.g., 10)", show_label=True)
|
|
48
|
+
self.help_button = gr.Button(value="Get Help")
|
|
49
|
+
self.help_button.click(self._show_help_callback, [self.help_sid_textbox, self.uds_sim_chatbot], [self.help_sid_textbox, self.uds_sim_chatbot])
|
|
50
|
+
|
|
51
|
+
def _show_help_callback(self, sid_str, chat_history):
|
|
52
|
+
try:
|
|
53
|
+
sid = int(sid_str, 16)
|
|
54
|
+
service = self.uds_client.server.service_map.get(sid)
|
|
55
|
+
if service:
|
|
56
|
+
chat_history.append({"role": "user", "content": f"Help for SID 0x{sid:02X}"})
|
|
57
|
+
chat_history.append({"role": "assistant", "content": service.__doc__})
|
|
58
|
+
else:
|
|
59
|
+
chat_history.append({"role": "user", "content": f"Help for SID 0x{sid:02X}"})
|
|
60
|
+
chat_history.append({"role": "assistant", "content": f"No help found for SID 0x{sid:02X}."})
|
|
61
|
+
except (ValueError, IndexError):
|
|
62
|
+
chat_history.append({"role": "user", "content": f"Help for SID {sid_str}"})
|
|
63
|
+
chat_history.append({"role": "assistant", "content": "Invalid SID. Please enter a valid hex value."})
|
|
64
|
+
return "", chat_history
|
|
65
|
+
|
|
66
|
+
def chat_bot_process(self, diagnostic_request, chat_history):
|
|
67
|
+
"""
|
|
68
|
+
Process user diagnostic request and update chat history.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
diagnostic_request (str): The diagnostic request input by the user in hex string format.
|
|
72
|
+
chat_history (list): The current chat history between user and assistant.
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
tuple: A tuple of (empty string, updated chat_history).
|
|
76
|
+
"""
|
|
77
|
+
diagnostic_request_clean = diagnostic_request.replace(" ", "")
|
|
78
|
+
try:
|
|
79
|
+
diagnostic_request_stream = [int(diagnostic_request_clean[i:i+2], 16) for i in range(0, len(diagnostic_request_clean), 2)]
|
|
80
|
+
user_sent_request = self.uds_client.format_request(diagnostic_request_stream)
|
|
81
|
+
chat_history.append({"role": "user", "content": user_sent_request})
|
|
82
|
+
diagnostic_response = self.uds_client.send_request(diagnostic_request_stream, True)
|
|
83
|
+
chat_history.append({"role": "assistant", "content": diagnostic_response})
|
|
84
|
+
except ValueError:
|
|
85
|
+
chat_history.append({"role": "user", "content": diagnostic_request})
|
|
86
|
+
chat_history.append({"role": "assistant", "content": "Invalid hex input. Please enter a valid hex string."})
|
|
87
|
+
self.logger.warning(f"Invalid Diagnostic Request 💉 {diagnostic_request}")
|
|
88
|
+
except Exception as e:
|
|
89
|
+
chat_history.append({"role": "user", "content": diagnostic_request})
|
|
90
|
+
chat_history.append({"role": "assistant", "content": f"An error occurred while processing the request. {e}"})
|
|
91
|
+
self.logger.error(f"Error occurred while processing request 💉 {diagnostic_request}: {e}")
|
|
92
|
+
finally:
|
|
93
|
+
return "", chat_history
|
|
94
|
+
|
|
95
|
+
def _update_tester_present(self, value: bool):
|
|
96
|
+
"""
|
|
97
|
+
Update the tester present flag in the UDS server and log the action.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
value (bool): True to activate tester present, False to deactivate.
|
|
101
|
+
"""
|
|
102
|
+
self.uds_client.server.diagnostic_session_control.tester_present_active = value
|
|
103
|
+
self.logger.info('tester present [✔️] activated' if value else 'tester present [✖️] deactivated')
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
if __name__ == "__main__":
|
|
107
|
+
web_ui = Web()
|
|
108
|
+
web_ui.run()
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: py-uds-demo
|
|
3
|
+
Version: 25.0.0
|
|
4
|
+
Summary: Learn and Practice UDS Protocol
|
|
5
|
+
Keywords: python,template
|
|
6
|
+
Author: chaitu-ycr
|
|
7
|
+
Author-email: chaitu-ycr <chaitu.ycr@gmail.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 chaitu-ycr
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
Classifier: Programming Language :: Python :: 3
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
32
|
+
Requires-Dist: dearpygui
|
|
33
|
+
Requires-Dist: gradio
|
|
34
|
+
Requires-Dist: fastapi
|
|
35
|
+
Requires-Dist: uvicorn
|
|
36
|
+
Requires-Python: >=3.10, <=3.14
|
|
37
|
+
Project-URL: documentation, https://chaitu-ycr.github.io/automotive-test-kit/packages/py_uds_demo
|
|
38
|
+
Project-URL: homepage, https://github.com/chaitu-ycr/automotive-test-kit
|
|
39
|
+
Project-URL: repository, https://github.com/chaitu-ycr/automotive-test-kit
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# py_uds_demo
|
|
43
|
+
|
|
44
|
+
## Overview
|
|
45
|
+
|
|
46
|
+
`py_uds_demo` is a Python package for learning and practicing the Unified Diagnostic Services (UDS) protocol. It provides a simulator with CLI, GUI, and Web interfaces, allowing users to send diagnostic requests and view responses as per ISO 14229.
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
- UDS protocol simulation (ISO 14229)
|
|
51
|
+
- CLI, GUI (CustomTkinter), and Web (Gradio) interfaces
|
|
52
|
+
- Diagnostic session management, data transmission, input/output control, and more
|
|
53
|
+
- Extensible and modular codebase
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## source manual
|
|
58
|
+
|
|
59
|
+
::: py_uds_demo.core.client
|
|
60
|
+
::: py_uds_demo.core.server
|
|
61
|
+
::: py_uds_demo.core.utils.helpers
|
|
62
|
+
::: py_uds_demo.core.utils.responses
|
|
63
|
+
::: py_uds_demo.core.utils.services.diagnostic_and_commmunication_management
|
|
64
|
+
::: py_uds_demo.core.utils.services.data_transmission
|
|
65
|
+
::: py_uds_demo.core.utils.services.stored_data_transmission
|
|
66
|
+
::: py_uds_demo.core.utils.services.input_output_contol
|
|
67
|
+
::: py_uds_demo.core.utils.services.remote_activation_of_routine
|
|
68
|
+
::: py_uds_demo.core.utils.services.upload_download
|
|
69
|
+
|
|
70
|
+
---
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
py_uds_demo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
py_uds_demo/__main__.py,sha256=jXTwCde6XSvrUodd8FGorlItlhav3EnuqHQtlYjorDY,1873
|
|
3
|
+
py_uds_demo/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
py_uds_demo/core/client.py,sha256=r9p-m68qsgyNLAji0znute0nAY_8VPvavvtbWCYTri4,3104
|
|
5
|
+
py_uds_demo/core/server.py,sha256=6DYcHajC7p4sEp-LP2UHYBEoCK2gZxNBauuQP_IUChM,12812
|
|
6
|
+
py_uds_demo/core/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
py_uds_demo/core/utils/helpers.py,sha256=mhrvOs1PCcgTNZFJPiVocp_3jOjgKC1sPnfCaUVwgmE,14162
|
|
8
|
+
py_uds_demo/core/utils/responses.py,sha256=Oqz36f79dF0pdawA04eXxfvjuvvgqdmxue45A0hk738,1749
|
|
9
|
+
py_uds_demo/core/utils/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
py_uds_demo/core/utils/services/data_transmission.py,sha256=JeTtcNKi3keLfDgdHh_4RdNm9ieCGl4twDvqa0oTyFA,16895
|
|
11
|
+
py_uds_demo/core/utils/services/diagnostic_and_commmunication_management.py,sha256=wX2qVEW29LGT4_XCM-iVhFXuGJukFVaY6lYcQQnids8,31161
|
|
12
|
+
py_uds_demo/core/utils/services/input_output_contol.py,sha256=DJ5z_JAYjphF7JSiSAkx1_Tj5511g4005duoLiFdDiQ,2495
|
|
13
|
+
py_uds_demo/core/utils/services/negative_response.py,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
14
|
+
py_uds_demo/core/utils/services/remote_activation_of_routine.py,sha256=id_vFBmANOTul5E-PU7ltRuMSE9poF4bTotbEKSkHFo,3311
|
|
15
|
+
py_uds_demo/core/utils/services/stored_data_transmission.py,sha256=IFeiFqZZtRvTm7MgZII1haU1FlATfjKsevC5kxG6D_4,5490
|
|
16
|
+
py_uds_demo/core/utils/services/upload_download.py,sha256=nLhGBANAYCuCTxv9D78FuEE2YR5FEsjCznK_aEkep40,6055
|
|
17
|
+
py_uds_demo/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
+
py_uds_demo/interface/api.py,sha256=CIqQJx_WsTc5rb4D9gFXnScVjtlBV5WJnA0_xfNfVeY,813
|
|
19
|
+
py_uds_demo/interface/cli.py,sha256=aDkAGkJlTnSd45NzpObpf6rY8Jndty1vMWqaQ85LPEk,2138
|
|
20
|
+
py_uds_demo/interface/gui.py,sha256=IpRa--_UKhx2xF-hlWrdFOsQsTxlmnOnMNMwkSoPyTw,4259
|
|
21
|
+
py_uds_demo/interface/web.py,sha256=fM7xVnGcpa6Mb0HPxZCt8911puT8po86GPFLhLfyXIM,5429
|
|
22
|
+
py_uds_demo-25.0.0.dist-info/WHEEL,sha256=5h_Q-_6zWQhhADpsAD_Xpw7gFbCRK5WjOOEq0nB806Q,79
|
|
23
|
+
py_uds_demo-25.0.0.dist-info/METADATA,sha256=YBl-lWSUtaRhbKYBbe3lKPDBVUDzQzZO_RIGECZkMKk,3062
|
|
24
|
+
py_uds_demo-25.0.0.dist-info/RECORD,,
|