Metadata-Version: 2.4
Name: ecu_test
Version: 1.1.8
Summary: a car ecu auto test package
Author-email: Yue Shi <2385606628@qq.com>
License-Expression: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: Microsoft :: Windows
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-can>=4.0.0
Requires-Dist: pywin32; sys_platform == "win32"
Requires-Dist: pycanape>=0.8.1
Dynamic: license-file

# ECU_TEST 使用说明

## 1. 包简介

ECU_TEST 是一个基于 Python 的 ECU 测试辅助包

---

## 2. 环境要求

请先确认环境中已经安装：

- Python 3.10+
- 依赖的构建工具（如有需要）
- Vector 驱动 / Vector 硬件（如果要实际通过 Vector 设备通信）

> 如果没有安装 Vector 驱动，初始化时可能会出现连接失败或无法收发数据的问题。

---

## 3. 安装方式

在项目根目录执行：

```bash
pip install .
```

如果你希望在开发模式下使用：

```bash
pip install -e .
```

---

## 4. 导入方式

安装完成后，可以这样导入：

```python
from ecu_test import UDS, CANape, CANoe
```

---

## 5. 基本使用示例

### 5.1 配置参数

```python
config = {
    "tr_id": "0x7E0",
    "rx_id": "0x7E8",
    "ch": 1,
    "fd": False,
    "app_name": "CANoe",
    "bitrate": 500000,
    "stmin": 20,
    "mask": "0xFF",
    "pad": "0x55",
}
```

### 5.2 初始化 UDS 对象

```python
uds = UDS(config, log_path="uds.log")
```

### 5.3 发送 UDS 请求

```python
resp = uds.send_req("10 01", dlc=8, t=30)
print(resp)
```

### 5.4 初始化 CANape / CANoe 对象

```python
canape = CANape()
canoe = CANoe()
```

### 5.5 CANape 使用说明


```python
from ecu_test import CANape

canape = CANape(
    path=r"E:\CANape\",
    cna=r"E:\CANape\config.cna",
)

canape.set_log(r"E:\CANape\logs\test.mf4")
canape.start_mse()

value = canape.get_sig("SignalName")
canape.set_sig("SignalName", 1.23)

canape.stop_mse()
canape.close()
```

常用方法：

- `CANape(path, cna)`
- `set_log(file)`
- `start_mse()`
- `stop_mse()`
- `get_sig(sig)`
- `set_sig(sig, val)`
- `close()`

### 5.6 CANoe 使用说明

```python
from ecu_test import CANoe

canoe = CANoe(
    path=r"D:\CANoe\CANoe_Test\CANoe_Test.cfg",
    log_path="canoe.log",
)

canoe.open()
canoe.start_mse()

value = canoe.get_sig("CAN", "MessageName", "SignalName")
canoe.set_sig("CAN", "MessageName", "SignalName", 1.23)

env_value = canoe.get_env("Namespace", "VariableName")
canoe.set_env("Namespace", "VariableName", 42)

canoe.set_log(r"D:\CANoe\logs\test.blf")

canoe.stop_mse()
canoe.close()
```

常用方法：

- `CANoe(path)`
- `open()`
- `start_mse()`
- `stop_mse()`
- `is_running()`
- `get_sig(ch, msg, sig)`
- `set_sig(ch, msg, sig, val)`
- `get_env(ns, var)`
- `set_env(ns, var, val)`
- `set_log(file)`
- `close()`

---
