{"id":13740241,"url":"https://github.com/lbenthins/ecu-simulator","last_synced_at":"2025-05-08T19:36:50.948Z","repository":{"id":51382770,"uuid":"229112105","full_name":"lbenthins/ecu-simulator","owner":"lbenthins","description":"Tool that simulates some vehicle diagnostic services. It can be used to test OBD-II dongles or tester tools that support the UDS (ISO 14229) and ISO-TP (ISO 15765-2) protocols.","archived":true,"fork":false,"pushed_at":"2023-06-02T06:58:16.000Z","size":4028,"stargazers_count":96,"open_issues_count":3,"forks_count":34,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-04T04:06:19.218Z","etag":null,"topics":["car-diagnostics","ecu-simulation","iso-14229","iso-15765-2","isotp","obd-ii","uds"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lbenthins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-12-19T18:06:17.000Z","updated_at":"2024-07-31T14:35:40.000Z","dependencies_parsed_at":"2022-09-11T19:21:55.181Z","dependency_job_id":"7e3fdd8c-cd7d-4bd2-b496-c91056f18bf2","html_url":"https://github.com/lbenthins/ecu-simulator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbenthins%2Fecu-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbenthins%2Fecu-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbenthins%2Fecu-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbenthins%2Fecu-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lbenthins","download_url":"https://codeload.github.com/lbenthins/ecu-simulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224765423,"owners_count":17366117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["car-diagnostics","ecu-simulation","iso-14229","iso-15765-2","isotp","obd-ii","uds"],"created_at":"2024-08-03T04:00:44.901Z","updated_at":"2024-11-15T10:30:25.536Z","avatar_url":"https://github.com/lbenthins.png","language":"Python","funding_links":[],"categories":["Test equipment and simulators"],"sub_categories":[],"readme":"# :warning: This project is not maintained anymore :(  It is kept here only for reference. Thanks for the feedbacks :)\n\n# ECU Simulator\n\nThis Python tool simulates some vehicle diagnostic services. It can be used to test OBD-II dongles or tester tools that support the UDS (ISO 14229) and ISO-TP (ISO 15765-2) protocols. \n\nThis tool does NOT implement the ISO-TP protocol. It just simulates a couple of OBD and UDS services. The simulation consists in receiving a diagnostic request (e.g., Request DTCs (0x03)), and responding to it according to the protocol specifications. The data of some responses (e.g., VIN) must be defined in the `ecu_config.json` file.\n\nI created this project to learn more about the OBD and UDS protocols. I did my best to understand the specifications, however, if you suspect that something is implemented wrongly, please let me know. Any feedback will be very appreciated. \n\n## Supported Services\n\n### OBD-II\n\n| Service | PID    |          Description                   |\n|:-------:|:-----: |:---------------------------------------|\n| 0x01    | 0x00   | List of supported PIDs in service 0x01 |\n| 0x01    | 0x05   | Engine coolant temperature |\n| 0x01    | 0x0D   | Vehicle speed |\n| 0x01    | 0x2F   | Fuel tank level input |\n| 0x01    | 0x51   | Fuel type |\n| 0x03    | -      | Request DTCs |\n| 0x09    | 0x00   | List of supported PIDs in service 0x09 |\n| 0x09    | 0x02   | Vehicle Identification Number (VIN) |\n| 0x09    | 0x0A   | ECU name |\n\n### UDS (ISO 14229)\n\n| Service ID |          Name            | Supported sub-functions | Default parameters (response) |\n|:----------:|:-------------------------|:------------------------|:-----------------|\n| 0x10       | DiagnosticSessionControl | **session types** \u003cbr\u003e \u003cbr\u003e 0x01 default \u003cbr\u003e 0x02 programming \u003cbr\u003e 0x03 extended \u003cbr\u003e 0x04 safety | |\n| 0x11       | ECUReset                 | **reset types** \u003cbr\u003e \u003cbr\u003e 0x01 hardReset \u003cbr\u003e 0x02 keyOffOnReset \u003cbr\u003e 0x03 softReset \u003cbr\u003e 0x04 enableRapidPowerShutDown \u003cbr\u003e 0x05 disableRapidPowerShutDown | 0x0F powerDownTime |\n| 0x19       | ReadDTCInformation       | **report types** \u003cbr\u003e \u003cbr\u003e 0x02 reportDTCByStatusMask | \u003cbr\u003e 0xFF DTCStatusAvailabilityMask \u003cbr\u003e 0x2F statusOfDTC  | \n \n## Addressing\n\n**OBD:** Functional and physical. See options `obd_broadcast_address` and `obd_ecu_address` in `ecu_config.json`.\n\n**UDS:** Physical. See option `uds_ecu_address` in `ecu_config.json`.\n\nIn both cases, only ISO-TP **normal addressing** (only CAN arbitration ID is used) is supported.\n\n## Requirements\n\n* Python3\n* [SocketCAN](https://www.kernel.org/doc/Documentation/networking/can.txt) Implementation of the CAN protocol. This kernel module is part of Linux. \n* [ISO-TP kernel module](https://github.com/hartkopp/can-isotp) It is NOT part of linux. It needs to be loaded before running the `ecu-simulator`. See `isotp_ko_file_path` in `ecu_config.json`.\n* [isotp](https://can-isotp.readthedocs.io/en/latest/) The `ecu-simulator` only uses [isotp.socket](https://can-isotp.readthedocs.io/en/latest/isotp/socket.html), which is a wrapper for the ISO-TP kernel module.\n* [python-can](https://python-can.readthedocs.io/en/master/installation.html) The `ecu-simulator` uses this library to log CAN messages (see `loggers\\logger_can.py`). **Note**: The bus type `socketcan_native` is used.  \n\n## Usage \n\nThe `ecu-simulator` sets up the CAN interface and loads the ISO-TP linux kernel module (you need to configure `can_interface`, `can_interface_type`, `can_bitrate`, and `isotp_ko_file_path` in `ecu_config.json`). To perform this task, the tool must be started with root privileges:   \n\n```\nsudo python3 ecu-simulator.py\n```\n\nIf you do not want to start the tool with root privileges, you can do the following:\n\n```\n# set up CAN hardware interface\nsudo sh setup_can.sh \u003cCAN interface e.g., can0\u003e \u003cCAN bitrate e.g., 500000\u003e \u003ccan-isotp.ko file pyth e.g., /lib/modules/4.19.75-v7+/kernel/net/can/can-isotp.ko\u003e\n\n# or set up CAN virtual interface \nsudo sh setup_vcan.sh \u003cvirtual CAN interface e.g., vcan0\u003e \u003ccan-isotp.ko file pyth e.g., /lib/modules/4.19.75-v7+/kernel/net/can/can-isotp.ko\u003e\n\n# and then start the tool without sudo\npython3 ecu_simulator.py\n``` \n\n## Logging \n\nThe `ecu-simulator` provides 3 levels of logging: CAN, ISO-TP, and application level. For example, when the VIN is requested, the following is logged:\n\n* In `can_[Timestamp].log`\n\n```\n2020-02-05T13:08:39.188 can0 0x7df 0x0209020000000000\n2020-02-05T13:08:39.192 can0 0x7e8 0x1014490200544553\n2020-02-05T13:08:39.192 can0 0x7e0 0x3000050000000000\n2020-02-05T13:08:39.198 can0 0x7e8 0x215456494e303132\n2020-02-05T13:08:39.203 can0 0x7e8 0x2233343536373839\n```\n* In `isotp_[Timestamp].log`\n\n```\n2020-02-05T13:08:39.498 can0 0x7df 0x0902\n2020-02-05T13:08:39.499 can0 0x7e8 0x4902005445535456494e30313233343536373839\n```\n* In `ecu_simulator.log`\n\n```\n2020-02-05T13:08:39.189 - ecu_simulator - INFO - Receiving on OBD address 0x7df from 0x7e8 Request: 0x0902\n2020-02-05T13:08:39.190 - ecu_simulator - INFO - Requested OBD SID 0x9: Request vehicle information\n2020-02-05T13:08:39.191 - ecu_simulator - INFO - Requested PID 0x2: Vehicle Identification Number(VIN)\n2020-02-05T13:08:39.191 - ecu_simulator - INFO - Sending to 0x7e8 Response: 0x4902005445535456494e30313233343536373839\n```\n\nThe log files have a max size of **1.5 M**. A new log file is generated when this size is reached.\n \n## Test Environment  \n\nThe `ecu-simulator` was tested on a Raspberry Pi (Raspbian, Linux Kernel 4.19) with PiCAN and [SBC-CAN01](http://www.anleitung.joy-it.net/wp-content/uploads/2018/09/SBC-CAN01-Anschlussplan.pdf) (see pic below) as CAN-Bus board. \n\n### OBD-II\n\nThe OBD-II services were tested using a real OBD-II scanner.\n\n\u003cimg src=\"https://github.com/lbenthins/ecu-simulator/blob/master/img/obd_sbc-can01.jpg\" alt=\"OBD-II test - SBC-CAN01\"/\u003e\n\n\u003cimg src=\"https://github.com/lbenthins/ecu-simulator/blob/master/img/obd_detecting.jpg\" alt=\"OBD-II test env\" width=\"407\" height=\"314\"/\u003e\n\n\u003cimg src=\"https://github.com/lbenthins/ecu-simulator/blob/master/img/obd_dtc.jpg\" alt=\"OBD-II test env\" width=\"407\" height=\"314\"/\u003e\n\n\u003cimg src=\"https://github.com/lbenthins/ecu-simulator/blob/master/img/obd_info.jpg\" alt=\"OBD-II test env\" width=\"407\" height=\"314\"/\u003e\n\n\n### UDS\n\nTo test the UDS services, the [Caring Caribou](https://github.com/CaringCaribou/caringcaribou) tool was used.\n\n\u003cimg src=\"https://github.com/lbenthins/ecu-simulator/blob/master/img/caringcaribou_1.png\" alt=\"UDS test env\" width=\"496\" height=\"160\" /\u003e\n\n\u003cimg src=\"https://github.com/lbenthins/ecu-simulator/blob/master/img/caringcaribou_2.png\" alt=\"UDS test env\" width=\"496\" height=\"160\" /\u003e \n\n## License \n\nMIT License\n\nCopyright (c) 2020 Luis Alberto Benthin Sanguino\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbenthins%2Fecu-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flbenthins%2Fecu-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbenthins%2Fecu-simulator/lists"}