├── truckdevil ├── j1939 │ └── __init__.py ├── libs │ ├── __init__.py │ ├── command.py │ ├── ecu.py │ ├── settings.py │ └── device.py ├── __init__.py ├── modules │ ├── __init__.py │ ├── send_messages.py │ ├── template.py │ ├── read_messages.py │ ├── ecu_discovery.py │ └── j1939_fuzzer.py ├── truckdevil.py └── resources │ └── json_files │ ├── src_addr_list.json │ ├── UDS_services.json │ └── UDS_NRC.json ├── .gitignore ├── requirements.txt ├── setup.py ├── tests └── settings.py ├── README.md ├── m2_sketch └── m2_sketch.ino └── LICENSE.md /truckdevil/j1939/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /truckdevil/libs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *__pycache__ 3 | -------------------------------------------------------------------------------- /truckdevil/__init__.py: -------------------------------------------------------------------------------- 1 | name = 'truckdevil' 2 | -------------------------------------------------------------------------------- /truckdevil/modules/__init__.py: -------------------------------------------------------------------------------- 1 | name = 'modules' 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyserial>=3.5 2 | python-can>=3.3.4 3 | dill>=0.3.4 4 | setuptools>=57.0.0 -------------------------------------------------------------------------------- /truckdevil/libs/command.py: -------------------------------------------------------------------------------- 1 | import cmd 2 | 3 | 4 | class Command(cmd.Cmd): 5 | def run_commands(self, argv): 6 | """ 7 | run commands from list of arguments 8 | """ 9 | command_names = [] 10 | for name in self.get_names(): 11 | if name.startswith("do_"): 12 | command_names.append(name.strip("do_")) 13 | cmd_args = [] 14 | for arg in argv: 15 | if arg in command_names and len(cmd_args) != 0: 16 | self.onecmd(' '.join(cmd_args)) 17 | cmd_args = [] 18 | cmd_args.append(arg) 19 | if len(cmd_args) != 0: 20 | self.onecmd(' '.join(cmd_args)) 21 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | import os 3 | 4 | 5 | def read(*paths): 6 | """Build a file path from *paths* and return the contents.""" 7 | with open(os.path.join(*paths), 'r') as f: 8 | return f.read() 9 | 10 | 11 | setup( 12 | name='truckdevil', 13 | version='1.0.0', 14 | description='J1939 testing framework', 15 | long_description=read('README.md'), 16 | long_description_content_type="text/markdown", 17 | url='https://github.com/LittleBlondeDevil/TruckDevil', 18 | download_url='https://pypi.org/project/truckdevil', 19 | license='GPLv3+', 20 | author='Hannah Silva', 21 | classifiers=[ 22 | 'Development Status :: 5 - Production/Stable', 23 | 'Intended Audience :: Science/Research', 24 | 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', 25 | 'Natural Language :: English', 26 | 'Operating System :: OS Independent', 27 | 'Programming Language :: Python :: 3 :: Only', 28 | 'Topic :: Scientific/Engineering', 29 | 'Topic :: Security', 30 | ], 31 | install_requires=[ 32 | 'pyserial>=3.5', 33 | 'python-can>=3.3.4', 34 | 'dill>=0.3.4', 35 | ], 36 | packages=find_packages(exclude=['tests*']), 37 | ) 38 | -------------------------------------------------------------------------------- /truckdevil/libs/ecu.py: -------------------------------------------------------------------------------- 1 | from j1939.j1939 import J1939Message 2 | 3 | 4 | class ECU: 5 | def __init__(self, address: int): 6 | self._address = address 7 | self._address_claimed_response = None 8 | self._prop_messages = [] 9 | 10 | @property 11 | def address(self): 12 | return self._address 13 | 14 | @property 15 | def name(self): 16 | if self._address_claimed_response is None: 17 | return None 18 | return self._address_claimed_response.data 19 | 20 | @property 21 | def address_claimed_response(self) -> J1939Message: 22 | return self._address_claimed_response 23 | 24 | @address_claimed_response.setter 25 | def address_claimed_response(self, msg: J1939Message): 26 | if msg.pdu_format != 0xEE: 27 | raise ValueError("Address claimed should have PDU Format 0xEE") 28 | if msg.src_addr != self.address: 29 | raise ValueError("Address of ECU does not match this ECU") 30 | if len(msg.data) != 16: 31 | raise ValueError("NAME should be 8 bytes long") 32 | self._address_claimed_response = msg 33 | 34 | @property 35 | def prop_messages(self) -> list: 36 | return self._prop_messages 37 | 38 | def add_prop_message(self, msg: J1939Message): 39 | """ 40 | Adds the msg to the list of proprietary messages, only if it's unique. 41 | """ 42 | for p in self._prop_messages: 43 | if msg.can_id == p.can_id: 44 | if msg.data == p.data: 45 | return # not unique 46 | self._prop_messages.append(msg) 47 | 48 | def __str__(self): 49 | name = "unknown" 50 | if self.name is not None: 51 | name = self.name 52 | return "address: {:<3} NAME: {}".format(self.address, name) 53 | -------------------------------------------------------------------------------- /truckdevil/modules/send_messages.py: -------------------------------------------------------------------------------- 1 | from j1939.j1939 import J1939Interface, J1939Message 2 | from libs.command import Command 3 | 4 | 5 | class SendCommands(Command): 6 | intro = "Welcome to the Send Messages tool." 7 | prompt = "(truckdevil.send_messages) " 8 | 9 | def __init__(self, device): 10 | super().__init__() 11 | self.devil = J1939Interface(device) 12 | 13 | def do_send(self, arg): 14 | """ 15 | Send message to CAN device to get pushed to the BUS. 16 | Transport protocol will automatically be applied for data longer 17 | than 8 bytes. 18 | 19 | usage: send [-vv] 20 | 21 | Arguments: 22 | can_id 29-bit identifier 23 | data hex string 24 | Optional: 25 | -v Don't send, just print the message 26 | -vv Don't send, just print the decoded form of the message 27 | 28 | examples: 29 | send 0x18EFF900 112233445566AABBCCDDEEFF 30 | send 0x18EF00F9 FFFF12FCFFFFFFFF 31 | send 0x0CEA000B ECFE00 32 | """ 33 | argv = arg.split() 34 | if len(argv) < 2: 35 | print("arguments not found, see 'help send'") 36 | return 37 | can_id = argv[0] 38 | if can_id.startswith("0x"): 39 | can_id = int(can_id, 16) 40 | else: 41 | try: 42 | can_id = int(can_id) 43 | except Exception as e: 44 | print(f'Could not parse can id - error: {e}') 45 | return 46 | 47 | data = argv[1] 48 | 49 | message = J1939Message(can_id, data) 50 | if len(argv) == 3: 51 | verbose = argv[2][1:].lower() 52 | if verbose == 'v': 53 | print(str(message)) 54 | elif verbose == 'vv': 55 | print(self.devil.get_decoded_message(message)) 56 | else: 57 | print("third argument invalid, see 'help send'") 58 | return 59 | self.devil.send_message(message) 60 | print("message sent.") 61 | 62 | @staticmethod 63 | def do_back(self, arg=None): 64 | """ 65 | Return to the main menu 66 | """ 67 | return True 68 | 69 | def main_mod(argv, device): 70 | scli = SendCommands(device) 71 | if len(argv) > 0: 72 | scli.run_commands(argv) 73 | else: 74 | scli.cmdloop() 75 | -------------------------------------------------------------------------------- /tests/settings.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from TruckDevil.truckdevil.libs.settings import Setting 4 | from TruckDevil.truckdevil.libs.settings import SettingsManager 5 | 6 | 7 | class SettingsManagerTestCase(unittest.TestCase): 8 | 9 | def test_settings_constructor(self): 10 | sm = SettingsManager() 11 | sm.add_setting(Setting("example", 10)) 12 | 13 | self.assertEqual(sm.example, 10) 14 | self.assertFalse(sm['example'].updated) 15 | 16 | sm.set("example", 17) 17 | self.assertEqual(sm.example, 17) 18 | self.assertTrue(sm['example'].updated) 19 | 20 | self.assertTrue(isinstance(sm['example'], Setting)) 21 | 22 | 23 | class SettingsTestCase(unittest.TestCase): 24 | 25 | def test_setting_constructor(self): 26 | setting = Setting("example", 25) 27 | self.assertTrue(isinstance(setting, Setting)) 28 | self.assertEqual(setting.value, 25) 29 | self.assertEqual(setting.default_value, 25) 30 | self.assertEqual(type(setting.value), type(25)) 31 | 32 | def test_setting_mutator(self): 33 | setting = Setting("example", 25) 34 | self.assertEqual(setting.value, 25) 35 | setting.value = 30 36 | self.assertEqual(setting.value, 30) 37 | 38 | with self.assertRaises(ValueError) as context: 39 | setting.value = "25" 40 | 41 | self.assertTrue("expected a " in str(context.exception)) 42 | 43 | def test_setting_updated(self): 44 | setting = Setting("example", "") 45 | self.assertEqual(setting.value, "") 46 | self.assertFalse(setting.updated) 47 | setting.value = "new value" 48 | self.assertEqual(setting.value, "new value") 49 | self.assertTrue(setting.updated) 50 | 51 | def test_setting_constraints(self): 52 | setting = Setting("example", 10) 53 | setting.add_constraint("minval", lambda x: 0 <= x <= 10) 54 | setting.value = 2 55 | self.assertEqual(setting.value, 2) 56 | 57 | with self.assertRaises(ValueError) as context: 58 | setting.value = -1 59 | 60 | self.assertTrue("constraint minval" in str(context.exception)) 61 | 62 | with self.assertRaises(ValueError) as context: 63 | setting.value = 11 64 | 65 | self.assertTrue("constraint minval" in str(context.exception)) 66 | 67 | 68 | if __name__ == '__main__': 69 | unittest.main() 70 | -------------------------------------------------------------------------------- /truckdevil/modules/template.py: -------------------------------------------------------------------------------- 1 | from j1939.j1939 import J1939Interface, J1939Message 2 | from libs.command import Command 3 | 4 | 5 | class TemplateCommands(Command): 6 | intro = "Welcome to the template module." 7 | # Change the prompt to your module name for example "(truckdevil.super_cool_custom_module) " 8 | prompt = "(truckdevil.template) " 9 | 10 | def __init__(self, device): 11 | super().__init__() 12 | self.devil = J1939Interface(device) 13 | 14 | def do_custom_send(self, arg): 15 | """ 16 | [Description] 17 | Describe your command here. Truckdevil will parse these comments into the help for the command. 18 | 19 | [Usage] 20 | Describe the usage and arguments for your custom command. Here is an example for a command called 'send' 21 | 22 | [EXAMPLE] 23 | ==================== 24 | Send message to CAN device to get pushed to the BUS. 25 | Transport protocol will automatically be applied for data longer 26 | than 8 bytes. 27 | 28 | usage: custom_send [-vv] 29 | Arguments: 30 | can_id 29-bit identifier 31 | data hex string 32 | Optional: 33 | -v Don't send, just print the message 34 | -vv Don't send, just print the decoded form of the message 35 | examples: 36 | custom_send 0x18EFF900 112233445566AABBCCDDEEFF 37 | custom_send 0x18EF00F9 FFFF12FCFFFFFFFF 38 | custom_send 0x0CEA000B ECFE00 39 | ==================== 40 | """ 41 | 42 | # Parse your input arguments, this example command takes two arguments 43 | argv = arg.split() 44 | if len(argv) < 2: 45 | print("This example takes 2 arguments") 46 | self.do_help("custom_send") 47 | return 48 | 49 | 50 | # Parse out the can_id from the first argument 51 | can_id = argv[0] 52 | 53 | # Support for base 16 (hex) or base 10 54 | if can_id.startswith("0x"): 55 | can_id = int(can_id, 16) 56 | else: 57 | can_id = int(can_id) 58 | 59 | # Put second argument into a data buffer 60 | data = argv[1] 61 | 62 | # Create a message out of our variables 63 | message = J1939Message(can_id, data) 64 | 65 | 66 | # Support extra argument flags for 'verbose' mode 67 | # It is best to do work inside a try-catch block. 68 | try: 69 | if len(argv) == 3: 70 | verbose = argv[2][1:].lower() 71 | if verbose == 'v': 72 | print(str(message)) 73 | elif verbose == 'vv': 74 | print(self.devil.get_decoded_message(message)) 75 | else: 76 | print("third argument invalid, let me RTFM that for you!") 77 | self.do_help("custom_send") 78 | return 79 | except: 80 | print("something went wrong before sending message, let me RTFM that for you!") 81 | self.do_help("custom_send") 82 | return 83 | 84 | try: 85 | self.devil.send_message(message) 86 | except: 87 | print("something went wrong, let me RTFM that for you!") 88 | self.do_help("custom_send") 89 | return 90 | 91 | print("message sent.") 92 | 93 | # You can create new commands by simply defining them 94 | def do_minimal_template(self, arg): 95 | """ 96 | Document your command here 97 | """ 98 | try: 99 | # Do some things 100 | print("Do Something Useful") 101 | except: 102 | # Handle Errors 103 | print("Something Useful") 104 | return 105 | 106 | # This static method allows going back to other modules 107 | @staticmethod 108 | def do_back(self, arg=None): 109 | """ 110 | Return to the main menu 111 | """ 112 | return True 113 | 114 | def main_mod(argv, device): 115 | # You will need to change this to "MyNewCommandCommands(device)" 116 | scli = TemplateCommands(device) 117 | if len(argv) > 0: 118 | scli.run_commands(argv) 119 | else: 120 | scli.cmdloop() 121 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | TruckDevil is a framework for interacting with and assessing ECUs that use J1939 for communications on the CANBUS. 4 | 5 | ## Requirements 6 | 7 | ### Hardware: 8 | 9 | The recommended CAN transciever to use is the Macchina M2 ([Under-the-Dash](https://www.macchina.cc/catalog/m2-boards/m2-under-dash)). 10 | 11 | However, python-can is used so hardware devices with any of the supported interfaces, such as SocketCAN, could be used: ([CAN Interface Modules](https://python-can.readthedocs.io/en/master/interfaces.html)). 12 | 13 | Additionally, an OBD-II to J1939 deutsch 9 pin adapter or splitter could be utilized, available on [Amazon](https://www.amazon.com/gp/product/B073DJN7FG/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1). 14 | 15 | ### Software: 16 | 17 | [Python 3](https://www.python.org/downloads/) is required. 18 | 19 | Additional software is required to flash the m2_sketch firmware to the M2, if used (see Installation). 20 | 21 | ## Installation 22 | ``` 23 | > git clone https://github.com/LittleBlondeDevil/TruckDevil.git 24 | ``` 25 | ### M2 (if used) 26 | 27 | - Follow the first 3 steps included in the M2 [Arduino IDE Quick Start](https://docs.macchina.cc/m2-docs/arduino) guide 28 | - Install the Arduino Desktop IDE 29 | - Install the Macchina M2 Board Configuration 30 | - Install drivers 31 | - Download and include due_can and can_common libraries from collin80 into IDE 32 | - [due_can](https://github.com/collin80/due_can) 33 | - [can_common](https://github.com/collin80/can_common) 34 | ``` 35 | Sketch > Include Library > Add .Zip Library... 36 | ``` 37 | - Upload m2_sketch.ino to the M2 38 | - Ensure M2 is plugged in over USB and that it's selected as the active board. 39 | ``` 40 | Tools > Board: "[...]" > Arduino Due (Native USB Port) 41 | ``` 42 | - Select the serial port in use for the M2 (usually named "Arduino Due"). 43 | ``` 44 | Tools > Port 45 | ``` 46 | - Open the m2_sketch.ino file and upload it to the M2. 47 | ``` 48 | Sketch > Upload 49 | ``` 50 | - Once uploaded, disconnect M2 and plug back in. 51 | 52 | ## Usage 53 | 54 | TruckDevil contains various modules for reading, sending, ECU discovery, and fuzzing. Additional modules can be added 55 | for more specific tasks. 56 | 57 | ### Getting Started 58 | * Interactively 59 | ``` 60 | > python truckdevil.py 61 | Welcome to the truckdevil framework 62 | (truckdevil)? 63 | 64 | Documented commands (type help ): 65 | ======================================== 66 | add_device help list_device list_modules run_module 67 | 68 | (truckdevil)add_device m2 can0 250000 COM5 69 | (truckdevil)list_device 70 | 71 | ***** CAN Device Info ***** 72 | Device Type: m2 73 | Serial Port: COM5 74 | CAN Channel: can0 75 | Baud Rate: 250000 76 | 77 | (truckdevil)list_modules 78 | ecu_discovery 79 | j1939_fuzzer 80 | read_messages 81 | send_messages 82 | 83 | (truckdevil)run_module read_messages 84 | Welcome to the Read Messages tool. 85 | (truckdevil.read_messages) ? 86 | 87 | Documented commands (type help ): 88 | ======================================== 89 | help load print_messages save set settings unset 90 | 91 | (truckdevil.read_messages) ? set 92 | 93 | Provide a setting name and a value to set the setting. For a list of 94 | available settings and their current and default values see the 95 | settings command. 96 | 97 | example: 98 | set read_time 10 99 | set filter_src_addr 11,249 100 | 101 | (truckdevil.read_messages) set num_messages 5 102 | (truckdevil.read_messages) print_messages 103 | 18FECA00 06 FECA 00 --> FF [0008] 00FF00000000FFFF 104 | 0CF00400 03 F004 00 --> FF [0008] F87D7D000000F07D 105 | 18F00E00 06 F00E 00 --> FF [0008] FFFF285AFFFFFFFF 106 | 0CF00300 03 F003 00 --> FF [0008] D10000FFFFFF00FF 107 | 18FEDF00 06 FEDF 00 --> FF [0008] FE00FEFE7D0200FF 108 | ``` 109 | * From command line (arguments are passed to module) 110 | ``` 111 | > python .\truckdevil.py add_device m2 can0 250000 COM5 run_module read_messages set num_messages 5 print_messages 112 | 18FECA00 06 FECA 00 --> FF [0008] 00FF00000000FFFF 113 | 0CF00400 03 F004 00 --> FF [0008] F87D7D000000F07D 114 | 18F00E00 06 F00E 00 --> FF [0008] FFFF285AFFFFFFFF 115 | 0CF00300 03 F003 00 --> FF [0008] D10000FFFFFF00FF 116 | 18FEDF00 06 FEDF 00 --> FF [0008] FE00FEFE7D0200FF 117 | ``` 118 | 119 | ### Custom Modules 120 | 121 | Create custom modules by creating a python file in the 'modules' folder. 122 | The file should contain the following function: 123 | ``` 124 | def main_mod(argv, device) 125 | ``` 126 | - argv contains the list of arguments passed to the module 127 | - device contains the Device object passed to the module 128 | 129 | ### J1939 API 130 | 131 | Python docs are available in the j1939.py file. Existing modules provide example usage. 132 | 133 | -------------------------------------------------------------------------------- /truckdevil/truckdevil.py: -------------------------------------------------------------------------------- 1 | import cmd 2 | import importlib 3 | import sys 4 | from pkgutil import iter_modules 5 | 6 | from libs.device import Device 7 | 8 | 9 | class FrameworkCommands(cmd.Cmd): 10 | intro = "Welcome to the truckdevil framework. Type 'help or ?' for a list of commands." 11 | prompt = '(truckdevil) ' 12 | 13 | def __init__(self): 14 | super().__init__() 15 | self._device = None 16 | self.module_names = [name for _, name, _ in iter_modules(['modules'])] 17 | 18 | @property 19 | def device(self): 20 | return self._device 21 | 22 | @device.setter 23 | def device(self, new_device): 24 | self._device = new_device 25 | 26 | @property 27 | def device_added(self): 28 | if self._device is not None: 29 | return True 30 | return False 31 | 32 | def do_list_device(self, args): 33 | """ 34 | List the current CAN device 35 | """ 36 | print(str(self.device)) 37 | 38 | def do_add_device(self, args): 39 | """ 40 | Add a new hardware device. If one exists, replace it. 41 | 42 | usage: add_device [serial_port] 43 | 44 | Arguments: 45 | interface The CAN interface to use. e.g. m2 or one supported by python-can 46 | https://python-can.readthedocs.io/en/master/interfaces.html 47 | channel CAN channel to send/receive on. e.g. can0, can1, vcan0 48 | can_baud Baudrate on the CAN bus. Most common are 250000 and 500000. Use 0 for autobaud detection. 49 | serial_port Serial port that the M2 is connected to, if used. For example: COM7 or /dev/ttyX. 50 | 51 | examples: 52 | add_device m2 can0 250000 COM5 53 | add_device socketcan vcan0 500000 54 | add_device pcan PCAN_USBBUS1 500000 55 | """ 56 | argv = args.split() 57 | if len(argv) < 3: 58 | print("Error: expected device details") 59 | self.do_help("add_device") 60 | return 61 | interface = argv[0] 62 | channel = argv[1] 63 | can_baud = argv[2] 64 | serial_port = None 65 | if len(argv) >= 4: 66 | serial_port = argv[3] 67 | self.device = Device(interface, serial_port, channel, can_baud) 68 | 69 | def do_list_modules(self, args): 70 | """ 71 | List all available modules 72 | """ 73 | for name in self.module_names: 74 | print(name) 75 | 76 | def do_ls(self, args): 77 | """ 78 | alias 'ls' to 'list_modules' 79 | """ 80 | self.do_list_modules(args) 81 | 82 | def do_run_module(self, args): 83 | """ 84 | Run a module from the 'modules' directory that contains 85 | a 'main_mod()' function 86 | 87 | usage: run_module [MODULE_ARGS] 88 | 89 | example: 90 | run_module read_messages 91 | """ 92 | argv = args.split() 93 | if len(argv) == 0: 94 | print("Error: expected module name") 95 | self.do_help("run_module") 96 | return 97 | module_name = argv[0] 98 | if module_name in self.module_names: 99 | mod = importlib.import_module("modules.{}".format(module_name)) 100 | mod.main_mod(argv[1:], self.device) 101 | else: 102 | print("Error: module not found") 103 | self.do_help("run_module") 104 | 105 | 106 | def do_use(self, args): 107 | """ 108 | alias 'use' to 'run_module' 109 | """ 110 | self.do_run_module(args) 111 | 112 | def do_quit(self, args): 113 | """ 114 | Quit TruckDevil 115 | """ 116 | sys.exit("Exiting TruckDevil") 117 | 118 | def complete_run_module(self, text, line, begidx, endidx): 119 | if not text: 120 | completions = self.module_names[:] 121 | else: 122 | completions = [ f 123 | for f in self.module_names 124 | if f.startswith(text) 125 | ] 126 | return completions 127 | 128 | def complete_use(self, text, line, begidx, endidx): 129 | if not text: 130 | completions = self.module_names[:] 131 | else: 132 | completions = [ f 133 | for f in self.module_names 134 | if f.startswith(text) 135 | ] 136 | return completions 137 | 138 | if __name__ == "__main__": 139 | fc = FrameworkCommands() 140 | if len(sys.argv) > 1: 141 | if sys.argv[1] == "add_device" and "run_module" in sys.argv: 142 | module_index = sys.argv[1:].index("run_module") 143 | device_args = sys.argv[1:][:module_index] 144 | module_args = sys.argv[module_index + 1:] 145 | fc.onecmd(' '.join(device_args)) 146 | fc.onecmd(' '.join(module_args)) 147 | elif sys.argv[1] == "add_device" and not "run_module" in sys.argv: 148 | fc.onecmd(' '.join(sys.argv[1:6])) 149 | fc.onecmd(' '.join(sys.argv[6:])) 150 | fc.cmdloop() 151 | else: 152 | fc.onecmd(' '.join(sys.argv[1:])) 153 | else: 154 | fc.cmdloop() 155 | -------------------------------------------------------------------------------- /truckdevil/libs/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Settings management for truckdevil 3 | """ 4 | from typing import Any 5 | from collections.abc import Callable 6 | from textwrap import fill 7 | 8 | 9 | class Setting: 10 | """ 11 | A setting is a strongly typed tunable parameter. 12 | 13 | Requirements: 14 | * Settings must maintain type information and enforce typing. 15 | * Settings must be able to report if they have been changed from 16 | its default value. 17 | * Settings must be able to validate ranges (e.g. [0..7] etc.) 18 | 19 | """ 20 | 21 | def __init__(self, name: str, def_val: Any): 22 | """ 23 | Create a setting object with the given name and value, the type of 24 | this setting will be inferred from the default value, so make sure it 25 | has the same type as what's desired. 26 | 27 | :param name: str - string name of this setting 28 | :param def_val: Any - the default value of this setting 29 | """ 30 | self.name = name 31 | self.datatype = type(def_val) 32 | self.default_value = def_val 33 | self._value = None 34 | self.constraints = {} 35 | self.description = "" 36 | return 37 | 38 | @property 39 | def value(self) -> Any: 40 | """ 41 | Get the value (or default value) of the setting 42 | 43 | :return: Any - the current value of this setting 44 | """ 45 | if self._value is None: 46 | return self.default_value 47 | return self._value 48 | 49 | @value.setter 50 | def value(self, new_value: Any): 51 | """ 52 | Set this setting's value with type checking 53 | 54 | :param new_value: Any - Value to set this setting to 55 | """ 56 | 57 | if len(self.constraints) > 0: 58 | for name in self.constraints: 59 | if not self.constraints[name](new_value): 60 | raise ValueError("constraint {} excludes {}".format(name, new_value)) 61 | 62 | if type(new_value) == self.datatype: 63 | self._value = new_value 64 | return 65 | 66 | raise ValueError("expected a {} but got {} ({})".format(type(self.datatype), type(new_value), new_value)) 67 | 68 | @property 69 | def updated(self): 70 | """ 71 | Check if this setting has been modified from it's default value 72 | 73 | :return: bool - True if it has been modified False otherwise 74 | """ 75 | return self._value is not None 76 | 77 | def add_constraint(self, name: str, constraint: Callable[[Any], bool]): 78 | """ 79 | Add constraints to the allowed value of setting. 80 | 81 | :param name: str - name of this constraint (e.g. max) 82 | :param constraint: Callable[[Any], bool] - validation function 83 | """ 84 | self.constraints[name] = constraint 85 | return self 86 | 87 | def add_description(self, desc: str): 88 | self.description = desc 89 | return self 90 | 91 | def __str__(self): 92 | if type(self.value) is list: 93 | str_vals = ", ".join([str(i) for i in self.value]) 94 | str_def_vals = ", ".join([str(i) for i in self.default_value]) 95 | return fill("{:<24} {:>12} (default: {:<5}) {:<}".format(self.name, str_vals, str_def_vals, self.description), 96 | width=120, subsequent_indent=" " * 55) 97 | return fill("{:<24} {:>12} (default: {:<5}) {:<}".format( 98 | self.name, self.value, self.default_value, self.description), width=120, subsequent_indent=" " * 55) 99 | 100 | 101 | class SettingsManager: 102 | """ 103 | Manage settings 104 | """ 105 | 106 | def __init__(self): 107 | self.settings = {} 108 | 109 | def add_setting(self, setting: Setting): 110 | """ 111 | Add a setting to the settings manager 112 | 113 | :param setting: Setting - to be added 114 | :return: self 115 | """ 116 | self.settings[setting.name] = setting 117 | return self 118 | 119 | def set(self, name: str, value: Any): 120 | """ 121 | Set a setting to the given value 122 | :param name: str - name of setting to set 123 | :param value: Any - value to set 124 | """ 125 | if name in self.settings: 126 | self.settings[name].value = value 127 | 128 | def unset(self, name: str): 129 | """ 130 | Set a setting to it's default value. This will also show as not updated again. 131 | :param name: str - name of the setting to unset 132 | """ 133 | if name in self.settings: 134 | self.settings[name]._value = None 135 | 136 | def __getattr__(self, name: str) -> Any: 137 | if name in self.settings: 138 | return self.settings[name].value 139 | 140 | def __getitem__(self, name: str) -> Setting: 141 | if name in self.settings: 142 | return self.settings[name] 143 | raise ValueError("setting name not found") 144 | 145 | def __str__(self): 146 | ret_val = "" 147 | for name in self.settings: 148 | ret_val += str(self.settings[name]) + "\n" 149 | return ret_val 150 | 151 | def __getstate__(self): 152 | return self.__dict__ 153 | 154 | def __setstate__(self, d): 155 | self.__dict__.update(d) 156 | -------------------------------------------------------------------------------- /m2_sketch/m2_sketch.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Configuration Parameters */ 4 | #define Serial SerialUSB 5 | #define LED_TIMEOUT 1000 6 | #define RX_LED DS5 7 | #define TX_LED DS6 8 | #define ON LOW 9 | #define OFF HIGH 10 | 11 | /* Global Variables */ 12 | int RxIndication = 0; 13 | int TxIndication = 0; 14 | int filter; 15 | char channel[5]; 16 | 17 | void initialize_can() { 18 | char tempbuf[8]; 19 | Serial.readBytes(tempbuf, 7); //read the baud rate (ex: 0250000) 20 | long baud_rate = strtol(tempbuf, 0 ,10); 21 | Serial.readBytes(channel, 4); //read the can channel (can0/can1) 22 | if (strcmp(channel,"can1") == 0) { 23 | Can1.begin(baud_rate); 24 | for (filter = 0; filter < 3; filter++) { 25 | Can1.setRXFilter(filter, 0, 0, true); 26 | } 27 | } else { 28 | Can0.begin(baud_rate); 29 | for (filter = 0; filter < 3; filter++) { 30 | Can0.setRXFilter(filter, 0, 0, true); 31 | } 32 | } 33 | 34 | /* Configure the RX/TX LEDs */ 35 | pinMode(RX_LED, OUTPUT); 36 | pinMode(TX_LED, OUTPUT); 37 | digitalWrite(RX_LED, OFF); 38 | digitalWrite(TX_LED, OFF); 39 | } 40 | 41 | void setup() { 42 | // put your setup code here, to run once: 43 | Serial.begin(115200); 44 | while(Serial.available() <= 0); 45 | Serial.read(); //read the init_delim 46 | initialize_can(); 47 | } 48 | 49 | void passFrameToSerial(CAN_FRAME &frame) { 50 | if (frame.extended == true) { 51 | Serial.print("$"); //start delimiter 52 | if(frame.id <0x10) {Serial.print("0000000");} //add number of leading zeros needed to ensure 8 digits 53 | else if(frame.id <0x100) {Serial.print("000000");} 54 | else if(frame.id <0x1000) {Serial.print("00000");} 55 | else if(frame.id <0x10000) {Serial.print("0000");} 56 | else if(frame.id <0x100000) {Serial.print("000");} 57 | else if(frame.id <0x1000000) {Serial.print("00");} 58 | else if(frame.id <0x10000000) {Serial.print("0");} 59 | 60 | Serial.print(frame.id, HEX); //id (ex: 18ECFFF9) 61 | Serial.print("0"); //adds leading zero to ensure 2 digits for length 62 | Serial.print(frame.length, HEX); //length (ex: 08) 63 | for (int count = 0; count < frame.length; count++) { 64 | if (frame.data.bytes[count] <0x10) {Serial.print("0");} //adds leading zero if needed, to ensure 2 digits is always sent 65 | Serial.print(frame.data.bytes[count], HEX); //the data (ex: 0102030405060708) 66 | } 67 | Serial.print("*"); //end delimiter 68 | } 69 | } 70 | 71 | CAN_FRAME passFrameFromSerial() { 72 | CAN_FRAME outgoing; 73 | outgoing.extended = 1; 74 | 75 | char c; 76 | char message[27]; //full message (ex: '18EF0B00080102030405060708') 77 | char start_delim = '$'; 78 | char reinit_delim = '#'; 79 | char end_delim = '*'; 80 | char tempbuf[17]; 81 | byte ndx = 0; 82 | 83 | c = char(Serial.read()); 84 | if (c == start_delim) { //start of new message 85 | while (Serial.available() > 0) { 86 | if (Serial.peek() == start_delim || ndx >= 27) { 87 | //ignore, misalignment happened, return frame indicating error 88 | outgoing.id = -1; 89 | return outgoing; 90 | } 91 | c = Serial.read(); 92 | if (c == end_delim && ndx > 10) { 93 | message[26] = '\0'; 94 | memcpy(tempbuf, &message[0], 8); //pull the 8 digit id out (18EF0B00) 95 | tempbuf[8] = '\0'; 96 | outgoing.id = strtol(tempbuf, 0 ,16); 97 | 98 | memcpy(tempbuf, &message[8], 2); //pull the 2 digit DLC out) 99 | tempbuf[2] = '\0'; 100 | outgoing.length = strtol(tempbuf, 0, 16); 101 | 102 | 103 | for (int count = 0; count < (ndx-10)/2; count++) { 104 | memcpy(tempbuf, &message[10 + (count*2)], 2); //pull one byte out at a time of data) 105 | tempbuf[2] = '\0'; 106 | outgoing.data.byte[count] = strtol(tempbuf, 0, 16); 107 | } 108 | return outgoing; 109 | } 110 | message[ndx] = c; 111 | ndx++; 112 | } 113 | 114 | } else if (c == reinit_delim){ 115 | initialize_can(); 116 | outgoing.id = -1; 117 | return outgoing; 118 | } else { 119 | //ignore, misalignment happened, return frame indicating error 120 | outgoing.id = -1; 121 | return outgoing; 122 | } 123 | } 124 | 125 | void loop() { 126 | // put your main code here, to run repeatedly: 127 | CAN_FRAME incoming; 128 | CAN_FRAME outgoing; 129 | //if there's an incoming CAN message to read from M2, pass it to Serial 130 | if (strcmp(channel,"can1") == 0 && Can1.available() > 0) { 131 | Can1.read(incoming); 132 | passFrameToSerial(incoming); 133 | 134 | /* Set Rx indication */ 135 | RxIndication = LED_TIMEOUT; 136 | digitalWrite(RX_LED, ON); 137 | } else if (strcmp(channel,"can1") != 0 && Can0.available() > 0) { 138 | Can0.read(incoming); 139 | passFrameToSerial(incoming); 140 | 141 | /* Set Rx indication */ 142 | RxIndication = LED_TIMEOUT; 143 | digitalWrite(RX_LED, ON); 144 | } 145 | 146 | //if there's a message from Serial, pass it to M2 CAN transceiver 147 | if (Serial.available() > 0) { 148 | outgoing = passFrameFromSerial(); 149 | if (outgoing.id != -1) { //no errors occurred 150 | if (strcmp(channel,"can1") == 0) { 151 | Can1.sendFrame(outgoing); 152 | /* Set Tx indication */ 153 | TxIndication = LED_TIMEOUT; 154 | digitalWrite(TX_LED, ON); 155 | } else { 156 | Can0.sendFrame(outgoing); 157 | /* Set Tx indication */ 158 | TxIndication = LED_TIMEOUT; 159 | digitalWrite(TX_LED, ON); 160 | } 161 | } 162 | } 163 | 164 | /* Check for Tx indication timeout */ 165 | if(TxIndication > 0){ 166 | TxIndication--; 167 | if(TxIndication == 0){ 168 | digitalWrite(TX_LED, OFF); 169 | } 170 | } 171 | /* Check for Rx indication timeout */ 172 | if(RxIndication > 0){ 173 | RxIndication--; 174 | if(RxIndication == 0){ 175 | digitalWrite(RX_LED, OFF); 176 | } 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /truckdevil/libs/device.py: -------------------------------------------------------------------------------- 1 | import can 2 | from can import interface, Message 3 | import serial 4 | import time 5 | import threading 6 | 7 | 8 | class Device: 9 | def __init__(self, device_type="m2", serial_port=None, channel='can0', can_baud=0): 10 | """ 11 | Defines a new hardware device 12 | 13 | :param device_type: either "m2" or "socketcan" (Default value = "m2"). 14 | :param serial_port: serial port that the M2 is connected to, if used. For example: COM7 or /dev/ttyX." 15 | :param channel: CAN channel to send/receive on. For example: can0, can1, or vcan0. (Default value = 'can0') 16 | :param can_baud: baudrate on the CAN bus. Most common are 250000 and 500000. Use 0 for autobaud detection. (Default value = 0) 17 | """ 18 | self._device_type = device_type 19 | self._serial_port = serial_port 20 | self._channel = channel 21 | self._can_baud = can_baud 22 | self.device_lock = threading.RLock() 23 | self._acknowledged_flush = True 24 | if device_type.lower() == "m2": 25 | if serial_port is None: 26 | raise ValueError("If using M2, serial port must be specified") 27 | self._m2 = serial.Serial( 28 | port=serial_port, baudrate=115200, 29 | dsrdtr=True 30 | ) 31 | self._m2.setDTR(True) 32 | # self._lockM2 = threading.RLock() 33 | # Ensure that can_baud is filled to 7 digits 34 | self.init_m2(self._can_baud, self._channel) 35 | self._m2used = True 36 | else: 37 | # TODO: test other devices 38 | self._can_bus = interface.Bus(bustype=device_type, channel=channel, bitrate=can_baud) 39 | self._m2used = False 40 | 41 | def __str__(self): 42 | device_str = "\n***** CAN Device Info *****" + "\nDevice Type: " + self._device_type 43 | if self._serial_port is not None: 44 | device_str += "\nSerial Port: " + self._serial_port 45 | device_str += "\nCAN Channel: " + self._channel + "\nBaud Rate: " + str(self._can_baud) 46 | return device_str 47 | 48 | @property 49 | def m2_used(self): 50 | return self._m2used 51 | 52 | @property 53 | def m2(self): 54 | return self._m2 55 | 56 | @property 57 | def can_bus(self): 58 | return self._can_bus 59 | 60 | def init_m2(self, can_baud: int, channel: str): 61 | """ 62 | Send command to M2 to set the CAN baud rate and channel that will be used 63 | 64 | :param can_baud: baudrate on the CAN bus. Most common are 250000 and 500000. Use 0 for autobaud detection. 65 | :param channel: CAN channel to send/receive on. For example: can0, can1, or vcan0. 66 | """ 67 | baud_to_send = '#' + str(can_baud).zfill(7) 68 | if channel == "can0" or channel == "can1": 69 | baud_to_send += channel 70 | else: 71 | baud_to_send += "can0" 72 | self.m2.write(baud_to_send.encode('utf-8')) 73 | 74 | def flush_m2(self): 75 | self._acknowledged_flush = False 76 | self.m2.reset_input_buffer() 77 | 78 | def read(self, timeout=None) -> Message: 79 | """ 80 | Reads one message from device, creates python-can Message, and returns it 81 | If optional timeout occurs, return None 82 | """ 83 | if self.m2_used: 84 | response = "" 85 | start_reading = False 86 | char = '' 87 | self._m2.timeout = timeout 88 | while True: 89 | if not self._acknowledged_flush: 90 | response = "" 91 | start_reading = False 92 | self._acknowledged_flush = True 93 | # Receive next character from M2 94 | try: 95 | char = self._m2.read().decode("utf-8") 96 | except UnicodeDecodeError: 97 | # Something went wrong 98 | # TODO: figure out why this error is occasionally raised - is the M2 sending an error frame?? 99 | continue 100 | if len(char) == 0: # timeout occurred 101 | self._m2.timeout = None 102 | return None 103 | # Denotes start of CAN message 104 | if start_reading is False and char == '$': 105 | response = '$' 106 | start_reading = True 107 | # Reading contents of CAN message, appending to response 108 | elif start_reading is True and char != '*': 109 | response += char 110 | # Denotes end of CAN message - return response 111 | elif (start_reading is True and len(response) > 0 and 112 | response[0] == '$' and char == '*' and 113 | response.count('$') == 1): 114 | try: 115 | str_frame = response[1:] 116 | if len(str_frame) < 10: 117 | raise ValueError("str_frame too short, error occurred") 118 | can_id = int(str_frame[0:8], 16) 119 | dlc = int(str_frame[8:10], 16) 120 | # TODO: remove print, or add check to ensure data is not more than 8 bytes long bc some error 121 | # occurred 122 | data = bytes.fromhex(str_frame[10:]) 123 | return Message(arbitration_id=can_id, channel=self._channel, dlc=dlc, data=data, 124 | is_extended_id=True, timestamp=time.time()) 125 | except ValueError as e: 126 | print("error in creating Message in device read: {}".format(e)) 127 | print("str_frame: {}".format(str_frame)) 128 | continue 129 | # If the serial buffer gets flushed during reading 130 | elif response.count('$') > 1: 131 | response = "" 132 | start_reading = False 133 | else: 134 | msg = self._can_bus.recv(timeout=timeout) 135 | return msg 136 | 137 | def send(self, msg: Message): 138 | if self.m2_used: 139 | # convert from Message to $1CECFF000820120003FFCAFE00* format 140 | can_id = hex(msg.arbitration_id)[2:].zfill(8) 141 | dlc = hex(msg.dlc)[2:].zfill(2) 142 | data = ''.join('{:02x}'.format(x) for x in msg.data) 143 | self.m2.write("${}{}{}*".format(can_id, dlc, data).encode('utf-8')) 144 | else: 145 | sleeptime = 0.0 146 | while True: 147 | try: 148 | self._can_bus.send(msg) 149 | time.sleep(sleeptime) 150 | except can.CanOperationError as e: 151 | if sleeptime == 0.0: 152 | sleeptime = 0.001 153 | else: 154 | sleeptime = sleeptime * 10 155 | print(f'error: {e} backing off delay to {sleeptime:d}') 156 | except Exception as e: 157 | print(f'error: {e} aborting.') 158 | return 159 | finally: 160 | return 161 | -------------------------------------------------------------------------------- /truckdevil/modules/read_messages.py: -------------------------------------------------------------------------------- 1 | import dill 2 | 3 | from j1939.j1939 import J1939Interface 4 | from libs.command import Command 5 | from libs.settings import SettingsManager, Setting 6 | 7 | 8 | class Reader: 9 | def __init__(self): 10 | self.sm = SettingsManager() 11 | sl = [ 12 | Setting("read_time", 0).add_constraint("minimum", lambda x: 0 <= x) 13 | .add_description("The amount of time to read messages for, in seconds. Ignored if not set."), 14 | 15 | Setting("num_messages", 0).add_constraint("minimum", lambda x: 0 <= x) 16 | .add_description("The number of messages to read before stopping. Ignored if not set."), 17 | 18 | Setting("abstract_TPM", False).add_constraint("boolean", lambda x: type(x) is bool) 19 | .add_description("Whether or not to abstract Transport Protocol messages."), 20 | 21 | Setting("log_to_file", False).add_constraint("boolean", lambda x: type(x) is bool) 22 | .add_description("Whether or not to log the messages to a file."), 23 | 24 | Setting("log_name", "log_[time].txt") 25 | .add_description("The name of the log file, if used."), 26 | 27 | Setting("verbose", False).add_constraint("boolean", lambda x: type(x) is bool) 28 | .add_description("Display the messages in decoded form, if applicable."), 29 | 30 | Setting("candump", False).add_constraint("boolean", lambda x: type(x) is bool) 31 | .add_description("Display the messages in candump format"), 32 | 33 | Setting("filter_can_id", [0]).add_constraint("list_of_ints", lambda x: all(isinstance(i, int) for i in x)) 34 | .add_description("Only read messages containing one of these CAN IDs."), 35 | 36 | Setting("filter_priority", [0]).add_constraint("list_of_ints", lambda x: all(isinstance(i, int) for i in x)) 37 | .add_description("Only read messages containing one of these priorities."), 38 | 39 | Setting("filter_pdu_format", [0]).add_constraint("list_of_ints", 40 | lambda x: all(isinstance(i, int) for i in x)) 41 | .add_description("Only read messages containing one of these PDU Formats."), 42 | 43 | Setting("filter_pdu_specific", [0]).add_constraint("list_of_ints", 44 | lambda x: all(isinstance(i, int) for i in x)) 45 | .add_description("Only read messages containing one of these PDU Specifics."), 46 | 47 | Setting("filter_src_addr", [0]).add_constraint("list_of_ints", lambda x: all(isinstance(i, int) for i in x)) 48 | .add_description("Only read messages containing one of these source addresses."), 49 | 50 | Setting("filter_data_snippet", [""]) 51 | .add_description( 52 | "Only read messages containing one of these data snippets. Checks if snippets in data."), 53 | 54 | ] 55 | 56 | for setting in sl: 57 | self.sm.add_setting(setting) 58 | 59 | 60 | class ReadCommands(Command): 61 | intro = "Welcome to the Read Messages tool." 62 | prompt = "(truckdevil.read_messages) " 63 | 64 | def __init__(self, device): 65 | super().__init__() 66 | self.devil = J1939Interface(device) 67 | self.reader = Reader() 68 | 69 | def do_save(self, arg): 70 | """ 71 | save settings to file. 72 | 73 | usage: save 74 | """ 75 | argv = arg.split() 76 | if len(argv) != 1: 77 | print("expected file name, see 'help save'") 78 | return 79 | file_name = argv[0] 80 | try: 81 | dill.dump(self.reader, open(file_name, "xb")) 82 | except FileExistsError: 83 | print("file already exists") 84 | return 85 | print("settings saved to {}".format(file_name)) 86 | 87 | def do_load(self, arg): 88 | """ 89 | load settings from a file. 90 | 91 | usage: load 92 | """ 93 | argv = arg.split() 94 | if len(argv) != 1: 95 | print("expected file name, see 'help save'") 96 | return 97 | file_name = argv[0] 98 | self.reader = dill.load(open(file_name, "rb")) 99 | print("settings loaded from {}".format(file_name)) 100 | 101 | def do_settings(self, arg): 102 | """Show the settings and each setting value""" 103 | print(self.reader.sm) 104 | return 105 | 106 | def do_set(self, arg): 107 | """ 108 | Provide a setting name and a value to set the setting. For a list of 109 | available settings and their current and default values see the 110 | settings command. 111 | 112 | example: 113 | set read_time 10 114 | set filter_src_addr 11,249 115 | """ 116 | argv = arg.split() 117 | name = argv[0] 118 | if len(argv) == 1: 119 | print("expected value, see 'help set'") 120 | return 121 | try: 122 | if self.reader.sm[name].datatype == int: 123 | self.reader.sm.set(name, int(argv[1])) 124 | elif self.reader.sm[name].datatype == float: 125 | self.reader.sm.set(name, float(argv[1])) 126 | elif self.reader.sm[name].datatype == bool: 127 | if argv[1] in ["True", "true", "on", 1]: 128 | self.reader.sm.set(name, True) 129 | elif argv[1] in ["False", "false", "off", 0]: 130 | self.reader.sm.set(name, False) 131 | else: 132 | self.reader.sm.set(name, argv[1]) 133 | elif self.reader.sm[name].datatype == list: 134 | values = argv[1].split(",") 135 | if type(self.reader.sm[name].default_value[0]) == int: 136 | new_values = [] 137 | for v in values: 138 | if v.startswith("0x"): 139 | new_values.append(int(v, 16)) 140 | else: 141 | new_values.append(int(v)) 142 | self.reader.sm.set(name, new_values) 143 | else: 144 | self.reader.sm.set(name, values) 145 | else: 146 | self.reader.sm.set(name, argv[1]) 147 | except ValueError as e: 148 | print("Could not set: {}".format(e)) 149 | return 150 | 151 | def do_unset(self, arg): 152 | """ 153 | Provide a setting name to set it back to it's default value. For a list of 154 | available settings and their current and default values see the 155 | settings command. 156 | 157 | example: 158 | unset read_time 159 | """ 160 | argv = arg.split() 161 | if len(argv) == 0: 162 | print("expected name, see 'help unset'") 163 | return 164 | name = argv[0] 165 | self.reader.sm.unset(name) 166 | 167 | def do_print_messages(self, arg): 168 | """Read and print all messages from CAN device, based on settings""" 169 | read_time = None 170 | num_messages = None 171 | if self.reader.sm["read_time"].updated: 172 | read_time = self.reader.sm.read_time 173 | if self.reader.sm["num_messages"].updated: 174 | num_messages = self.reader.sm.num_messages 175 | filters = {} 176 | if self.reader.sm["filter_can_id"].updated: 177 | filters["can_id"] = self.reader.sm.filter_can_id 178 | else: 179 | if self.reader.sm["filter_priority"].updated: 180 | filters["priority"] = self.reader.sm.filter_priority 181 | if self.reader.sm["filter_pdu_format"].updated: 182 | filters["pdu_format"] = self.reader.sm.filter_pdu_format 183 | if self.reader.sm["filter_pdu_specific"].updated: 184 | filters["pdu_specific"] = self.reader.sm.filter_pdu_specific 185 | if self.reader.sm["filter_src_addr"].updated: 186 | filters["src_addr"] = self.reader.sm.filter_src_addr 187 | if self.reader.sm["filter_data_snippet"].updated: 188 | filters["data_snippet"] = self.reader.sm.filter_data_snippet 189 | file_name = None 190 | if self.reader.sm["log_name"].updated: 191 | file_name = self.reader.sm.log_name 192 | try: 193 | self.devil.print_messages(self.reader.sm.abstract_TPM, read_time, num_messages, 194 | self.reader.sm.verbose, self.reader.sm.log_to_file, file_name, 195 | self.reader.sm.candump, **filters) 196 | except KeyboardInterrupt: 197 | return 198 | except FileExistsError: 199 | print("Log file already exists.") 200 | return 201 | 202 | @staticmethod 203 | def do_back(self, arg=None): 204 | """ 205 | Return to the main menu 206 | """ 207 | return True 208 | 209 | # TODO: add feature for viewing messages that have changed. Instead of scrolling, show a count and the bytes 210 | # that changed in the data between receives 211 | 212 | 213 | def main_mod(argv, device): 214 | rcli = ReadCommands(device) 215 | if len(argv) > 0: 216 | rcli.run_commands(argv) 217 | else: 218 | rcli.cmdloop() 219 | -------------------------------------------------------------------------------- /truckdevil/resources/json_files/src_addr_list.json: -------------------------------------------------------------------------------- 1 | { 2 | "0": "Engine #1", 3 | "1": "Engine #2", 4 | "2": "Turbocharger", 5 | "3": "Transmission #1", 6 | "4": "Transmission #2", 7 | "5": "Shift Console - Primary", 8 | "6": "Shift Console - Secondary", 9 | "7": "Power TakeOff - (Main or Rear)", 10 | "8": "Axle - Steering", 11 | "9": "Axle - Drive #1", 12 | "10": "Axle - Drive #2", 13 | "11": "Brakes - System Controller", 14 | "12": "Brakes - Steer Axle", 15 | "13": "Brakes - Drive axle #1", 16 | "14": "Brakes - Drive Axle #2", 17 | "15": "Retarder - Engine", 18 | "16": "Retarder - Driveline", 19 | "17": "Cruise Control", 20 | "18": "Fuel System", 21 | "19": "Steering Controller", 22 | "20": "Suspension - Steer Axle", 23 | "21": "Suspension - Drive Axle #1", 24 | "22": "Suspension - Drive Axle #2", 25 | "23": "Instrument Cluster #1", 26 | "24": "Trip Recorder", 27 | "25": "Passenger-Operator Climate Control #1", 28 | "26": "Alternator/Electrical Charging System", 29 | "27": "Aerodynamic Control", 30 | "28": "Vehicle Navigation", 31 | "29": "Vehicle Security", 32 | "30": "Electrical System", 33 | "31": "Starter System", 34 | "32": "Tractor-Trailer Bridge #1", 35 | "33": "Body Controller", 36 | "34": "Auxiliary Valve Control or Engine Air System Valve Control", 37 | "35": "Hitch Control", 38 | "36": "Power TakeOff (Front or Secondary)", 39 | "37": "Off Vehicle Gateway", 40 | "38": "Virtual Terminal (in cab)", 41 | "39": "Management Computer #1", 42 | "40": "Cab Display #1", 43 | "41": "Retarder, Exhaust, Engine #1", 44 | "42": "Headway Controller", 45 | "43": "On-Board Diagnostic Unit", 46 | "44": "Retarder, Exhaust, Engine #2", 47 | "45": "Endurance Braking System", 48 | "46": "Hydraulic Pump Controller", 49 | "47": "Suspension - System Controller #1", 50 | "48": "Pneumatic - System Controller", 51 | "49": "Cab Controller - Primary", 52 | "50": "Cab Controller - Secondary", 53 | "51": "Tire Pressure Controller", 54 | "52": "Ignition Control Module #1", 55 | "53": "Ignition Control Module #2", 56 | "54": "Seat Control #1", 57 | "55": "Lighting - Operator Controls", 58 | "56": "Rear Axle Steering Controller #1", 59 | "57": "Water Pump Controller", 60 | "58": "Passenger-Operator Climate Control #2", 61 | "59": "Transmission Display - Primary", 62 | "60": "Transmission Display - Secondary", 63 | "61": "Exhaust Emission Controller", 64 | "62": "Vehicle Dynamic Stability Controller", 65 | "63": "Oil Sensor", 66 | "64": "Suspension - System Controller #2", 67 | "65": "Information System Controller #1", 68 | "66": "Ramp Control", 69 | "67": "Clutch/Converter Unit", 70 | "68": "Auxiliary Heater #1", 71 | "69": "Auxiliary Heater #2", 72 | "70": "Engine Valve Controller", 73 | "71": "Chassis Controller #1", 74 | "72": "Chassis Controller #2", 75 | "73": "Propulsion Battery Charger", 76 | "74": "Communications Unit, Cellular", 77 | "75": "Communications Unit, Satellite", 78 | "76": "Communications Unit, Radio", 79 | "77": "Steering Column Unit", 80 | "78": "Fan Drive Controller", 81 | "79": "Seat Control #2", 82 | "80": "Parking brake controller", 83 | "81": "Aftertreatment #1 system gas intake", 84 | "82": "Aftertreatment #1 system gas outlet", 85 | "83": "Safety Restraint System", 86 | "84": "Cab Display #2", 87 | "85": "Diesel Particulate Filter Controller", 88 | "86": "Aftertreatment #2 system gas intake", 89 | "87": "Aftertreatment #2 system gas outlet", 90 | "88": "Safety Restraint System #2", 91 | "89": "Atmospheric Sensor", 92 | "90": "Powertrain Control Module", 93 | "91": "Power Systems Manager", 94 | "92": "SAE Reserved", 95 | "93": "SAE Reserved", 96 | "94": "SAE Reserved", 97 | "95": "SAE Reserved", 98 | "96": "SAE Reserved", 99 | "97": "SAE Reserved", 100 | "98": "SAE Reserved", 101 | "99": "SAE Reserved", 102 | "100": "SAE Reserved", 103 | "101": "SAE Reserved", 104 | "102": "SAE Reserved", 105 | "103": "SAE Reserved", 106 | "104": "SAE Reserved", 107 | "105": "SAE Reserved", 108 | "106": "SAE Reserved", 109 | "107": "SAE Reserved", 110 | "108": "SAE Reserved", 111 | "109": "SAE Reserved", 112 | "110": "SAE Reserved", 113 | "111": "SAE Reserved", 114 | "112": "SAE Reserved", 115 | "113": "SAE Reserved", 116 | "114": "SAE Reserved", 117 | "115": "SAE Reserved", 118 | "116": "SAE Reserved", 119 | "117": "SAE Reserved", 120 | "118": "SAE Reserved", 121 | "119": "SAE Reserved", 122 | "120": "SAE Reserved", 123 | "121": "SAE Reserved", 124 | "122": "SAE Reserved", 125 | "123": "SAE Reserved", 126 | "124": "SAE Reserved", 127 | "125": "SAE Reserved", 128 | "126": "SAE Reserved", 129 | "127": "SAE Reserved", 130 | "128": "SAE Reserved", 131 | "129": "SAE Reserved", 132 | "130": "SAE Reserved", 133 | "131": "SAE Reserved", 134 | "132": "SAE Reserved", 135 | "133": "SAE Reserved", 136 | "134": "SAE Reserved", 137 | "135": "SAE Reserved", 138 | "136": "SAE Reserved", 139 | "137": "SAE Reserved", 140 | "138": "SAE Reserved", 141 | "139": "SAE Reserved", 142 | "140": "SAE Reserved", 143 | "141": "SAE Reserved", 144 | "142": "SAE Reserved", 145 | "143": "SAE Reserved", 146 | "144": "SAE Reserved", 147 | "145": "SAE Reserved", 148 | "146": "SAE Reserved", 149 | "147": "SAE Reserved", 150 | "148": "SAE Reserved", 151 | "149": "SAE Reserved", 152 | "150": "SAE Reserved", 153 | "151": "SAE Reserved", 154 | "152": "SAE Reserved", 155 | "153": "SAE Reserved", 156 | "154": "SAE Reserved", 157 | "155": "SAE Reserved", 158 | "156": "SAE Reserved", 159 | "157": "SAE Reserved", 160 | "158": "SAE Reserved", 161 | "159": "Roadway Information System", 162 | "160": "Advanced emergency braking system", 163 | "161": "Fifth Wheel Smart Systems", 164 | "162": "Slope Sensor", 165 | "163": "Catalyst Fluid Sensor", 166 | "164": "On Board Diagnostic Unit #2", 167 | "165": "Rear Steering Axle Controller #2", 168 | "166": "Rear Steering Axle Controller #3", 169 | "167": "Instrument Cluster #2", 170 | "168": "Trailer #5 Bridge", 171 | "169": "Trailer #5 Lighting-electrical", 172 | "170": "Trailer #5 Brakes (ABS-EBS)", 173 | "171": "Trailer #5 Reefer", 174 | "172": "Trailer #5 Cargo", 175 | "173": "Trailer #5 Chassis-Suspension", 176 | "174": "Other Trailer #5 Devices", 177 | "175": "Other Trailer #5 Devices", 178 | "176": "Trailer #4 Bridge", 179 | "177": "Trailer #4 Lighting-electrical", 180 | "178": "Trailer #4 Brakes (ABS-EBS)", 181 | "179": "Trailer #4 Reefer", 182 | "180": "Trailer #4 Cargo", 183 | "181": "Trailer #4 Chassis-Suspension", 184 | "182": "Other Trailer #4 Devices", 185 | "183": "Other Trailer #4 Devices", 186 | "184": "Trailer #3 Bridge", 187 | "185": "Trailer #3 Lighting-electrical", 188 | "186": "Trailer #3 Brakes (ABS-EBS)", 189 | "187": "Trailer #3 Reefer", 190 | "188": "Trailer #3 Cargo", 191 | "189": "Trailer #3 Chassis-Suspension", 192 | "190": "Other Trailer #3 Devices", 193 | "191": "Other Trailer #3 Devices", 194 | "192": "Trailer #2 Bridge", 195 | "193": "Trailer #2 Lighting-electrical", 196 | "194": "Trailer #2 Brakes (ABS-EBS)", 197 | "195": "Trailer #2 Reefer", 198 | "196": "Trailer #2 Cargo", 199 | "197": "Trailer #2 Chassis-Suspension", 200 | "198": "Other Trailer #2 Devices", 201 | "199": "Other Trailer #2 Devices", 202 | "200": "Trailer #1 Bridge", 203 | "201": "Trailer #1 Lighting-electrical", 204 | "202": "Trailer #1 Brakes (ABS-EBS)", 205 | "203": "Trailer #1 Reefer", 206 | "204": "Trailer #1 Cargo", 207 | "205": "Trailer #1 Chassis-Suspension", 208 | "206": "Other Trailer #1 Devices", 209 | "207": "Other Trailer #1 Devices", 210 | "208": "SAE Reserved", 211 | "209": "SAE Reserved", 212 | "210": "SAE Reserved", 213 | "211": "SAE Reserved", 214 | "212": "SAE Reserved", 215 | "213": "SAE Reserved", 216 | "214": "SAE Reserved", 217 | "215": "SAE Reserved", 218 | "216": "SAE Reserved", 219 | "217": "SAE Reserved", 220 | "218": "SAE Reserved", 221 | "219": "SAE Reserved", 222 | "220": "SAE Reserved", 223 | "221": "SAE Reserved", 224 | "222": "SAE Reserved", 225 | "223": "SAE Reserved", 226 | "224": "SAE Reserved", 227 | "225": "SAE Reserved", 228 | "226": "SAE Reserved", 229 | "227": "SAE Reserved", 230 | "228": "Steering Input Unit", 231 | "229": "Body Controller #2", 232 | "230": "Body-to-Vehicle Interface Control", 233 | "231": "Articulation Turntable Control", 234 | "232": "Forward Road Image Processor", 235 | "233": "Door Controller #3", 236 | "234": "Door Controller #4", 237 | "235": "Tractor/Trailer Bridge #2", 238 | "236": "Door Controller #1", 239 | "237": "Door Controller #2", 240 | "238": "Tachograph", 241 | "239": "Electric Propulsion Control Unit #1", 242 | "240": "Electric Propulsion Control Unit #2", 243 | "241": "Electric Propulsion Control Unit #3", 244 | "242": "Electric Propulsion Control Unit #4", 245 | "243": "Battery Pack Monitor #1", 246 | "244": "Battery Pack Monitor #2 / APU #4", 247 | "245": "Battery Pack Monitor #3 / APU #3", 248 | "246": "Battery Pack Monitor #4 / APU #2", 249 | "247": "Auxiliary Power Unit (APU) #1", 250 | "248": "File Server / Printer", 251 | "249": "Off Board Diagnostic-Service Tool #1", 252 | "250": "Off Board Diagnostic-Service Tool #2", 253 | "251": "On-Board Data Logger", 254 | "252": "Reserved for Experimental Use", 255 | "253": "Reserved for OEM", 256 | "254": "Null Address", 257 | "255": "GLOBAL (All-Any Node)" 258 | } -------------------------------------------------------------------------------- /truckdevil/modules/ecu_discovery.py: -------------------------------------------------------------------------------- 1 | import copy 2 | import time 3 | import dill 4 | 5 | from j1939.j1939 import J1939Interface, J1939Message 6 | from libs.command import Command 7 | from libs.ecu import ECU 8 | 9 | 10 | def input_to_int(in_str: str) -> int: 11 | """ 12 | Takes user input string and converts to an integer 13 | """ 14 | if in_str.startswith("0x"): 15 | return int(in_str, 16) 16 | return int(in_str) 17 | 18 | 19 | class ECUDiscovery: 20 | def __init__(self): 21 | self._known_ecus = [] 22 | 23 | @property 24 | def known_ecus(self): 25 | return self._known_ecus 26 | 27 | def get_ecu_by_address(self, address): 28 | for e in self._known_ecus: 29 | if e.address == address: 30 | return e 31 | return None 32 | 33 | def get_all_addresses(self) -> list: 34 | """ 35 | returns all known ECU's addresses 36 | """ 37 | return [e.address for e in self._known_ecus] 38 | 39 | def add_known_ecu(self, ecu: ECU) -> ECU: 40 | """ 41 | Add an ECU to the list of known ECUs if it's not already there. If already added, return the one already found. 42 | """ 43 | for e in self._known_ecus: 44 | if e.address == ecu.address: 45 | return e 46 | self._known_ecus.append(ecu) 47 | return ecu 48 | 49 | 50 | class DiscoveryCommands(Command): 51 | intro = "Welcome to the ECU Discovery tool." 52 | prompt = "(truckdevil.ecu_discovery) " 53 | 54 | def __init__(self, device): 55 | super().__init__() 56 | self.devil = J1939Interface(device) 57 | self.ed = ECUDiscovery() 58 | 59 | 60 | def do_save(self, arg): 61 | """ 62 | save ECU information to file. 63 | 64 | usage: save 65 | """ 66 | argv = arg.split() 67 | if len(argv) != 1: 68 | print("expected file name, see 'help save'") 69 | return 70 | file_name = argv[0] 71 | try: 72 | dill.dump(self.ed, open(file_name, "xb")) 73 | except FileExistsError: 74 | print("file already exists") 75 | return 76 | print("ECU information saved to {}".format(file_name)) 77 | 78 | def do_load(self, arg): 79 | """ 80 | load ECU information from a file. 81 | 82 | usage: load 83 | """ 84 | argv = arg.split() 85 | if len(argv) != 1: 86 | print("expected file name, see 'help save'") 87 | return 88 | file_name = argv[0] 89 | self.ed = dill.load(open(file_name, "rb")) 90 | print("ECU information loaded from {}".format(file_name)) 91 | 92 | def do_view_ecus(self, arg): 93 | """ 94 | View information about all ECUs discovered on the bus. 95 | """ 96 | if len(self.ed.get_all_addresses()) == 0: 97 | print("no ecu information stored. See the passive_scan command.") 98 | return 99 | for ecu in self.ed.known_ecus: 100 | print(ecu) 101 | 102 | def do_passive_scan(self, arg): 103 | """ 104 | Passively scan the bus to find ECUs and store them in the list of discovered ecus. 105 | """ 106 | print("scanning...") 107 | self.devil.start_data_collection() 108 | time.sleep(10) 109 | messages = self.devil.stop_data_collection() 110 | known_addresses = self.ed.get_all_addresses() 111 | for m in messages: 112 | ecu = ECU(m.src_addr) 113 | self.ed.add_known_ecu(ecu) 114 | ecus_added = len(self.ed.get_all_addresses()) - len(known_addresses) 115 | print("scanning complete.") 116 | if ecus_added > 0: 117 | print("added {} new ecus.".format(ecus_added)) 118 | else: 119 | print("no new ecus found.") 120 | 121 | def do_active_scan(self, arg): 122 | """ 123 | Send Request for Address Claimed to discover ECUs and their NAME value 124 | """ 125 | print("scanning...") 126 | self.devil.start_data_collection() 127 | rqst = J1939Message(can_id=0x18EA0000, data="00EE00") 128 | for addr in range(0, 256): 129 | rqst.pdu_specific = addr 130 | self.devil.send_message(rqst) 131 | time.sleep(5) # Give ecus 5 seconds to respond 132 | messages = self.devil.stop_data_collection() 133 | known_addresses = self.ed.get_all_addresses() 134 | for m in messages: 135 | if m.pdu_format == 0xEE: 136 | ecu = ECU(m.src_addr) 137 | self.ed.add_known_ecu(ecu).address_claimed_response = m 138 | ecus_added = len(self.ed.get_all_addresses()) - len(known_addresses) 139 | print("scanning complete.") 140 | if ecus_added > 0: 141 | print("added {} new ecus.".format(ecus_added)) 142 | else: 143 | print("no new ecus found.") 144 | 145 | def do_find_boot_msg(self, arg): 146 | """ 147 | Provide the address of the ECU to discover it's reboot message in order to detect crashes. 148 | ECU must be reset during this test. 149 | 150 | usage: find_boot_msg
151 | """ 152 | argv = arg.split() 153 | if len(argv) == 0: 154 | print("expected address, see 'help find_boot_msg'") 155 | return 156 | address = input_to_int(argv[0]) 157 | if address < 0 or address > 255: 158 | print("address should be between 0-255.") 159 | return 160 | while True: 161 | val = input("please shut down the ECU, enter y when done or q to quit: ") 162 | if val == 'q' or val == 'quit': 163 | return 164 | if val != 'y' and val != 'yes': 165 | print('input not recognized.') 166 | continue 167 | break 168 | print("waiting for messages to stop transmitting...") 169 | while self.devil.read_one_message(timeout=0.5) is not None: 170 | continue 171 | self.devil.start_data_collection() 172 | while True: 173 | val = input("please power on the ECU, enter y when done or q to quit: ") 174 | if val == 'q' or val == 'quit': 175 | self.devil.stop_data_collection() 176 | if val != 'y' and val != 'yes': 177 | print('input not recognized.') 178 | continue 179 | break 180 | messages = self.devil.stop_data_collection() 181 | reboot_message = None 182 | for m in messages: 183 | if m.src_addr == address: 184 | reboot_message = m 185 | break 186 | if reboot_message is None: 187 | print("no messages detected for ECU {}.".format(address)) 188 | else: 189 | print("reboot message for ECU {}: \n{}".format(address, reboot_message)) 190 | 191 | def do_find_proprietary(self, arg): 192 | """ 193 | Provide the address of the ECU to discover the proprietary messages it's sending. 194 | Performs passive and active scanning techniques. 195 | 196 | usage: find_proprietary
197 | """ 198 | argv = arg.split() 199 | if len(argv) == 0: 200 | print("expected address, see 'help find_proprietary'") 201 | return 202 | address = input_to_int(argv[0]) 203 | if address < 0 or address > 255: 204 | print("address should be between 0-255.") 205 | return 206 | print("Scanning...") 207 | self.devil.start_data_collection() 208 | rqst = J1939Message(can_id=0x18EA0000, data="") 209 | rqst.pdu_specific = address 210 | prop_range = [] 211 | for i in range(0, 256): 212 | prop_range.append("{0:02x}EF00".format(i)) 213 | prop_range.append("{0:02x}FF00".format(i)) 214 | for data in prop_range: 215 | rqst.data = data 216 | self.devil.send_message(rqst) 217 | time.sleep(10) 218 | messages = self.devil.stop_data_collection() 219 | e = self.ed.get_ecu_by_address(address) 220 | num_prop_messages = 0 221 | if e is not None: 222 | num_prop_messages = len(e.prop_messages) 223 | for m in messages: 224 | if m.src_addr == address and (m.pdu_format == 0xEF or m.pdu_format == 0xFF): 225 | if e is None: 226 | e = ECU(address) 227 | self.ed.add_known_ecu(e) 228 | e.add_prop_message(m) 229 | discovered = len(e.prop_messages) - num_prop_messages 230 | if discovered > 0: 231 | print("discovered {} new unique proprietary messages.".format(discovered)) 232 | else: 233 | print("no additional proprietary messages found.") 234 | if len(e.prop_messages) > 0: 235 | print("Proprietary messages for address {}:".format(address)) 236 | for p in e.prop_messages: 237 | print(p) 238 | 239 | def do_find_uds(self, arg): 240 | # TODO: add progress bar 241 | """ 242 | Provide the address of the ECU to determine if it responds to a UDS session. 243 | Performs passive and active scanning techniques. 244 | 245 | usage: find_uds
246 | """ 247 | argv = arg.split() 248 | if len(argv) == 0: 249 | print("expected address, see 'help find_proprietary'") 250 | return 251 | address = input_to_int(argv[0]) 252 | if address < 0 or address > 255: 253 | print("address should be between 0-255.") 254 | return 255 | print("Scanning...") 256 | self.devil.start_data_collection() 257 | uds_pdu_formats = [0xDA, 0xDB, 0xCD, 0xCE, 0xEF] 258 | tester_present_request = "023E00FFFFFFFF" 259 | msg = J1939Message(0x180000F9, tester_present_request) 260 | msg.pdu_specific = address 261 | messages_to_send = [] 262 | for f in uds_pdu_formats: 263 | msg.pdu_format = f 264 | for pri in range(0, 8): 265 | for dp in range(0, 2): 266 | for rb in range(0, 2): 267 | msg.priority = pri 268 | msg.data_page_bit = dp 269 | msg.reserved_bit = rb 270 | messages_to_send.append(copy.copy(msg)) 271 | for m in messages_to_send: 272 | self.devil.send_message(m) 273 | time.sleep(0.5) 274 | time.sleep(5) 275 | messages = self.devil.stop_data_collection() 276 | uniq_responses = [] 277 | for m in messages: 278 | if m.pdu_format in uds_pdu_formats: 279 | if m.pdu_format == 0xEF and "027E" not in m.data: 280 | continue 281 | if m.can_id not in [rsp.can_id for rsp in uniq_responses]: 282 | uniq_responses.append(m) 283 | if len(uniq_responses) == 0: 284 | print("ECU did not respond to any tester present requests.") 285 | else: 286 | for u in uniq_responses: 287 | print("Tester present responses: \n{}".format(u)) 288 | 289 | def do_request_pgn(self, arg): 290 | """ 291 | Provide the address of the ECU and the PGN to request from it 292 | 293 | usage: request_pgn
294 | 295 | example (request ECU Identification Information from a brake controller): 296 | request_pgn 11 64965 297 | """ 298 | argv = arg.split() 299 | if len(argv) != 2: 300 | print("expected address and pgn, see 'help request_pgn'") 301 | return 302 | address = input_to_int(argv[0]) 303 | if address < 0 or address > 255: 304 | print("address should be between 0-255.") 305 | return 306 | pgn = input_to_int(argv[1]) 307 | if pgn < 0 or pgn > 0x01FFFF: 308 | print("pgn should be between 0x0 - 0x1FFFF") 309 | return 310 | print("requesting {} from {}...".format(pgn, address)) 311 | pgn_data = "{0:06x}".format(pgn) 312 | pgn_data = pgn_data[4:6] + pgn_data[2:4] + pgn_data[0:2] 313 | self.devil.start_data_collection() 314 | rqst = J1939Message(can_id=0x18EA0000, data=pgn_data) 315 | rqst.pdu_specific = address 316 | self.devil.send_message(rqst) 317 | time.sleep(5) 318 | messages = self.devil.stop_data_collection() 319 | ack_msg = None 320 | found_msg = None 321 | for m in messages: 322 | if m.pdu_format == 0xE8: 323 | ack_msg = m 324 | 325 | if m.pgn == pgn: 326 | found_msg = m 327 | if ack_msg is None: 328 | print("ECU did not ack the request.") 329 | else: 330 | print("Acknowledgement message: \n{}".format(ack_msg)) 331 | if found_msg is None: 332 | print("ECU did not send requested message.") 333 | else: 334 | print(found_msg) 335 | 336 | @staticmethod 337 | def do_back(self, arg=None): 338 | """ 339 | Return to the main menu 340 | """ 341 | return True 342 | 343 | def main_mod(argv, device): 344 | if device is None: 345 | print("add device first.") 346 | return 347 | dcli = DiscoveryCommands(device) 348 | if len(argv) > 0: 349 | dcli.run_commands(argv) 350 | else: 351 | dcli.cmdloop() 352 | -------------------------------------------------------------------------------- /truckdevil/resources/json_files/UDS_services.json: -------------------------------------------------------------------------------- 1 | { 2 | "10": { 3 | "service": "DiagnosticSessionControl", 4 | "description": "used to enable different diagnostic sessions in the server(s).", 5 | "serviceID": 16, 6 | "type": "request", 7 | "subfunction_supported": true, 8 | "data_bytes": [ 9 | "diagnosticSessionType" 10 | ] 11 | }, 12 | "11": { 13 | "service": "ECUReset", 14 | "description": "used by the client to request a server reset.", 15 | "serviceID": 17, 16 | "type": "request", 17 | "subfunction_supported": true, 18 | "data_bytes": [ 19 | "resetType" 20 | ] 21 | }, 22 | "14": { 23 | "service": "ClearDiagnosticInformation", 24 | "description": "used by the client to clear diagnostic information in one or multiple servers' memory.", 25 | "serviceID": 20, 26 | "type": "request", 27 | "subfunction_supported": false, 28 | "data_bytes": [ 29 | "groupOfDTC" 30 | ] 31 | }, 32 | "19": { 33 | "service": "ReadDTCInformation", 34 | "description": "allows a client to read the status of server resident Diagnostic Trouble Code information from any server, or group of servers within a vehicle.", 35 | "serviceID": 25, 36 | "type": "multiRequest", 37 | "subfunction_supported": true, 38 | "parameters": { 39 | "1": { 40 | "data_bytes": [ 41 | "reportType", 42 | "DTCStatusMask" 43 | ] 44 | }, 45 | "2": { 46 | "data_bytes": [ 47 | "reportType", 48 | "DTCStatusMask" 49 | ] 50 | }, 51 | "3": { 52 | "data_bytes": [ 53 | "reportType", 54 | "DTCMaskRecord", 55 | "DTCSnapshotRecordNumber" 56 | ] 57 | }, 58 | "4": { 59 | "data_bytes": [ 60 | "reportType", 61 | "DTCMaskRecord", 62 | "DTCSnapshotRecordNumber" 63 | ] 64 | }, 65 | "5": { 66 | "data_bytes": [ 67 | "reportType", 68 | "DTCStoredDataRecordNumber" 69 | ] 70 | }, 71 | "6": { 72 | "data_bytes": [ 73 | "reportType", 74 | "DTCMaskRecord", 75 | "DTCExtDataRecordNumber" 76 | ] 77 | }, 78 | "7": { 79 | "data_bytes": [ 80 | "reportType", 81 | "DTCSeverityMask", 82 | "DTCStatusMask" 83 | ] 84 | }, 85 | "8": { 86 | "data_bytes": [ 87 | "reportType", 88 | "DTCSeverityMask", 89 | "DTCStatusMask" 90 | ] 91 | }, 92 | "9": { 93 | "data_bytes": [ 94 | "reportType", 95 | "DTCMaskRecord" 96 | ] 97 | }, 98 | "10": { 99 | "data_bytes": [ 100 | "reportType" 101 | ] 102 | }, 103 | "11": { 104 | "data_bytes": [ 105 | "reportType" 106 | ] 107 | }, 108 | "12": { 109 | "data_bytes": [ 110 | "reportType" 111 | ] 112 | }, 113 | "13": { 114 | "data_bytes": [ 115 | "reportType" 116 | ] 117 | }, 118 | "14": { 119 | "data_bytes": [ 120 | "reportType" 121 | ] 122 | }, 123 | "15": { 124 | "data_bytes": [ 125 | "reportType", 126 | "DTCStatusMask" 127 | ] 128 | }, 129 | "16": { 130 | "data_bytes": [ 131 | "reportType", 132 | "DTCMaskRecord", 133 | "DTCExtDataRecordNumber" 134 | ] 135 | }, 136 | "17": { 137 | "data_bytes": [ 138 | "reportType", 139 | "DTCStatusMask" 140 | ] 141 | }, 142 | "18": { 143 | "data_bytes": [ 144 | "reportType", 145 | "DTCStatusMask" 146 | ] 147 | }, 148 | "19": { 149 | "data_bytes": [ 150 | "reportType", 151 | "DTCStatusMask" 152 | ] 153 | }, 154 | "20": { 155 | "data_bytes": [ 156 | "reportType" 157 | ] 158 | }, 159 | "21": { 160 | "data_bytes": [ 161 | "reportType" 162 | ] 163 | }, 164 | "22": { 165 | "data_bytes": [ 166 | "reportType", 167 | "DTCExtDataRecordNumber" 168 | ] 169 | }, 170 | "23": { 171 | "data_bytes": [ 172 | "reportType", 173 | "DTCStatusMask", 174 | "MemorySelection" 175 | ] 176 | }, 177 | "24": { 178 | "data_bytes": [ 179 | "reportType", 180 | "DTCMaskRecord", 181 | "DTCSnapshotRecordNumber", 182 | "MemorySelection" 183 | ] 184 | }, 185 | "25": { 186 | "data_bytes": [ 187 | "reportType", 188 | "DTCMaskRecord", 189 | "DTCExtDataRecordNumber", 190 | "MemorySelection" 191 | ] 192 | }, 193 | "66": { 194 | "data_bytes": [ 195 | "reportType", 196 | "FunctionalGroupIdentifier", 197 | "DTCStatusMask", 198 | "DTCSeverityMask" 199 | ] 200 | }, 201 | "55": { 202 | "data_bytes": [ 203 | "reportType", 204 | "FunctionalGroupIdentifier" 205 | ] 206 | } 207 | } 208 | }, 209 | "22": { 210 | "service": "ReadDataByIdentifier", 211 | "description": "allows the client to request data record values from the server identified by one or more dataIdentifiers.", 212 | "serviceID": 34, 213 | "type": "request", 214 | "subfunction_supported": false, 215 | "data_bytes": [ 216 | "dataIdentifier*" 217 | ] 218 | }, 219 | "23": { 220 | "service": "ReadMemoryByAddress", 221 | "description": "allows the client to request memory data from the server via provided starting address and size of memory to be read.", 222 | "serviceID": 35, 223 | "type": "request", 224 | "subfunction_supported": false, 225 | "data_bytes": [ 226 | "addressAndLengthFormatIdentifier", 227 | "memoryAddress", 228 | "memorySize" 229 | ] 230 | }, 231 | "24": { 232 | "service": "ReadScalingDataByIdentifier", 233 | "description": "allows the client to request scaling data record information from the server identified by a dataIdentifier.", 234 | "serviceID": 36, 235 | "type": "request", 236 | "subfunction_supported": false, 237 | "data_bytes": [ 238 | "dataIdentifier" 239 | ] 240 | }, 241 | "27": { 242 | "service": "SecurityAccess", 243 | "description": "provide a means to access data and/or diagnostic services, which have restricted access for security, emissions, or safety reasons.", 244 | "serviceID": 39, 245 | "type": "request", 246 | "subfunction_supported": true, 247 | "data_bytes": [ 248 | "securityAccessType", 249 | "securityAccessDataOrKey" 250 | ] 251 | }, 252 | "28": { 253 | "service": "CommunicationControl", 254 | "description": "switch on/off the transmission and/or the reception of certain messages of a server.", 255 | "serviceID": 40, 256 | "type": "request", 257 | "subfunction_supported": true, 258 | "data_bytes": [ 259 | "controlType", 260 | "communicationType", 261 | "nodeIdentificationNumber" 262 | ] 263 | }, 264 | "2A": { 265 | "service": "ReadDataByPeriodicIdentifier", 266 | "description": "allows the client to request the periodic transmission of data record values from the server identified by one or more periodicDataIdentifiers.", 267 | "serviceID": 42, 268 | "type": "request", 269 | "subfunction_supported": false, 270 | "data_bytes": [ 271 | "transmissionMode", 272 | "periodicDataIdentifier*" 273 | ] 274 | }, 275 | "2C": { 276 | "service": "DynamicallyDefineDataIdentifier", 277 | "description": "allows the client to dynamically define in a server a data identifier that can be read via the ReadDataByIdentifier service at a later time.", 278 | "serviceID": 44, 279 | "type": "multiRequest", 280 | "subfunction_supported": true, 281 | "parameters": { 282 | "1": { 283 | "data_bytes": [ 284 | "definitionType", 285 | "dynamicallyDefinedDataIdentifier", 286 | "sourceDataIdentifier*", 287 | "positionInSourceDataRecord*", 288 | "memorySize*" 289 | ] 290 | }, 291 | "2": { 292 | "data_bytes": [ 293 | "definitionType", 294 | "dynamicallyDefinedDataIdentifier", 295 | "addressAndLengthFormatIdentifier", 296 | "memoryAddress*", 297 | "memorySize*" 298 | ] 299 | }, 300 | "3": { 301 | "data_bytes": [ 302 | "definitionType", 303 | "dynamicallyDefinedDataIdentifier" 304 | ] 305 | } 306 | } 307 | }, 308 | "2E": { 309 | "service": "WriteDataByIdentifier", 310 | "description": "allows the client to write information into the server at an internal location specified by the provided data identifier.", 311 | "serviceID": 46, 312 | "type": "request", 313 | "subfunction_supported": false, 314 | "data_bytes": [ 315 | "dataIdentifier", 316 | "dataRecord*" 317 | ] 318 | }, 319 | "2F": { 320 | "service": "InputOutputControlByIdentifier", 321 | "description": "used by the client to substitute a value for an input signal, internal server function and/or force control to a value for an output (actuator) of an electronic system.", 322 | "serviceID": 47, 323 | "type": "request", 324 | "subfunction_supported": false, 325 | "data_bytes": [ 326 | "dataIdentifier", 327 | "controlOptionRecord", 328 | "controlEnableMaskRecord" 329 | ] 330 | }, 331 | "31": { 332 | "service": "RoutineControl", 333 | "description": "used by the client to execute a defined sequence of steps and obtain any relevant results.", 334 | "serviceID": 49, 335 | "type": "request", 336 | "subfunction_supported": true, 337 | "data_bytes": [ 338 | "routineControlType", 339 | "routineIdentifier", 340 | "routineControlOptionRecord" 341 | ] 342 | }, 343 | "34": { 344 | "service": "RequestDownload", 345 | "description": "used by the client to initiate a data transfer from the client to the server (download).", 346 | "serviceID": 52, 347 | "type": "request", 348 | "subfunction_supported": false, 349 | "data_bytes": [ 350 | "dataFormatIdentifier1", 351 | "addressAndLengthFormatIdentifier", 352 | "memoryAddress", 353 | "memorySize" 354 | ] 355 | }, 356 | "35": { 357 | "service": "RequestUpload", 358 | "description": "used by the client to initiate a data transfer from the server to the client (upload).", 359 | "serviceID": 53, 360 | "type": "request", 361 | "subfunction_supported": false, 362 | "data_bytes": [ 363 | "dataFormatIdentifier1", 364 | "addressAndLengthFormatIdentifier", 365 | "memoryAddress", 366 | "memorySize" 367 | ] 368 | }, 369 | "36": { 370 | "service": "TransferData", 371 | "description": "used by the client to transfer data either from the client to the server (download) or from the server to the client (upload).", 372 | "serviceID": 54, 373 | "type": "request", 374 | "subfunction_supported": false, 375 | "data_bytes": [ 376 | "blockSequenceCounter", 377 | "transferRequestParameterRecord" 378 | ] 379 | }, 380 | "37": { 381 | "service": "RequestTransferExit", 382 | "description": "used by the client to terminate a data transfer between client and server (upload or download).", 383 | "serviceID": 55, 384 | "type": "request", 385 | "subfunction_supported": false, 386 | "data_bytes": [ 387 | "transferRequestParameterRecord" 388 | ] 389 | }, 390 | "38": { 391 | "service": "RequestFileTransfer", 392 | "description": "used by the client to initiate a file data transfer from either the client to the server or from the server to the client (download or upload).", 393 | "serviceID": 56, 394 | "type": "request", 395 | "subfunction_supported": false, 396 | "data_bytes": [ 397 | "modeOfOperation", 398 | "filePathAndNameLength", 399 | "filePathAndName", 400 | "dataFormatIdentifier2", 401 | "fileSizeParameterLength", 402 | "fileSizeUncompressed", 403 | "fileSizeCompressed" 404 | ] 405 | }, 406 | "3D": { 407 | "service": "WriteMemoryByAddress", 408 | "description": "allows the client to write information into the server at one or more contiguous memory locations.", 409 | "serviceID": 61, 410 | "type": "request", 411 | "subfunction_supported": false, 412 | "data_bytes": [ 413 | "addressAndLengthFormatIdentifier", 414 | "memoryAddress", 415 | "memorySize", 416 | "dataRecord" 417 | ] 418 | }, 419 | "3E": { 420 | "service": "TesterPresent", 421 | "description": "used to indicate to a server that a client is still connected to the vehicle and that certain diagnostic services and/or communication that have been previously activated are to remain active.", 422 | "serviceID": 62, 423 | "type": "request", 424 | "subfunction_supported": true, 425 | "data_bytes": [ 426 | "zeroSubFunction" 427 | ] 428 | }, 429 | "50": { 430 | "service": "DiagnosticSessionControl", 431 | "description": "used to enable different diagnostic sessions in the server(s).", 432 | "serviceID": 80, 433 | "type": "response", 434 | "subfunction_supported": false, 435 | "data_bytes": [ 436 | "diagnosticSessionType", 437 | "sessionParameterRecord" 438 | ] 439 | }, 440 | "51": { 441 | "service": "ECUReset", 442 | "description": "used by the client to request a server reset.", 443 | "serviceID": 81, 444 | "type": "response", 445 | "subfunction_supported": false, 446 | "data_bytes": [ 447 | "resetType", 448 | "powerDownTime" 449 | ] 450 | }, 451 | "54": { 452 | "service": "ClearDiagnosticInformation", 453 | "description": "used by the client to clear diagnostic information in one or multiple servers' memory.", 454 | "serviceID": 84, 455 | "type": "response", 456 | "subfunction_supported": false, 457 | "data_bytes": [ 458 | ] 459 | }, 460 | "59": { 461 | "service": "ReadDTCInformation", 462 | "description": "allows a client to read the status of server resident Diagnostic Trouble Code information from any server, or group of servers within a vehicle.", 463 | "serviceID": 89, 464 | "type": "multiResponse", 465 | "subfunction_supported": false, 466 | "parameters": { 467 | "1": { 468 | "data_bytes": [ 469 | "reportType", 470 | "DTCStatusAvailabilityMask", 471 | "DTCFormatIdentifier", 472 | "DTCCount" 473 | ] 474 | }, 475 | "2": { 476 | "data_bytes": [ 477 | "reportType", 478 | "DTCStatusAvailabilityMask", 479 | "DTCAndStatusRecord*" 480 | ] 481 | }, 482 | "3": { 483 | "data_bytes": [ 484 | "reportType", 485 | "DTCRecord*", 486 | "DTCSnapshotRecordNumber*" 487 | ] 488 | }, 489 | "4": { 490 | "data_bytes": [ 491 | "reportType", 492 | "DTCAndStatusRecord", 493 | "DTCSnapshotRecordNumber*", 494 | "DTCSnapshotRecordNumberOfIdentifiers*", 495 | "DTCSnapshotRecord*" 496 | ] 497 | }, 498 | "5": { 499 | "data_bytes": [ 500 | "reportType", 501 | "DTCStoredDataRecordNumber*", 502 | "DTCAndStatusRecord*", 503 | "DTCStoredDataRecordNumberOfIdentifiers*", 504 | "DTCStoredDataRecord*" 505 | ] 506 | }, 507 | "6": { 508 | "data_bytes": [ 509 | "reportType", 510 | "DTCAndStatusRecord", 511 | "DTCExtDataRecordNumber*", 512 | "DTCExtDataRecord*" 513 | ] 514 | }, 515 | "7": { 516 | "data_bytes": [ 517 | "reportType", 518 | "DTCStatusAvailabilityMask", 519 | "DTCFormatIdentifier", 520 | "DTCCount" 521 | ] 522 | }, 523 | "8": { 524 | "data_bytes": [ 525 | "reportType", 526 | "DTCStatusAvailabilityMask", 527 | "DTCAndSeverityRecord1*" 528 | ] 529 | }, 530 | "9": { 531 | "data_bytes": [ 532 | "reportType", 533 | "DTCStatusAvailabilityMask", 534 | "DTCAndSeverityRecord1*" 535 | ] 536 | }, 537 | "10": { 538 | "data_bytes": [ 539 | "reportType", 540 | "DTCStatusAvailabilityMask", 541 | "DTCAndStatusRecord*" 542 | ] 543 | }, 544 | "11": { 545 | "data_bytes": [ 546 | "reportType", 547 | "DTCStatusAvailabilityMask", 548 | "DTCAndStatusRecord*" 549 | ] 550 | }, 551 | "12": { 552 | "data_bytes": [ 553 | "reportType", 554 | "DTCStatusAvailabilityMask", 555 | "DTCAndStatusRecord*" 556 | ] 557 | }, 558 | "13": { 559 | "data_bytes": [ 560 | "reportType", 561 | "DTCStatusAvailabilityMask", 562 | "DTCAndStatusRecord*" 563 | ] 564 | }, 565 | "14": { 566 | "data_bytes": [ 567 | "reportType", 568 | "DTCStatusAvailabilityMask", 569 | "DTCAndStatusRecord*" 570 | ] 571 | }, 572 | "15": { 573 | "data_bytes": [ 574 | "reportType", 575 | "DTCStatusAvailabilityMask", 576 | "DTCAndStatusRecord*" 577 | ] 578 | }, 579 | "16": { 580 | "data_bytes": [ 581 | "reportType", 582 | "DTCAndStatusRecord", 583 | "DTCExtDataRecordNumber*", 584 | "DTCExtDataRecord*" 585 | ] 586 | }, 587 | "17": { 588 | "data_bytes": [ 589 | "reportType", 590 | "DTCStatusAvailabilityMask", 591 | "DTCFormatIdentifier", 592 | "DTCCount" 593 | ] 594 | }, 595 | "18": { 596 | "data_bytes": [ 597 | "reportType", 598 | "DTCStatusAvailabilityMask", 599 | "DTCFormatIdentifier", 600 | "DTCCount" 601 | ] 602 | }, 603 | "19": { 604 | "data_bytes": [ 605 | "reportType", 606 | "DTCStatusAvailabilityMask", 607 | "DTCAndStatusRecord*" 608 | ] 609 | }, 610 | "20": { 611 | "data_bytes": [ 612 | "reportType", 613 | "DTCFaultDetectionCounterRecord*" 614 | ] 615 | }, 616 | "21": { 617 | "data_bytes": [ 618 | "reportType", 619 | "DTCStatusAvailabilityMask", 620 | "DTCAndStatusRecord*" 621 | ] 622 | }, 623 | "22": { 624 | "data_bytes": [ 625 | "reportType", 626 | "DTCExtDataRecordNumber", 627 | "DTCAndStatusRecord*", 628 | "DTCExtDataRecord*" 629 | ] 630 | }, 631 | "23": { 632 | "data_bytes": [ 633 | "reportType", 634 | "MemorySelection", 635 | "DTCStatusAvailabilityMask", 636 | "DTCAndStatusRecord*" 637 | ] 638 | }, 639 | "24": { 640 | "data_bytes": [ 641 | "reportType", 642 | "MemorySelection", 643 | "DTCAndStatusRecord", 644 | "DTCSnapshotRecordNumber*", 645 | "DTCSnapshotRecordNumberOfIdentifiers*", 646 | "DTCSnapshotRecord*" 647 | ] 648 | }, 649 | "25": { 650 | "data_bytes": [ 651 | "reportType", 652 | "MemorySelection", 653 | "DTCAndStatusRecord", 654 | "DTCExtDataRecordNumber", 655 | "DTCExtDataRecord*" 656 | ] 657 | }, 658 | "66": { 659 | "data_bytes": [ 660 | "reportType", 661 | "FunctionalGroupIdentifier", 662 | "DTCStatusAvailabilityMask", 663 | "DTCSeverityAvailabilityMask", 664 | "DTCFormatIdentifier", 665 | "DTCAndSeverityRecord2*" 666 | ] 667 | }, 668 | "85": { 669 | "data_bytes": [ 670 | "reportType", 671 | "FunctionalGroupIdentifier", 672 | "DTCStatusAvailabilityMask", 673 | "DTCFormatIdentifier", 674 | "DTCAndStatusRecord*" 675 | ] 676 | } 677 | } 678 | }, 679 | "62": { 680 | "service": "ReadDataByIdentifier", 681 | "description": "allows the client to request data record values from the server identified by one or more dataIdentifiers.", 682 | "serviceID": 98, 683 | "type": "response", 684 | "subfunction_supported": false, 685 | "data_bytes": [ 686 | "dataIdentifier*", 687 | "dataRecord*" 688 | ] 689 | }, 690 | "63": { 691 | "service": "ReadMemoryByAddress", 692 | "description": "allows the client to request memory data from the server via provided starting address and size of memory to be read.", 693 | "serviceID": 99, 694 | "type": "response", 695 | "subfunction_supported": false, 696 | "data_bytes": [ 697 | "dataRecord*" 698 | ] 699 | }, 700 | "64": { 701 | "service": "ReadScalingDataByIdentifier", 702 | "description": "allows the client to request scaling data record information from the server identified by a dataIdentifier.", 703 | "serviceID": 100, 704 | "type": "response", 705 | "subfunction_supported": false, 706 | "data_bytes": [ 707 | "dataIdentifier", 708 | "scalingByte*", 709 | "scalingByteExtension*" 710 | ] 711 | }, 712 | "67": { 713 | "service": "SecurityAccess", 714 | "description": "provide a means to access data and/or diagnostic services, which have restricted access for security, emissions, or safety reasons.", 715 | "serviceID": 103, 716 | "type": "response", 717 | "subfunction_supported": false, 718 | "data_bytes": [ 719 | "securityAccessType", 720 | "securitySeed" 721 | ] 722 | }, 723 | "68": { 724 | "service": "CommunicationControl", 725 | "description": "switch on/off the transmission and/or the reception of certain messages of a server.", 726 | "serviceID": 104, 727 | "type": "response", 728 | "subfunction_supported": false, 729 | "data_bytes": [ 730 | "controlType" 731 | ] 732 | }, 733 | "6A": { 734 | "service": "ReadDataByPeriodicIdentifier", 735 | "description": "allows the client to request the periodic transmission of data record values from the server identified by one or more periodicDataIdentifiers.", 736 | "serviceID": 106, 737 | "type": "response", 738 | "subfunction_supported": false, 739 | "data_bytes": [ 740 | ] 741 | }, 742 | "6C": { 743 | "service": "DynamicallyDefineDataIdentifier", 744 | "description": "allows the client to dynamically define in a server a data identifier that can be read via the ReadDataByIdentifier service at a later time.", 745 | "serviceID": 108, 746 | "type": "response", 747 | "subfunction_supported": false, 748 | "data_bytes": [ 749 | "definitionType", 750 | "dynamicallyDefinedDataIdentifier" 751 | ] 752 | }, 753 | "6E": { 754 | "service": "WriteDataByIdentifier", 755 | "description": "allows the client to write information into the server at an internal location specified by the provided data identifier.", 756 | "serviceID": 110, 757 | "type": "response", 758 | "subfunction_supported": false, 759 | "data_bytes": [ 760 | "dataIdentifier" 761 | ] 762 | }, 763 | "6F": { 764 | "service": "InputOutputControlByIdentifier", 765 | "description": "used by the client to substitute a value for an input signal, internal server function and/or force control to a value for an output (actuator) of an electronic system.", 766 | "serviceID": 111, 767 | "type": "response", 768 | "subfunction_supported": false, 769 | "data_bytes": [ 770 | "dataIdentifier", 771 | "controlStatusRecord" 772 | ] 773 | }, 774 | "71": { 775 | "service": "RoutineControl", 776 | "description": "used by the client to execute a defined sequence of steps and obtain any relevant results.", 777 | "serviceID": 113, 778 | "type": "response", 779 | "subfunction_supported": false, 780 | "data_bytes": [ 781 | "routineControlType", 782 | "routineIdentifier", 783 | "routineInfo", 784 | "routineStatusRecord" 785 | ] 786 | }, 787 | "74": { 788 | "service": "RequestDownload", 789 | "description": "used by the client to initiate a data transfer from the client to the server (download).", 790 | "serviceID": 116, 791 | "type": "response", 792 | "subfunction_supported": false, 793 | "data_bytes": [ 794 | "lengthFormatIdentifier", 795 | "maxNumberOfBlockLength" 796 | ] 797 | }, 798 | "75": { 799 | "service": "RequestUpload", 800 | "description": "used by the client to initiate a data transfer from the server to the client (upload).", 801 | "serviceID": 117, 802 | "type": "response", 803 | "subfunction_supported": false, 804 | "data_bytes": [ 805 | "lengthFormatIdentifier", 806 | "maxNumberOfBlockLength" 807 | ] 808 | }, 809 | "76": { 810 | "service": "TransferData", 811 | "description": "used by the client to transfer data either from the client to the server (download) or from the server to the client (upload).", 812 | "serviceID": 118, 813 | "type": "response", 814 | "subfunction_supported": false, 815 | "data_bytes": [ 816 | "blockSequenceCounter", 817 | "transferResponseParameterRecord" 818 | ] 819 | }, 820 | "77": { 821 | "service": "RequestTransferExit", 822 | "description": "used by the client to terminate a data transfer between client and server (upload or download).", 823 | "serviceID": 119, 824 | "type": "response", 825 | "subfunction_supported": false, 826 | "data_bytes": [ 827 | "transferResponseParameterRecord" 828 | ] 829 | }, 830 | "78": { 831 | "service": "RequestFileTransfer", 832 | "description": "used by the client to initiate a file data transfer from either the client to the server or from the server to the client (download or upload).", 833 | "serviceID": 120, 834 | "type": "response", 835 | "subfunction_supported": false, 836 | "data_bytes": [ 837 | "modeOfOperation", 838 | "lengthFormatIdentifier", 839 | "maxNumberOfBlockLength", 840 | "dataFormatIdentifier1", 841 | "fileSizeOrDirInfoParameterLength", 842 | "fileSizeUncompressedOrDirInfoLength", 843 | "fileSizeCompressed" 844 | ] 845 | }, 846 | "7D": { 847 | "service": "WriteMemoryByAddress", 848 | "description": "allows the client to write information into the server at one or more contiguous memory locations.", 849 | "serviceID": 125, 850 | "type": "response", 851 | "subfunction_supported": false, 852 | "data_bytes": [ 853 | "addressAndLengthFormatIdentifier", 854 | "memoryAddress", 855 | "memorySize" 856 | ] 857 | }, 858 | "7E": { 859 | "service": "TesterPresent", 860 | "description": "used to indicate to a server that a client is still connected to the vehicle and that certain diagnostic services and/or communication that have been previously activated are to remain active.", 861 | "serviceID": 126, 862 | "type": "response", 863 | "subfunction_supported": false, 864 | "data_bytes": [ 865 | "zeroSubFunction" 866 | ] 867 | }, 868 | "83": { 869 | "service": "AccessTimingParameter", 870 | "description": "used to read and change the default timing parameters of a communication link for the duration this communication link is active.", 871 | "serviceID": 131, 872 | "type": "request", 873 | "subfunction_supported": true, 874 | "data_bytes": [ 875 | "timingParameterAccessType", 876 | "timingParameterRequestRecord" 877 | ] 878 | }, 879 | "84": { 880 | "service": "SecuredDataTransmission", 881 | "description": "used to transmit data that is protected against attacks from third parties - which could endanger data security.", 882 | "serviceID": 132, 883 | "type": "request", 884 | "subfunction_supported": false, 885 | "data_bytes": [ 886 | "securityDataRequestRecord" 887 | ] 888 | }, 889 | "85": { 890 | "service": "ControlDTCSetting", 891 | "description": "used by a client to stop or resume the updating of DTC status bits in the server.", 892 | "serviceID": 133, 893 | "type": "request", 894 | "subfunction_supported": true, 895 | "data_bytes": [ 896 | "DTCSettingType", 897 | "DTCSettingControlOptionRecord" 898 | ] 899 | }, 900 | "86": { 901 | "service": "ResponseOnEvent", 902 | "description": "requests a server to start or stop transmission of responses on a specified event.", 903 | "serviceID": 134, 904 | "type": "request", 905 | "subfunction_supported": true, 906 | "data_bytes": [ 907 | "eventType", 908 | "eventWindowTime", 909 | "eventTypeRecord", 910 | "serviceToRespondToRecord" 911 | ] 912 | }, 913 | "87": { 914 | "service": "LinkControl", 915 | "description": "used to control the communication between the client and server in order to gain bus bandwidth for diagnostic purposes.", 916 | "serviceID": 135, 917 | "type": "multiRequest", 918 | "subfunction_supported": true, 919 | "parameters": { 920 | "1": { 921 | "data_bytes": [ 922 | "linkControlType", 923 | "linkControlModeIdentifier" 924 | ] 925 | }, 926 | "2": { 927 | "data_bytes": [ 928 | "linkControlType", 929 | "linkRecord" 930 | ] 931 | }, 932 | "3": { 933 | "data_bytes": [ 934 | "linkControlType" 935 | ] 936 | } 937 | } 938 | }, 939 | "C3": { 940 | "service": "AccessTimingParameter", 941 | "description": "used to read and change the default timing parameters of a communication link for the duration this communication link is active.", 942 | "serviceID": 195, 943 | "type": "response", 944 | "subfunction_supported": false, 945 | "data_bytes": [ 946 | "timingParameterAccessType", 947 | "timingParameterResponseRecord" 948 | ] 949 | }, 950 | "C4": { 951 | "service": "SecuredDataTransmission", 952 | "description": "used to transmit data that is protected against attacks from third parties - which could endanger data security.", 953 | "serviceID": 196, 954 | "type": "response", 955 | "subfunction_supported": false, 956 | "data_bytes": [ 957 | "securityDataResponseRecord" 958 | ] 959 | }, 960 | "C5": { 961 | "service": "ControlDTCSetting", 962 | "description": "used by a client to stop or resume the updating of DTC status bits in the server.", 963 | "serviceID": 197, 964 | "type": "response", 965 | "subfunction_supported": false, 966 | "data_bytes": [ 967 | "DTCSettingType" 968 | ] 969 | }, 970 | "C6": { 971 | "service": "ResponseOnEvent", 972 | "description": "requests a server to start or stop transmission of responses on a specified event.", 973 | "serviceID": 198, 974 | "type": "multiResponse", 975 | "subfunction_supported": false, 976 | "parameters": { 977 | "4": { 978 | "data_bytes": [ 979 | "eventType", 980 | "numberOfActivatedEvents", 981 | "eventTypeOfActiveEvents*", 982 | "eventWindowTime*", 983 | "eventTypeRecord*", 984 | "serviceToRespondToRecord*" 985 | ] 986 | }, 987 | "others": { 988 | "data_bytes": [ 989 | "eventType", 990 | "numberOfIdentifiedEvents", 991 | "eventWindowTime", 992 | "eventTypeRecord", 993 | "serviceToRespondToRecord" 994 | ] 995 | } 996 | } 997 | }, 998 | "C7": { 999 | "service": "LinkControl", 1000 | "description": "used to control the communication between the client and server in order to gain bus bandwidth for diagnostic purposes.", 1001 | "serviceID": 199, 1002 | "type": "response", 1003 | "subfunction_supported": false, 1004 | "data_bytes": [ 1005 | "linkControlType" 1006 | ] 1007 | } 1008 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /truckdevil/resources/json_files/UDS_NRC.json: -------------------------------------------------------------------------------- 1 | { 2 | "00": { 3 | "nrc": 0, 4 | "name": "positiveResponse", 5 | "description": "shall not be used in a negative response message." 6 | }, 7 | "01": { 8 | "nrc": 1, 9 | "name": "ISOSAEReserved", 10 | "description": "reserved by this document for future definition." 11 | }, 12 | "02": { 13 | "nrc": 2, 14 | "name": "ISOSAEReserved", 15 | "description": "reserved by this document for future definition." 16 | }, 17 | "03": { 18 | "nrc": 3, 19 | "name": "ISOSAEReserved", 20 | "description": "reserved by this document for future definition." 21 | }, 22 | "04": { 23 | "nrc": 4, 24 | "name": "ISOSAEReserved", 25 | "description": "reserved by this document for future definition." 26 | }, 27 | "05": { 28 | "nrc": 5, 29 | "name": "ISOSAEReserved", 30 | "description": "reserved by this document for future definition." 31 | }, 32 | "06": { 33 | "nrc": 6, 34 | "name": "ISOSAEReserved", 35 | "description": "reserved by this document for future definition." 36 | }, 37 | "07": { 38 | "nrc": 7, 39 | "name": "ISOSAEReserved", 40 | "description": "reserved by this document for future definition." 41 | }, 42 | "08": { 43 | "nrc": 8, 44 | "name": "ISOSAEReserved", 45 | "description": "reserved by this document for future definition." 46 | }, 47 | "09": { 48 | "nrc": 9, 49 | "name": "ISOSAEReserved", 50 | "description": "reserved by this document for future definition." 51 | }, 52 | "0A": { 53 | "nrc": 10, 54 | "name": "ISOSAEReserved", 55 | "description": "reserved by this document for future definition." 56 | }, 57 | "0B": { 58 | "nrc": 11, 59 | "name": "ISOSAEReserved", 60 | "description": "reserved by this document for future definition." 61 | }, 62 | "0C": { 63 | "nrc": 12, 64 | "name": "ISOSAEReserved", 65 | "description": "reserved by this document for future definition." 66 | }, 67 | "0D": { 68 | "nrc": 13, 69 | "name": "ISOSAEReserved", 70 | "description": "reserved by this document for future definition." 71 | }, 72 | "0E": { 73 | "nrc": 14, 74 | "name": "ISOSAEReserved", 75 | "description": "reserved by this document for future definition." 76 | }, 77 | "0F": { 78 | "nrc": 15, 79 | "name": "ISOSAEReserved", 80 | "description": "reserved by this document for future definition." 81 | }, 82 | "10": { 83 | "nrc": 16, 84 | "name": "generalReject", 85 | "description": "indicates that the requested action has been rejected by the server." 86 | }, 87 | "11": { 88 | "nrc": 17, 89 | "name": "serviceNotSupported", 90 | "description": "the server does not support the requested service." 91 | }, 92 | "12": { 93 | "nrc": 18, 94 | "name": "sub-functionNotSupported", 95 | "description": "the server does not support the service specific parameters of the request message." 96 | }, 97 | "13": { 98 | "nrc": 19, 99 | "name": "incorrectMessageLengthOrInvalidFormat", 100 | "description": "the length of the received request message does not match the prescribed length for the specified service or the format does not match." 101 | }, 102 | "14": { 103 | "nrc": 20, 104 | "name": "responseTooLong", 105 | "description": "the response to be generated exceeds the maximum number of bytes available by the underlying network layer." 106 | }, 107 | "15": { 108 | "nrc": 21, 109 | "name": "ISOSAEReserved", 110 | "description": "reserved by this document for future definition." 111 | }, 112 | "16": { 113 | "nrc": 22, 114 | "name": "ISOSAEReserved", 115 | "description": "reserved by this document for future definition." 116 | }, 117 | "17": { 118 | "nrc": 23, 119 | "name": "ISOSAEReserved", 120 | "description": "reserved by this document for future definition." 121 | }, 122 | "18": { 123 | "nrc": 24, 124 | "name": "ISOSAEReserved", 125 | "description": "reserved by this document for future definition." 126 | }, 127 | "19": { 128 | "nrc": 25, 129 | "name": "ISOSAEReserved", 130 | "description": "reserved by this document for future definition." 131 | }, 132 | "1A": { 133 | "nrc": 26, 134 | "name": "ISOSAEReserved", 135 | "description": "reserved by this document for future definition." 136 | }, 137 | "1B": { 138 | "nrc": 27, 139 | "name": "ISOSAEReserved", 140 | "description": "reserved by this document for future definition." 141 | }, 142 | "1C": { 143 | "nrc": 28, 144 | "name": "ISOSAEReserved", 145 | "description": "reserved by this document for future definition." 146 | }, 147 | "1D": { 148 | "nrc": 29, 149 | "name": "ISOSAEReserved", 150 | "description": "reserved by this document for future definition." 151 | }, 152 | "1E": { 153 | "nrc": 30, 154 | "name": "ISOSAEReserved", 155 | "description": "reserved by this document for future definition." 156 | }, 157 | "1F": { 158 | "nrc": 31, 159 | "name": "ISOSAEReserved", 160 | "description": "reserved by this document for future definition." 161 | }, 162 | "20": { 163 | "nrc": 32, 164 | "name": "ISOSAEReserved", 165 | "description": "reserved by this document for future definition." 166 | }, 167 | "21": { 168 | "nrc": 33, 169 | "name": "busyRepeatRequest", 170 | "description": "the server is temporarily too busy to perform the requested operation." 171 | }, 172 | "22": { 173 | "nrc": 34, 174 | "name": "conditionsNotCorrect", 175 | "description": "the server prerequisite conditions are not met." 176 | }, 177 | "23": { 178 | "nrc": 35, 179 | "name": "ISOSAEReserved", 180 | "description": "reserved by this document for future definition." 181 | }, 182 | "24": { 183 | "nrc": 36, 184 | "name": "requestSequenceError", 185 | "description": "the server expects a different sequence of request messages or message as sent by the client." 186 | }, 187 | "25": { 188 | "nrc": 37, 189 | "name": "noResponseFromSubnetComponent", 190 | "description": "the server has received the request but the requested action could not be performed by the server as a subnet component which is necessary to supply the requested info did not respond within the specified time." 191 | }, 192 | "26": { 193 | "nrc": 38, 194 | "name": "failurePreventsExecutionOfRequestedAction", 195 | "description": "a failure condition, identified by a DTC, has occured and that this failure condition prevents the server from performing the requested action." 196 | }, 197 | "27": { 198 | "nrc": 39, 199 | "name": "ISOSAEReserved", 200 | "description": "reserved by this document for future definition." 201 | }, 202 | "28": { 203 | "nrc": 40, 204 | "name": "ISOSAEReserved", 205 | "description": "reserved by this document for future definition." 206 | }, 207 | "29": { 208 | "nrc": 41, 209 | "name": "ISOSAEReserved", 210 | "description": "reserved by this document for future definition." 211 | }, 212 | "2A": { 213 | "nrc": 42, 214 | "name": "ISOSAEReserved", 215 | "description": "reserved by this document for future definition." 216 | }, 217 | "2B": { 218 | "nrc": 43, 219 | "name": "ISOSAEReserved", 220 | "description": "reserved by this document for future definition." 221 | }, 222 | "2C": { 223 | "nrc": 44, 224 | "name": "ISOSAEReserved", 225 | "description": "reserved by this document for future definition." 226 | }, 227 | "2D": { 228 | "nrc": 45, 229 | "name": "ISOSAEReserved", 230 | "description": "reserved by this document for future definition." 231 | }, 232 | "2E": { 233 | "nrc": 46, 234 | "name": "ISOSAEReserved", 235 | "description": "reserved by this document for future definition." 236 | }, 237 | "2F": { 238 | "nrc": 47, 239 | "name": "ISOSAEReserved", 240 | "description": "reserved by this document for future definition." 241 | }, 242 | "30": { 243 | "nrc": 48, 244 | "name": "ISOSAEReserved", 245 | "description": "reserved by this document for future definition." 246 | }, 247 | "31": { 248 | "nrc": 49, 249 | "name": "requestOutOfRange", 250 | "description": "the server has detected that the request message contains a parameter which attempts to substitute a value beyond its range of authority, or which attempts to access a dataIdentifier/routineIdentifier that is not supported or not supported in active session." 251 | }, 252 | "32": { 253 | "nrc": 50, 254 | "name": "ISOSAEReserved", 255 | "description": "reserved by this document for future definition." 256 | }, 257 | "33": { 258 | "nrc": 51, 259 | "name": "securityAccessDenied", 260 | "description": "the server's security strategy has not been satisifed by the client." 261 | }, 262 | "34": { 263 | "nrc": 52, 264 | "name": "ISOSAEReserved", 265 | "description": "reserved by this document for future definition." 266 | }, 267 | "35": { 268 | "nrc": 53, 269 | "name": "invalidKey", 270 | "description": "the server has not given security access because the key sent by the client did not match with the key in the server's memory." 271 | }, 272 | "36": { 273 | "nrc": 54, 274 | "name": "exceedNumberOfAttempts", 275 | "description": "the client has unsuccessfully attempted to gain security access more times than the server's security strategy will allow." 276 | }, 277 | "37": { 278 | "nrc": 55, 279 | "name": "requiredTimeDelayNotExpired", 280 | "description": "the client's latest attempt to gain security access was initiated before the server's required timeout period had elapsed." 281 | }, 282 | "38": { 283 | "nrc": 56, 284 | "name": "reservedByExtendedDataLinkSecurityDocument", 285 | "description": "reserved by extended data link security." 286 | }, 287 | "39": { 288 | "nrc": 57, 289 | "name": "reservedByExtendedDataLinkSecurityDocument", 290 | "description": "reserved by extended data link security." 291 | }, 292 | "3A": { 293 | "nrc": 58, 294 | "name": "reservedByExtendedDataLinkSecurityDocument", 295 | "description": "reserved by extended data link security." 296 | }, 297 | "3B": { 298 | "nrc": 59, 299 | "name": "reservedByExtendedDataLinkSecurityDocument", 300 | "description": "reserved by extended data link security." 301 | }, 302 | "3C": { 303 | "nrc": 60, 304 | "name": "reservedByExtendedDataLinkSecurityDocument", 305 | "description": "reserved by extended data link security." 306 | }, 307 | "3D": { 308 | "nrc": 61, 309 | "name": "reservedByExtendedDataLinkSecurityDocument", 310 | "description": "reserved by extended data link security." 311 | }, 312 | "3E": { 313 | "nrc": 62, 314 | "name": "reservedByExtendedDataLinkSecurityDocument", 315 | "description": "reserved by extended data link security." 316 | }, 317 | "3F": { 318 | "nrc": 63, 319 | "name": "reservedByExtendedDataLinkSecurityDocument", 320 | "description": "reserved by extended data link security." 321 | }, 322 | "40": { 323 | "nrc": 64, 324 | "name": "reservedByExtendedDataLinkSecurityDocument", 325 | "description": "reserved by extended data link security." 326 | }, 327 | "41": { 328 | "nrc": 65, 329 | "name": "reservedByExtendedDataLinkSecurityDocument", 330 | "description": "reserved by extended data link security." 331 | }, 332 | "42": { 333 | "nrc": 66, 334 | "name": "reservedByExtendedDataLinkSecurityDocument", 335 | "description": "reserved by extended data link security." 336 | }, 337 | "43": { 338 | "nrc": 67, 339 | "name": "reservedByExtendedDataLinkSecurityDocument", 340 | "description": "reserved by extended data link security." 341 | }, 342 | "44": { 343 | "nrc": 68, 344 | "name": "reservedByExtendedDataLinkSecurityDocument", 345 | "description": "reserved by extended data link security." 346 | }, 347 | "45": { 348 | "nrc": 69, 349 | "name": "reservedByExtendedDataLinkSecurityDocument", 350 | "description": "reserved by extended data link security." 351 | }, 352 | "46": { 353 | "nrc": 70, 354 | "name": "reservedByExtendedDataLinkSecurityDocument", 355 | "description": "reserved by extended data link security." 356 | }, 357 | "47": { 358 | "nrc": 71, 359 | "name": "reservedByExtendedDataLinkSecurityDocument", 360 | "description": "reserved by extended data link security." 361 | }, 362 | "48": { 363 | "nrc": 72, 364 | "name": "reservedByExtendedDataLinkSecurityDocument", 365 | "description": "reserved by extended data link security." 366 | }, 367 | "49": { 368 | "nrc": 73, 369 | "name": "reservedByExtendedDataLinkSecurityDocument", 370 | "description": "reserved by extended data link security." 371 | }, 372 | "4A": { 373 | "nrc": 74, 374 | "name": "reservedByExtendedDataLinkSecurityDocument", 375 | "description": "reserved by extended data link security." 376 | }, 377 | "4B": { 378 | "nrc": 75, 379 | "name": "reservedByExtendedDataLinkSecurityDocument", 380 | "description": "reserved by extended data link security." 381 | }, 382 | "4C": { 383 | "nrc": 76, 384 | "name": "reservedByExtendedDataLinkSecurityDocument", 385 | "description": "reserved by extended data link security." 386 | }, 387 | "4D": { 388 | "nrc": 77, 389 | "name": "reservedByExtendedDataLinkSecurityDocument", 390 | "description": "reserved by extended data link security." 391 | }, 392 | "4E": { 393 | "nrc": 78, 394 | "name": "reservedByExtendedDataLinkSecurityDocument", 395 | "description": "reserved by extended data link security." 396 | }, 397 | "4F": { 398 | "nrc": 79, 399 | "name": "reservedByExtendedDataLinkSecurityDocument", 400 | "description": "reserved by extended data link security." 401 | }, 402 | "50": { 403 | "nrc": 80, 404 | "name": "ISOSAEReserved", 405 | "description": "reserved by this document for future definition." 406 | }, 407 | "51": { 408 | "nrc": 81, 409 | "name": "ISOSAEReserved", 410 | "description": "reserved by this document for future definition." 411 | }, 412 | "52": { 413 | "nrc": 82, 414 | "name": "ISOSAEReserved", 415 | "description": "reserved by this document for future definition." 416 | }, 417 | "53": { 418 | "nrc": 84, 419 | "name": "ISOSAEReserved", 420 | "description": "reserved by this document for future definition." 421 | }, 422 | "54": { 423 | "nrc": 84, 424 | "name": "ISOSAEReserved", 425 | "description": "reserved by this document for future definition." 426 | }, 427 | "55": { 428 | "nrc": 85, 429 | "name": "ISOSAEReserved", 430 | "description": "reserved by this document for future definition." 431 | }, 432 | "56": { 433 | "nrc": 86, 434 | "name": "ISOSAEReserved", 435 | "description": "reserved by this document for future definition." 436 | }, 437 | "57": { 438 | "nrc": 87, 439 | "name": "ISOSAEReserved", 440 | "description": "reserved by this document for future definition." 441 | }, 442 | "58": { 443 | "nrc": 88, 444 | "name": "ISOSAEReserved", 445 | "description": "reserved by this document for future definition." 446 | }, 447 | "59": { 448 | "nrc": 89, 449 | "name": "ISOSAEReserved", 450 | "description": "reserved by this document for future definition." 451 | }, 452 | "5A": { 453 | "nrc": 90, 454 | "name": "ISOSAEReserved", 455 | "description": "reserved by this document for future definition." 456 | }, 457 | "5B": { 458 | "nrc": 91, 459 | "name": "ISOSAEReserved", 460 | "description": "reserved by this document for future definition." 461 | }, 462 | "5C": { 463 | "nrc": 92, 464 | "name": "ISOSAEReserved", 465 | "description": "reserved by this document for future definition." 466 | }, 467 | "5D": { 468 | "nrc": 93, 469 | "name": "ISOSAEReserved", 470 | "description": "reserved by this document for future definition." 471 | }, 472 | "5E": { 473 | "nrc": 94, 474 | "name": "ISOSAEReserved", 475 | "description": "reserved by this document for future definition." 476 | }, 477 | "5F": { 478 | "nrc": 95, 479 | "name": "ISOSAEReserved", 480 | "description": "reserved by this document for future definition." 481 | }, 482 | "60": { 483 | "nrc": 96, 484 | "name": "ISOSAEReserved", 485 | "description": "reserved by this document for future definition." 486 | }, 487 | "61": { 488 | "nrc": 97, 489 | "name": "ISOSAEReserved", 490 | "description": "reserved by this document for future definition." 491 | }, 492 | "62": { 493 | "nrc": 98, 494 | "name": "ISOSAEReserved", 495 | "description": "reserved by this document for future definition." 496 | }, 497 | "63": { 498 | "nrc": 99, 499 | "name": "ISOSAEReserved", 500 | "description": "reserved by this document for future definition." 501 | }, 502 | "64": { 503 | "nrc": 100, 504 | "name": "ISOSAEReserved", 505 | "description": "reserved by this document for future definition." 506 | }, 507 | "65": { 508 | "nrc": 101, 509 | "name": "ISOSAEReserved", 510 | "description": "reserved by this document for future definition." 511 | }, 512 | "66": { 513 | "nrc": 102, 514 | "name": "ISOSAEReserved", 515 | "description": "reserved by this document for future definition." 516 | }, 517 | "67": { 518 | "nrc": 103, 519 | "name": "ISOSAEReserved", 520 | "description": "reserved by this document for future definition." 521 | }, 522 | "68": { 523 | "nrc": 104, 524 | "name": "ISOSAEReserved", 525 | "description": "reserved by this document for future definition." 526 | }, 527 | "69": { 528 | "nrc": 105, 529 | "name": "ISOSAEReserved", 530 | "description": "reserved by this document for future definition." 531 | }, 532 | "6A": { 533 | "nrc": 106, 534 | "name": "ISOSAEReserved", 535 | "description": "reserved by this document for future definition." 536 | }, 537 | "6B": { 538 | "nrc": 107, 539 | "name": "ISOSAEReserved", 540 | "description": "reserved by this document for future definition." 541 | }, 542 | "6C": { 543 | "nrc": 108, 544 | "name": "ISOSAEReserved", 545 | "description": "reserved by this document for future definition." 546 | }, 547 | "6D": { 548 | "nrc": 109, 549 | "name": "ISOSAEReserved", 550 | "description": "reserved by this document for future definition." 551 | }, 552 | "6E": { 553 | "nrc": 110, 554 | "name": "ISOSAEReserved", 555 | "description": "reserved by this document for future definition." 556 | }, 557 | "6F": { 558 | "nrc": 111, 559 | "name": "ISOSAEReserved", 560 | "description": "reserved by this document for future definition." 561 | }, 562 | "70": { 563 | "nrc": 112, 564 | "name": "uploadDownloadNotAccepted", 565 | "description": "indicates that an attempt to upload or download to a server's memory cannot be accomplished due to some fault conditions." 566 | }, 567 | "71": { 568 | "nrc": 113, 569 | "name": "transferDataSuspended", 570 | "description": "indicates that a data transfer operation was halted due to some fault." 571 | }, 572 | "72": { 573 | "nrc": 114, 574 | "name": "generalProgrammingFailure", 575 | "description": "the server detected an error when erasing or programming a memory location in the permanent memory device." 576 | }, 577 | "73": { 578 | "nrc": 115, 579 | "name": "wrongBlockSequenceCounter", 580 | "description": "the server detected an error in the sequence of blockSequenceCounter values." 581 | }, 582 | "74": { 583 | "nrc": 116, 584 | "name": "ISOSAEReserved", 585 | "description": "reserved by this document for future definition." 586 | }, 587 | "75": { 588 | "nrc": 117, 589 | "name": "ISOSAEReserved", 590 | "description": "reserved by this document for future definition." 591 | }, 592 | "76": { 593 | "nrc": 118, 594 | "name": "ISOSAEReserved", 595 | "description": "reserved by this document for future definition." 596 | }, 597 | "77": { 598 | "nrc": 119, 599 | "name": "ISOSAEReserved", 600 | "description": "reserved by this document for future definition." 601 | }, 602 | "78": { 603 | "nrc": 120, 604 | "name": "requestCorrectlyReceived-ResponsePending", 605 | "description": "the request message was received correctly, and that all parameters in the request message were valid, but the action to be performed is not yet completed and the server is not yet ready to receive another request." 606 | }, 607 | "79": { 608 | "nrc": 121, 609 | "name": "ISOSAEReserved", 610 | "description": "reserved by this document for future definition." 611 | }, 612 | "7A": { 613 | "nrc": 122, 614 | "name": "ISOSAEReserved", 615 | "description": "reserved by this document for future definition." 616 | }, 617 | "7B": { 618 | "nrc": 123, 619 | "name": "ISOSAEReserved", 620 | "description": "reserved by this document for future definition." 621 | }, 622 | "7C": { 623 | "nrc": 124, 624 | "name": "ISOSAEReserved", 625 | "description": "reserved by this document for future definition." 626 | }, 627 | "7D": { 628 | "nrc": 125, 629 | "name": "ISOSAEReserved", 630 | "description": "reserved by this document for future definition." 631 | }, 632 | "7E": { 633 | "nrc": 126, 634 | "name": "sub-functionNotSupportedInActiveSession", 635 | "description": "the server does not support the requested sub-function in the session currently active." 636 | }, 637 | "7F": { 638 | "nrc": 127, 639 | "name": "serviceNotSupportedInActiveSession", 640 | "description": "the server does not support the requestd service in the session currently active." 641 | }, 642 | "80": { 643 | "nrc": 128, 644 | "name": "ISOSAEReserved", 645 | "description": "reserved by this document for future definition." 646 | }, 647 | "81": { 648 | "nrc": 129, 649 | "name": "rpmTooHigh", 650 | "description": "the server prerequisite condition for RPM is too high." 651 | }, 652 | "82": { 653 | "nrc": 130, 654 | "name": "rpmTooLow", 655 | "description": "the server prerequisite condition for RPM is too low." 656 | }, 657 | "83": { 658 | "nrc": 131, 659 | "name": "engineIsRunning", 660 | "description": "required for those actuator tests which cannot be actuated while the engine is running." 661 | }, 662 | "84": { 663 | "nrc": 132, 664 | "name": "engineIsNotRunning", 665 | "description": "required for those actuator tests which cannot be actuated unless the engine is running." 666 | }, 667 | "85": { 668 | "nrc": 133, 669 | "name": "engineRunTimeTooLow", 670 | "description": "the server prerequisite condition for engine run time is not met (too low)." 671 | }, 672 | "86": { 673 | "nrc": 134, 674 | "name": "temperatureTooHigh", 675 | "description": "the server prerequisite condition for temperature is not met (too high)." 676 | }, 677 | "87": { 678 | "nrc": 135, 679 | "name": "temperatureTooLow", 680 | "description": "the server prerequisite condition for temperature is not met (too low)." 681 | }, 682 | "88": { 683 | "nrc": 136, 684 | "name": "vehicleSpeedTooHigh", 685 | "description": "the server prerequisite condition for vehicle speed is not met (too high)." 686 | }, 687 | "89": { 688 | "nrc": 137, 689 | "name": "vehicleSpeedTooLow", 690 | "description": "the server prerequisite condition for vehicle speed is not met (too low)." 691 | }, 692 | "8A": { 693 | "nrc": 138, 694 | "name": "throttle/PedalTooHigh", 695 | "description": "the server prerequisite condition for thottle/pedal position is not met (too high)." 696 | }, 697 | "8B": { 698 | "nrc": 139, 699 | "name": "throttle/PedalTooLow", 700 | "description": "the server prerequisite condition for thottle/pedal position is not met (too low)." 701 | }, 702 | "8C": { 703 | "nrc": 140, 704 | "name": "transmissionRangeNotInNeutral", 705 | "description": "the server prerequisite condition for being in neutral is not met." 706 | }, 707 | "8D": { 708 | "nrc": 141, 709 | "name": "transmissionRangeNotInGear", 710 | "description": "the server prerequisite condition for being in gear is not met." 711 | }, 712 | "8E": { 713 | "nrc": 142, 714 | "name": "ISOSAEReserved", 715 | "description": "reserved by this document for future definition." 716 | }, 717 | "8F": { 718 | "nrc": 143, 719 | "name": "brakeSwitch(es)NotClosed", 720 | "description": "for safety reasons, the brake pedal must not be pressed for certain tests before it begins." 721 | }, 722 | "90": { 723 | "nrc": 144, 724 | "name": "shifterLeverNotInPark", 725 | "description": "for safety reasons, shifter must be in park for certains tests before it begins." 726 | }, 727 | "91": { 728 | "nrc": 145, 729 | "name": "torqueConverterClutchLocked", 730 | "description": "the server prerequisite condition for torque converter clutch is not met." 731 | }, 732 | "92": { 733 | "nrc": 146, 734 | "name": "voltageTooHigh", 735 | "description": "the server prerequisite condition for voltage at the primary pin of the server is not met (too high)." 736 | }, 737 | "93": { 738 | "nrc": 147, 739 | "name": "voltageTooLow", 740 | "description": "the server prerequisite condition for voltage at the primary pin of the server is not met (too high)." 741 | }, 742 | "94": { 743 | "nrc": 148, 744 | "name": "reservedForSpecificConditionsNotCorrect", 745 | "description": "reserved by the document for future definition." 746 | }, 747 | "95": { 748 | "nrc": 149, 749 | "name": "reservedForSpecificConditionsNotCorrect", 750 | "description": "reserved by the document for future definition." 751 | }, 752 | "96": { 753 | "nrc": 150, 754 | "name": "reservedForSpecificConditionsNotCorrect", 755 | "description": "reserved by the document for future definition." 756 | }, 757 | "97": { 758 | "nrc": 151, 759 | "name": "reservedForSpecificConditionsNotCorrect", 760 | "description": "reserved by the document for future definition." 761 | }, 762 | "98": { 763 | "nrc": 152, 764 | "name": "reservedForSpecificConditionsNotCorrect", 765 | "description": "reserved by the document for future definition." 766 | }, 767 | "99": { 768 | "nrc": 153, 769 | "name": "reservedForSpecificConditionsNotCorrect", 770 | "description": "reserved by the document for future definition." 771 | }, 772 | "9A": { 773 | "nrc": 154, 774 | "name": "reservedForSpecificConditionsNotCorrect", 775 | "description": "reserved by the document for future definition." 776 | }, 777 | "9B": { 778 | "nrc": 155, 779 | "name": "reservedForSpecificConditionsNotCorrect", 780 | "description": "reserved by the document for future definition." 781 | }, 782 | "9C": { 783 | "nrc": 156, 784 | "name": "reservedForSpecificConditionsNotCorrect", 785 | "description": "reserved by the document for future definition." 786 | }, 787 | "9D": { 788 | "nrc": 157, 789 | "name": "reservedForSpecificConditionsNotCorrect", 790 | "description": "reserved by the document for future definition." 791 | }, 792 | "9E": { 793 | "nrc": 158, 794 | "name": "reservedForSpecificConditionsNotCorrect", 795 | "description": "reserved by the document for future definition." 796 | }, 797 | "9F": { 798 | "nrc": 159, 799 | "name": "reservedForSpecificConditionsNotCorrect", 800 | "description": "reserved by the document for future definition." 801 | }, 802 | "A0": { 803 | "nrc": 160, 804 | "name": "reservedForSpecificConditionsNotCorrect", 805 | "description": "reserved by the document for future definition." 806 | }, 807 | "A1": { 808 | "nrc": 161, 809 | "name": "reservedForSpecificConditionsNotCorrect", 810 | "description": "reserved by the document for future definition." 811 | }, 812 | "A2": { 813 | "nrc": 162, 814 | "name": "reservedForSpecificConditionsNotCorrect", 815 | "description": "reserved by the document for future definition." 816 | }, 817 | "A3": { 818 | "nrc": 163, 819 | "name": "reservedForSpecificConditionsNotCorrect", 820 | "description": "reserved by the document for future definition." 821 | }, 822 | "A4": { 823 | "nrc": 164, 824 | "name": "reservedForSpecificConditionsNotCorrect", 825 | "description": "reserved by the document for future definition." 826 | }, 827 | "A5": { 828 | "nrc": 165, 829 | "name": "reservedForSpecificConditionsNotCorrect", 830 | "description": "reserved by the document for future definition." 831 | }, 832 | "A6": { 833 | "nrc": 166, 834 | "name": "reservedForSpecificConditionsNotCorrect", 835 | "description": "reserved by the document for future definition." 836 | }, 837 | "A7": { 838 | "nrc": 167, 839 | "name": "reservedForSpecificConditionsNotCorrect", 840 | "description": "reserved by the document for future definition." 841 | }, 842 | "A8": { 843 | "nrc": 168, 844 | "name": "reservedForSpecificConditionsNotCorrect", 845 | "description": "reserved by the document for future definition." 846 | }, 847 | "A9": { 848 | "nrc": 169, 849 | "name": "reservedForSpecificConditionsNotCorrect", 850 | "description": "reserved by the document for future definition." 851 | }, 852 | "AA": { 853 | "nrc": 170, 854 | "name": "reservedForSpecificConditionsNotCorrect", 855 | "description": "reserved by the document for future definition." 856 | }, 857 | "AB": { 858 | "nrc": 171, 859 | "name": "reservedForSpecificConditionsNotCorrect", 860 | "description": "reserved by the document for future definition." 861 | }, 862 | "AC": { 863 | "nrc": 172, 864 | "name": "reservedForSpecificConditionsNotCorrect", 865 | "description": "reserved by the document for future definition." 866 | }, 867 | "AD": { 868 | "nrc": 173, 869 | "name": "reservedForSpecificConditionsNotCorrect", 870 | "description": "reserved by the document for future definition." 871 | }, 872 | "AE": { 873 | "nrc": 174, 874 | "name": "reservedForSpecificConditionsNotCorrect", 875 | "description": "reserved by the document for future definition." 876 | }, 877 | "AF": { 878 | "nrc": 175, 879 | "name": "reservedForSpecificConditionsNotCorrect", 880 | "description": "reserved by the document for future definition." 881 | }, 882 | "B0": { 883 | "nrc": 176, 884 | "name": "reservedForSpecificConditionsNotCorrect", 885 | "description": "reserved by the document for future definition." 886 | }, 887 | "B1": { 888 | "nrc": 177, 889 | "name": "reservedForSpecificConditionsNotCorrect", 890 | "description": "reserved by the document for future definition." 891 | }, 892 | "B2": { 893 | "nrc": 178, 894 | "name": "reservedForSpecificConditionsNotCorrect", 895 | "description": "reserved by the document for future definition." 896 | }, 897 | "B3": { 898 | "nrc": 179, 899 | "name": "reservedForSpecificConditionsNotCorrect", 900 | "description": "reserved by the document for future definition." 901 | }, 902 | "B4": { 903 | "nrc": 180, 904 | "name": "reservedForSpecificConditionsNotCorrect", 905 | "description": "reserved by the document for future definition." 906 | }, 907 | "B5": { 908 | "nrc": 181, 909 | "name": "reservedForSpecificConditionsNotCorrect", 910 | "description": "reserved by the document for future definition." 911 | }, 912 | "B6": { 913 | "nrc": 182, 914 | "name": "reservedForSpecificConditionsNotCorrect", 915 | "description": "reserved by the document for future definition." 916 | }, 917 | "B7": { 918 | "nrc": 183, 919 | "name": "reservedForSpecificConditionsNotCorrect", 920 | "description": "reserved by the document for future definition." 921 | }, 922 | "B8": { 923 | "nrc": 184, 924 | "name": "reservedForSpecificConditionsNotCorrect", 925 | "description": "reserved by the document for future definition." 926 | }, 927 | "B9": { 928 | "nrc": 185, 929 | "name": "reservedForSpecificConditionsNotCorrect", 930 | "description": "reserved by the document for future definition." 931 | }, 932 | "BA": { 933 | "nrc": 186, 934 | "name": "reservedForSpecificConditionsNotCorrect", 935 | "description": "reserved by the document for future definition." 936 | }, 937 | "BB": { 938 | "nrc": 187, 939 | "name": "reservedForSpecificConditionsNotCorrect", 940 | "description": "reserved by the document for future definition." 941 | }, 942 | "BC": { 943 | "nrc": 188, 944 | "name": "reservedForSpecificConditionsNotCorrect", 945 | "description": "reserved by the document for future definition." 946 | }, 947 | "BD": { 948 | "nrc": 189, 949 | "name": "reservedForSpecificConditionsNotCorrect", 950 | "description": "reserved by the document for future definition." 951 | }, 952 | "BE": { 953 | "nrc": 190, 954 | "name": "reservedForSpecificConditionsNotCorrect", 955 | "description": "reserved by the document for future definition." 956 | }, 957 | "BF": { 958 | "nrc": 191, 959 | "name": "reservedForSpecificConditionsNotCorrect", 960 | "description": "reserved by the document for future definition." 961 | }, 962 | "C0": { 963 | "nrc": 192, 964 | "name": "reservedForSpecificConditionsNotCorrect", 965 | "description": "reserved by the document for future definition." 966 | }, 967 | "C1": { 968 | "nrc": 193, 969 | "name": "reservedForSpecificConditionsNotCorrect", 970 | "description": "reserved by the document for future definition." 971 | }, 972 | "C2": { 973 | "nrc": 194, 974 | "name": "reservedForSpecificConditionsNotCorrect", 975 | "description": "reserved by the document for future definition." 976 | }, 977 | "C3": { 978 | "nrc": 195, 979 | "name": "reservedForSpecificConditionsNotCorrect", 980 | "description": "reserved by the document for future definition." 981 | }, 982 | "C4": { 983 | "nrc": 196, 984 | "name": "reservedForSpecificConditionsNotCorrect", 985 | "description": "reserved by the document for future definition." 986 | }, 987 | "C5": { 988 | "nrc": 197, 989 | "name": "reservedForSpecificConditionsNotCorrect", 990 | "description": "reserved by the document for future definition." 991 | }, 992 | "C6": { 993 | "nrc": 198, 994 | "name": "reservedForSpecificConditionsNotCorrect", 995 | "description": "reserved by the document for future definition." 996 | }, 997 | "C7": { 998 | "nrc": 199, 999 | "name": "reservedForSpecificConditionsNotCorrect", 1000 | "description": "reserved by the document for future definition." 1001 | }, 1002 | "C8": { 1003 | "nrc": 200, 1004 | "name": "reservedForSpecificConditionsNotCorrect", 1005 | "description": "reserved by the document for future definition." 1006 | }, 1007 | "C9": { 1008 | "nrc": 201, 1009 | "name": "reservedForSpecificConditionsNotCorrect", 1010 | "description": "reserved by the document for future definition." 1011 | }, 1012 | "CA": { 1013 | "nrc": 202, 1014 | "name": "reservedForSpecificConditionsNotCorrect", 1015 | "description": "reserved by the document for future definition." 1016 | }, 1017 | "CB": { 1018 | "nrc": 203, 1019 | "name": "reservedForSpecificConditionsNotCorrect", 1020 | "description": "reserved by the document for future definition." 1021 | }, 1022 | "CC": { 1023 | "nrc": 204, 1024 | "name": "reservedForSpecificConditionsNotCorrect", 1025 | "description": "reserved by the document for future definition." 1026 | }, 1027 | "CD": { 1028 | "nrc": 205, 1029 | "name": "reservedForSpecificConditionsNotCorrect", 1030 | "description": "reserved by the document for future definition." 1031 | }, 1032 | "CE": { 1033 | "nrc": 206, 1034 | "name": "reservedForSpecificConditionsNotCorrect", 1035 | "description": "reserved by the document for future definition." 1036 | }, 1037 | "CF": { 1038 | "nrc": 207, 1039 | "name": "reservedForSpecificConditionsNotCorrect", 1040 | "description": "reserved by the document for future definition." 1041 | }, 1042 | "D0": { 1043 | "nrc": 208, 1044 | "name": "reservedForSpecificConditionsNotCorrect", 1045 | "description": "reserved by the document for future definition." 1046 | }, 1047 | "D1": { 1048 | "nrc": 209, 1049 | "name": "reservedForSpecificConditionsNotCorrect", 1050 | "description": "reserved by the document for future definition." 1051 | }, 1052 | "D2": { 1053 | "nrc": 210, 1054 | "name": "reservedForSpecificConditionsNotCorrect", 1055 | "description": "reserved by the document for future definition." 1056 | }, 1057 | "D3": { 1058 | "nrc": 211, 1059 | "name": "reservedForSpecificConditionsNotCorrect", 1060 | "description": "reserved by the document for future definition." 1061 | }, 1062 | "D4": { 1063 | "nrc": 212, 1064 | "name": "reservedForSpecificConditionsNotCorrect", 1065 | "description": "reserved by the document for future definition." 1066 | }, 1067 | "D5": { 1068 | "nrc": 213, 1069 | "name": "reservedForSpecificConditionsNotCorrect", 1070 | "description": "reserved by the document for future definition." 1071 | }, 1072 | "D6": { 1073 | "nrc": 214, 1074 | "name": "reservedForSpecificConditionsNotCorrect", 1075 | "description": "reserved by the document for future definition." 1076 | }, 1077 | "D7": { 1078 | "nrc": 215, 1079 | "name": "reservedForSpecificConditionsNotCorrect", 1080 | "description": "reserved by the document for future definition." 1081 | }, 1082 | "D8": { 1083 | "nrc": 216, 1084 | "name": "reservedForSpecificConditionsNotCorrect", 1085 | "description": "reserved by the document for future definition." 1086 | }, 1087 | "D9": { 1088 | "nrc": 217, 1089 | "name": "reservedForSpecificConditionsNotCorrect", 1090 | "description": "reserved by the document for future definition." 1091 | }, 1092 | "DA": { 1093 | "nrc": 218, 1094 | "name": "reservedForSpecificConditionsNotCorrect", 1095 | "description": "reserved by the document for future definition." 1096 | }, 1097 | "DB": { 1098 | "nrc": 219, 1099 | "name": "reservedForSpecificConditionsNotCorrect", 1100 | "description": "reserved by the document for future definition." 1101 | }, 1102 | "DC": { 1103 | "nrc": 220, 1104 | "name": "reservedForSpecificConditionsNotCorrect", 1105 | "description": "reserved by the document for future definition." 1106 | }, 1107 | "DD": { 1108 | "nrc": 221, 1109 | "name": "reservedForSpecificConditionsNotCorrect", 1110 | "description": "reserved by the document for future definition." 1111 | }, 1112 | "DE": { 1113 | "nrc": 222, 1114 | "name": "reservedForSpecificConditionsNotCorrect", 1115 | "description": "reserved by the document for future definition." 1116 | }, 1117 | "DF": { 1118 | "nrc": 223, 1119 | "name": "reservedForSpecificConditionsNotCorrect", 1120 | "description": "reserved by the document for future definition." 1121 | }, 1122 | "E0": { 1123 | "nrc": 224, 1124 | "name": "reservedForSpecificConditionsNotCorrect", 1125 | "description": "reserved by the document for future definition." 1126 | }, 1127 | "E1": { 1128 | "nrc": 225, 1129 | "name": "reservedForSpecificConditionsNotCorrect", 1130 | "description": "reserved by the document for future definition." 1131 | }, 1132 | "E2": { 1133 | "nrc": 226, 1134 | "name": "reservedForSpecificConditionsNotCorrect", 1135 | "description": "reserved by the document for future definition." 1136 | }, 1137 | "E3": { 1138 | "nrc": 227, 1139 | "name": "reservedForSpecificConditionsNotCorrect", 1140 | "description": "reserved by the document for future definition." 1141 | }, 1142 | "E4": { 1143 | "nrc": 228, 1144 | "name": "reservedForSpecificConditionsNotCorrect", 1145 | "description": "reserved by the document for future definition." 1146 | }, 1147 | "E5": { 1148 | "nrc": 229, 1149 | "name": "reservedForSpecificConditionsNotCorrect", 1150 | "description": "reserved by the document for future definition." 1151 | }, 1152 | "E6": { 1153 | "nrc": 230, 1154 | "name": "reservedForSpecificConditionsNotCorrect", 1155 | "description": "reserved by the document for future definition." 1156 | }, 1157 | "E7": { 1158 | "nrc": 231, 1159 | "name": "reservedForSpecificConditionsNotCorrect", 1160 | "description": "reserved by the document for future definition." 1161 | }, 1162 | "E8": { 1163 | "nrc": 232, 1164 | "name": "reservedForSpecificConditionsNotCorrect", 1165 | "description": "reserved by the document for future definition." 1166 | }, 1167 | "E9": { 1168 | "nrc": 233, 1169 | "name": "reservedForSpecificConditionsNotCorrect", 1170 | "description": "reserved by the document for future definition." 1171 | }, 1172 | "EA": { 1173 | "nrc": 234, 1174 | "name": "reservedForSpecificConditionsNotCorrect", 1175 | "description": "reserved by the document for future definition." 1176 | }, 1177 | "EB": { 1178 | "nrc": 235, 1179 | "name": "reservedForSpecificConditionsNotCorrect", 1180 | "description": "reserved by the document for future definition." 1181 | }, 1182 | "EC": { 1183 | "nrc": 236, 1184 | "name": "reservedForSpecificConditionsNotCorrect", 1185 | "description": "reserved by the document for future definition." 1186 | }, 1187 | "ED": { 1188 | "nrc": 237, 1189 | "name": "reservedForSpecificConditionsNotCorrect", 1190 | "description": "reserved by the document for future definition." 1191 | }, 1192 | "EE": { 1193 | "nrc": 238, 1194 | "name": "reservedForSpecificConditionsNotCorrect", 1195 | "description": "reserved by the document for future definition." 1196 | }, 1197 | "EF": { 1198 | "nrc": 239, 1199 | "name": "reservedForSpecificConditionsNotCorrect", 1200 | "description": "reserved by the document for future definition." 1201 | }, 1202 | "F0": { 1203 | "nrc": 240, 1204 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1205 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1206 | }, 1207 | "F1": { 1208 | "nrc": 241, 1209 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1210 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1211 | }, 1212 | "F2": { 1213 | "nrc": 242, 1214 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1215 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1216 | }, 1217 | "F3": { 1218 | "nrc": 243, 1219 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1220 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1221 | }, 1222 | "F4": { 1223 | "nrc": 244, 1224 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1225 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1226 | }, 1227 | "F5": { 1228 | "nrc": 245, 1229 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1230 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1231 | }, 1232 | "F6": { 1233 | "nrc": 246, 1234 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1235 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1236 | }, 1237 | "F7": { 1238 | "nrc": 247, 1239 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1240 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1241 | }, 1242 | "F8": { 1243 | "nrc": 248, 1244 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1245 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1246 | }, 1247 | "F9": { 1248 | "nrc": 249, 1249 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1250 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1251 | }, 1252 | "FA": { 1253 | "nrc": 250, 1254 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1255 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1256 | }, 1257 | "FB": { 1258 | "nrc": 251, 1259 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1260 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1261 | }, 1262 | "FC": { 1263 | "nrc": 252, 1264 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1265 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1266 | }, 1267 | "FD": { 1268 | "nrc": 253, 1269 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1270 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1271 | }, 1272 | "FE": { 1273 | "nrc": 254, 1274 | "name": "vehicleManufacturerSpecificConditionsNotCorrect", 1275 | "description": "reserved for vehicle manufacturer specific condition not correct scenarios." 1276 | }, 1277 | "FF": { 1278 | "nrc": 255, 1279 | "name": "ISOSAEReserved", 1280 | "description": "reserved by this document for future definition." 1281 | } 1282 | } -------------------------------------------------------------------------------- /truckdevil/modules/j1939_fuzzer.py: -------------------------------------------------------------------------------- 1 | import time 2 | import random 3 | import threading 4 | import copy 5 | import sys 6 | import dill 7 | 8 | from j1939.j1939 import J1939Message, J1939Interface, j1939_fields_to_can_id 9 | from libs.command import Command 10 | from libs.settings import SettingsManager, Setting 11 | 12 | 13 | class J1939Fuzzer: 14 | class Target: 15 | def __init__(self, address, reboot_pgn=None, reboot_data_snip=None): 16 | 17 | self.__addr = 0 18 | self.__reboot_pgn = None 19 | self.__reboot_data_snip = None 20 | 21 | self.address = address 22 | if reboot_pgn is not None: 23 | self.reboot_pgn = reboot_pgn 24 | if reboot_data_snip is not None: 25 | self.reboot_data_snip = reboot_data_snip 26 | 27 | @property 28 | def address(self): 29 | return self.__addr 30 | 31 | @address.setter 32 | def address(self, value): 33 | if isinstance(value, str): 34 | if value.startswith("0x"): 35 | value = int(value, 16) 36 | else: 37 | value = int(value) 38 | 39 | if 0 <= value <= 255: 40 | self.__addr = value 41 | else: 42 | raise ValueError("addresses must be between 0 and 255") 43 | return 44 | 45 | @property 46 | def reboot_pgn(self): 47 | return self.__reboot_pgn 48 | 49 | @reboot_pgn.setter 50 | def reboot_pgn(self, value): 51 | if isinstance(value, str): 52 | if value.startswith("0x"): 53 | value = int(value, 16) 54 | else: 55 | value = int(value) 56 | if 0 <= value <= 65535: 57 | self.__reboot_pgn = value 58 | else: 59 | raise ValueError("Valid reboot_pgn values are between 0 and 65535") 60 | 61 | def has_user_set_reboot_pgn(self): 62 | if self.__reboot_pgn is None: 63 | return False 64 | return True 65 | 66 | @property 67 | def reboot_data_snip(self): 68 | return self.__reboot_data_snip 69 | 70 | @reboot_data_snip.setter 71 | def reboot_data_snip(self, value): 72 | if value.startswith("0x"): 73 | value = value[2:] 74 | if len(value) % 2 != 0 or len(value) > 3570: 75 | raise ValueError('Length of data must be an even number and shorter than 1785 bytes') 76 | int(value, 16) # should raise ValueError if not hexadecimal string 77 | self.__reboot_data_snip = value 78 | 79 | def has_user_set_reboot_data_snip(self): 80 | if self.__reboot_data_snip is None: 81 | return False 82 | return True 83 | 84 | def __str__(self): 85 | pgn = "not set" 86 | data_snip = "not set" 87 | if self.has_user_set_reboot_pgn(): 88 | pgn = self.reboot_pgn 89 | if self.has_user_set_reboot_data_snip(): 90 | data_snip = self.reboot_data_snip 91 | return "address: {:<3} reboot_pgn: {:<5} reboot_data_snip: {}".format(self.address, pgn, data_snip) 92 | 93 | def __init__(self, device): 94 | self._targets = [] # Each target should have an optional field to specify what message is sent from the ECU 95 | 96 | self.baseline = [] 97 | self.baseline_messages = [] 98 | self.test_cases = [] 99 | 100 | self.devil = J1939Interface(device) 101 | self.done_fuzzing = False 102 | self.pause_fuzzing = False 103 | self.fuzzed_messages = [] 104 | self.lock_fuzzed_messages = threading.RLock() 105 | 106 | self.sm = SettingsManager() 107 | sl = [ 108 | Setting("baseline_time", 60).add_constraint("minimum", lambda x: 10 <= x) 109 | .add_description("The amount of time to record the baseline for, in seconds."), 110 | 111 | Setting("num_messages", 5000).add_constraint("minimum", lambda x: 1 <= x) 112 | .add_description("Number of test cases to generate"), 113 | 114 | Setting("mode", 0).add_constraint("allowed_states", lambda x: 0 <= x <= 2) 115 | .add_description("There are 3 modes to create test cases: 0 - mutational, 1 - generational" 116 | "2 - mutational/generational. "), 117 | 118 | Setting("generate_data_option", 0).add_constraint("allowed_states", lambda x: 0 <= x <= 2) 119 | .add_description("When performing generational fuzzing, there are 3 options: 0 - Generate test case " 120 | "data based on J1939 standard, 1 - Generate test case data randomly with standard " 121 | "length, 2 - Generate test case data randomly with random length"), 122 | 123 | Setting("check_frequency", 20).add_constraint("minimum", lambda x: 1 <= x) 124 | .add_description("how long to wait between analysing for anomalies, in seconds."), 125 | 126 | Setting("message_frequency", 0.5).add_constraint("minimum", lambda x: 0.0 <= x) 127 | .add_description("the amount of time to wait between sending each fuzzed message, in seconds."), 128 | 129 | Setting("diff_tolerance", 5).add_constraint("minimum", lambda x: 0 <= x) 130 | .add_description( 131 | "the acceptable difference in the volume of messages between the " 132 | "baseline and the current interval to determine if a crash has occurred. " 133 | "A percentage value is expected."), 134 | 135 | Setting("test_case_can_id", 0).add_constraint("range", lambda x: 0 <= x <= 0x1FFFFFFF) 136 | .add_description("CAN ID set for each test case."), 137 | 138 | Setting("test_case_priority", 0).add_constraint("range", lambda x: 0 <= x <= 7) 139 | .add_description("Priority set for each test case."), 140 | 141 | Setting("test_case_reserved_bit", 0).add_constraint("range", lambda x: 0 <= x <= 1) 142 | .add_description("Reserved bit of CAN ID for each test case."), 143 | 144 | Setting("test_case_data_page_bit", 0).add_constraint("range", lambda x: 0 <= x <= 1) 145 | .add_description("Data page bit of CAN ID for each test case."), 146 | 147 | Setting("test_case_pdu_format", 0).add_constraint("range", lambda x: 0 <= x <= 255) 148 | .add_description("PDU Format byte for each test case. 0-239 for destination specific, 240+ " 149 | "for broadcast."), 150 | 151 | Setting("test_case_pdu_specific", 0).add_constraint("range", lambda x: 0 <= x <= 255) 152 | .add_description("PDU Specific byte for each test case. If PDU Format is 0-239, this is the destination" 153 | " address. If PDU Format is 240+, this is extension."), 154 | 155 | Setting("test_case_src_address", 0).add_constraint("range", lambda x: 0 <= x <= 255) 156 | .add_description("Source address to set for each test case"), 157 | 158 | Setting("test_case_data", "") 159 | .add_constraint("max_length", lambda x: len(x) <= (2 * 1785)) 160 | .add_constraint("even_bytes", lambda x: len(x) % 2 == 0) 161 | .add_description("Data to be set for the test case"), 162 | 163 | Setting("mutate_priority", False).add_constraint("boolean", lambda x: type(x) is bool) 164 | .add_description("Should the generator mutate the test case priority field?"), 165 | 166 | Setting("mutate_reserved_bit", False).add_constraint("boolean", lambda x: type(x) is bool) 167 | .add_description("Should the generator mutate the test case reserved bit field?"), 168 | 169 | Setting("mutate_data_page_bit", False).add_constraint("boolean", lambda x: type(x) is bool) 170 | .add_description("Should the generator mutate the test case data page bit field?"), 171 | 172 | Setting("mutate_pdu_format", False).add_constraint("boolean", lambda x: type(x) is bool) 173 | .add_description("Should the generator mutate the test case PDU Format field?"), 174 | 175 | Setting("mutate_pdu_specific", False).add_constraint("boolean", lambda x: type(x) is bool) 176 | .add_description("Should the generator mutate the test case PDU Specific field?"), 177 | 178 | Setting("mutate_src_address", False).add_constraint("boolean", lambda x: type(x) is bool) 179 | .add_description("Should the generator mutate the source address?"), 180 | 181 | Setting("mutate_data", False).add_constraint("boolean", lambda x: type(x) is bool) 182 | .add_description("Should the generator mutate the data field?"), 183 | 184 | Setting("mutate_data_length", False).add_constraint("boolean", lambda x: type(x) is bool) 185 | .add_description("Should the generator mutate the length of the data field?"), 186 | 187 | Setting("carry_on", False).add_constraint("boolean", lambda x: type(x) is bool) 188 | .add_description("Should the fuzzer skip waiting for you to reset the ECU and just carry on fuzzing?"), 189 | ] 190 | 191 | for setting in sl: 192 | self.sm.add_setting(setting) 193 | 194 | 195 | 196 | @property 197 | def targets(self): 198 | """ 199 | Get the list of targets 200 | 201 | :return: the targets list 202 | """ 203 | return self._targets 204 | 205 | @targets.setter 206 | def targets(self, val: []): 207 | """ 208 | Set the list of targets 209 | """ 210 | self._targets = val 211 | 212 | def add_target(self, tgt): 213 | """ 214 | Add a target object to the targets list, if it doesn't exist 215 | 216 | :param tgt: target object to add to list 217 | """ 218 | if tgt.address not in [t.address for t in self.targets]: 219 | self._targets.append(tgt) 220 | return 221 | raise ValueError("Target with this address already exists") 222 | 223 | def remove_target(self, address): 224 | """ 225 | Remove a target object from the targets list 226 | 227 | :param address: Address of target object to remove from list 228 | """ 229 | if isinstance(address, str): 230 | if address.startswith("0x"): 231 | address = int(address, 16) 232 | else: 233 | address = int(address) 234 | 235 | for idx, t in enumerate(self._targets): 236 | if t.address == address: 237 | tmp = self._targets[:idx] 238 | tmp.extend(self._targets[idx + 1:]) 239 | self._targets = tmp 240 | 241 | def modify_target(self, address, pgn, data): 242 | """ 243 | Modify the reboot PGN and data snippet of a target 244 | 245 | :param address: Address of target 246 | :param pgn: new reboot PGN 247 | :param data: new reboot data snippet 248 | """ 249 | if isinstance(address, str): 250 | if address.startswith("0x"): 251 | address = int(address, 16) 252 | else: 253 | address = int(address) 254 | 255 | for idx, t in enumerate(self._targets): 256 | if t.address == address: 257 | self._targets[idx] = self.Target(address, pgn, data) 258 | 259 | def mutate(self, message: J1939Message, mutate_priority=False, mutate_reserved_bit=False, 260 | mutate_data_page_bit=False, mutate_pdu_format=False, mutate_pdu_specific=False, mutate_src_addr=False, 261 | mutate_data=False, mutate_data_length=False) -> J1939Message: 262 | """ 263 | Given a J1939_Message, mutate different parts of it randomly depending on the arguments 264 | 265 | :param message: required, this is the starting message that will be mutated 266 | :param mutate_priority: if true, modify priority to a random value between 0-7 267 | :param mutate_reserved_bit: if true, modify reserved bit to either 0 or 1 268 | :param mutate_data_page_bit: if true, modify data page bit to either 0 or 1 269 | :param mutate_pdu_format: if true, modify pdu format 50% chance of being 0-239, 50% chance of being 240-255 270 | :param mutate_pdu_specific: if true, modify pdu specific to random value between 0-255 271 | :param mutate_src_addr: if true, modify source address to a random value between 0-255 272 | :param mutate_data: if true, mutates a random number of bytes to random values between 0-255. 273 | :param mutate_data_length: if true, makes the data either shorter or longer 274 | :return: the mutated message 275 | """ 276 | if mutate_priority: 277 | message.priority = random.randint(0, 7) 278 | if mutate_reserved_bit: 279 | message.reserved_bit = random.randint(0, 1) 280 | if mutate_data_page_bit: 281 | message.data_page_bit = random.randint(0, 1) 282 | if mutate_pdu_format: 283 | destination_specific = random.randint(0, 1) 284 | if destination_specific: 285 | message.pdu_format = random.randint(0, 239) 286 | else: 287 | message.pdu_format = random.randint(240, 255) 288 | if mutate_pdu_specific: 289 | message.pdu_specific = random.randint(0, 255) 290 | if mutate_src_addr: 291 | message.src_addr = random.randint(0, 255) 292 | message_data_bytes = int(len(message.data) / 2) 293 | if mutate_data and message_data_bytes > 0: 294 | num_bytes_to_mutate = random.randint(1, message_data_bytes) 295 | for i in range(0, num_bytes_to_mutate): 296 | byte_to_mutate = random.randint(0, message_data_bytes - 1) 297 | data_byte = hex(random.randint(0, 255))[2:].zfill(2) 298 | message.data = message.data[0:byte_to_mutate * 2] + data_byte + message.data[byte_to_mutate * 2 + 2:] 299 | if mutate_data_length: 300 | shorter = random.randint(0, 1) 301 | if shorter: 302 | num_bytes = random.randint(0, message_data_bytes - 1) 303 | message.data = message.data[0:num_bytes * 2] 304 | else: 305 | num_bytes_added = random.randint(1, 1785 - message_data_bytes) 306 | for i in range(0, num_bytes_added + 1): 307 | data_byte = hex(random.randint(0, 255))[2:].zfill(2) 308 | message.data += data_byte 309 | return message 310 | 311 | def generate(self, option=0, **test_case_values): 312 | """ 313 | Generate and return a J1939_Message based on optional parameters. 314 | 315 | :param option: optional int (0-2), if not given then generate a random option between 0-2 316 | 0) generate data based on the pgn, data length and format matching the specified pgn 317 | in this case, all of the data within will be generated based on acceptable ranges 318 | for example, if field is 1 byte long, it will be between 0-255 (even if operationally it only allows 0-200) 319 | 1) generate data randomly based on data length of specified pgn 320 | 2) generate random data length and random data 321 | :param test_case_values: 322 | See below 323 | :Keyword Arguments: 324 | can_id: optional int, if not given then generate the other fields to create the can_id 325 | priority: optional int, if not given then generate a random one between 0-7 326 | reserved_bit: optional int, if not given then generate a random one between 0-1 327 | data_page_bit: optional int, if not given then generate a random one between 0-1 328 | pdu_format: optional int, if not given then generate a random one between 0-255 329 | pdu_specific: optional int, if not given then generate a random one between 0-255 330 | src_addr: optional int, if not given then generate a random one between 0-255 331 | data: optional hex string, if not given then generate a hex string based on one of three options 332 | :return: J1939_Message object containing the generated message 333 | """ 334 | can_id = test_case_values.setdefault("can_id", None) 335 | if can_id is None: 336 | priority = test_case_values.setdefault("priority", random.randint(0, 7)) 337 | reserved_bit = test_case_values.setdefault("reserved_bit", random.randint(0, 1)) 338 | data_page_bit = test_case_values.setdefault("data_page_bit", random.randint(0, 1)) 339 | src_addr = test_case_values.setdefault("src_addr", random.randint(0, 255)) 340 | pdu_format = test_case_values.setdefault("pdu_format", None) 341 | if pdu_format is None: 342 | destination_specific = random.randint(0, 1) 343 | if destination_specific: 344 | pdu_format = random.randint(0, 239) 345 | else: 346 | pdu_format = random.randint(240, 255) 347 | pdu_specific = test_case_values.setdefault("pdu_specific", random.randint(0, 255)) 348 | 349 | if pdu_format < 240: 350 | pgn = pdu_format << 8 351 | else: 352 | pgn = (pdu_format << 8) + pdu_specific 353 | 354 | can_id = j1939_fields_to_can_id(priority, reserved_bit, data_page_bit, pdu_format, pdu_specific, src_addr) 355 | else: 356 | pgn = can_id >> 8 & 0xFFFF 357 | if pgn < 0xF000: 358 | pgn = can_id >> 8 & 0xFF00 359 | if pgn == 60928 and option == 0: 360 | option = 1 361 | 362 | data = test_case_values.setdefault("data", None) 363 | if data is None: 364 | if 2 < option < 0: 365 | option = random.randint(0, 2) 366 | if option == 0: 367 | data = '' 368 | try: 369 | pgn_info = self.devil.pgn_list[str(pgn)] 370 | if isinstance(pgn_info['pgnDataLength'], int): 371 | data_len = pgn_info['pgnDataLength'] 372 | else: 373 | raise KeyError 374 | spn_list = pgn_info['spnList'] 375 | bin_data = '' 376 | used_bits = 0 377 | for spn in spn_list: 378 | spn_info = self.devil.spn_list[str(spn)] 379 | if isinstance(spn_info['spnLength'], int): 380 | spn_length = spn_info['spnLength'] # number of bits 381 | else: 382 | raise KeyError # length is variable 383 | max_val = (2 ** spn_length) - 1 # maximum int value for x number of bits (ex: 255 for 8 bits) 384 | 385 | val = random.randint(0, max_val) 386 | bin_val = bin(val)[2:].zfill(spn_length) 387 | bin_data = bin_data + bin_val 388 | used_bits += spn_length 389 | if spn_info['bitPositionStart'] > used_bits: 390 | filler = (spn_info['bitPositionStart'] - used_bits) * '1' 391 | bin_data = bin_data + filler 392 | used_bits += len(filler) 393 | bits_left = (data_len * 8 - used_bits) * '1' 394 | if len(bits_left) > 0: 395 | data = (hex(int(bin_data + bits_left, 2))[2:].zfill(data_len * 2)).upper() 396 | else: 397 | data = (hex(int(bin_data, 2))[2:].zfill(int(len(bin_data) / 4))).upper() 398 | except KeyError: 399 | option = 1 400 | if option == 1: 401 | try: 402 | pgn_info = self.devil.pgn_list[str(pgn)] 403 | if isinstance(pgn_info['pgnDataLength'], int): 404 | data_len = pgn_info['pgnDataLength'] # number of bytes to generate is based on data length 405 | # specified in pgn 406 | data = '' 407 | for i in range(0, data_len): 408 | data_byte = hex(random.randint(0, 255))[2:].zfill(2) 409 | data += data_byte 410 | else: 411 | raise KeyError 412 | except KeyError: 413 | option = 2 414 | if option == 2: 415 | long = random.randint(0, 9) 416 | if long == 9: 417 | data_len = random.randint(9, 1785) # number of bytes to generate 418 | else: 419 | data_len = random.randint(0, 8) # number of bytes to generate 420 | data = '' 421 | for i in range(0, data_len): 422 | data_byte = hex(random.randint(0, 255))[2:].zfill(2) 423 | data += data_byte 424 | message = J1939Message(can_id, data) 425 | return message 426 | 427 | def anomaly_check(self): 428 | """ 429 | Checks for anomalies/differences from the baseline every x seconds, based on check_frequency variable 430 | """ 431 | start_time = time.time() 432 | previous_interval_messages = [] 433 | num_crashes = 0 434 | while not self.done_fuzzing: 435 | if self.devil.device.m2_used: 436 | self.devil.device.flush_m2() 437 | self.devil.start_data_collection() 438 | time.sleep(self.sm.check_frequency) 439 | if self.done_fuzzing: 440 | break 441 | incoming_messages = self.devil.stop_data_collection() 442 | # crash analysis 443 | any_anomalies = False 444 | after_fuzz = [] 445 | for x in range(256): 446 | node = {'total_messages': 0, 'pgns': {}, 'boot_msg_found': False} 447 | after_fuzz.append(node) 448 | for m in incoming_messages: 449 | after_fuzz[m.src_addr]['total_messages'] += 1 450 | # TODO: maybe get rid of the collection pgns? 451 | if m.pgn not in after_fuzz[m.src_addr]['pgns']: 452 | after_fuzz[m.src_addr]['pgns'][m.pgn] = 1 453 | else: 454 | after_fuzz[m.src_addr]['pgns'][m.pgn] += 1 455 | if len(self.targets) > 0: 456 | for t in self.targets: 457 | if t.address == m.src_addr: 458 | if t.has_user_set_reboot_pgn() and t.has_user_set_reboot_data_snip(): 459 | if t.reboot_pgn == m.pgn and t.reboot_data_snip in m.data: 460 | after_fuzz[m.src_addr]['boot_msg_found'] = True 461 | elif t.has_user_set_reboot_pgn(): 462 | if t.reboot_pgn == m.pgn: 463 | after_fuzz[m.src_addr]['boot_msg_found'] = True 464 | elif t.has_user_set_reboot_data_snip(): 465 | if t.reboot_data_snip in m.data: 466 | after_fuzz[m.src_addr]['boot_msg_found'] = True 467 | addresses = [t.address for t in self.targets] if len(self.targets) != 0 else list(range(0, 256)) 468 | for src in addresses: 469 | anomaly = False 470 | message = "" 471 | base_per_sec = self.baseline[src]['total_messages'] / self.sm.baseline_time 472 | curr_per_sec = after_fuzz[src]['total_messages'] / self.sm.check_frequency 473 | if after_fuzz[src]['boot_msg_found']: 474 | anomaly = True 475 | any_anomalies = True 476 | message = "targets reboot message was detected." 477 | elif curr_per_sec == 0 and base_per_sec != 0: 478 | anomaly = True 479 | any_anomalies = True 480 | message = "The baseline had messages for this node, but this interval did not." 481 | elif curr_per_sec > 0: 482 | percent_diff = ((abs(base_per_sec - curr_per_sec)) / ((base_per_sec + curr_per_sec) / 2)) * 100 483 | if percent_diff > self.sm.diff_tolerance: 484 | anomaly = True 485 | any_anomalies = True 486 | message = "Number of messages changed by " + "{:.2f}".format(percent_diff) + "%" 487 | elif any([x not in self.baseline[src]['pgns'].keys() for x in after_fuzz[src]['pgns']]): 488 | anomaly = True 489 | any_anomalies = True 490 | message = "new PGNs detected from target: " + str( 491 | set(self.baseline[src]['pgns'].keys()) - set(after_fuzz[src]['pgns'])) 492 | if anomaly: 493 | print("\n source: " + str(src)) 494 | print(" interval messages/second: " + str(curr_per_sec)) 495 | print(" interval pgns sent to: " + str(after_fuzz[src]['pgns'])) 496 | print(" baseline messages/second: " + str(base_per_sec)) 497 | print(" baseline pgns sent to: " + str(self.baseline[src]['pgns'])) 498 | print(" Reason: " + message) 499 | 500 | if any_anomalies: 501 | self.pause_fuzzing = True 502 | num_crashes = num_crashes + 1 503 | filename_previous = "crashReport_" + str(int(start_time)) + "_previous_" + str(num_crashes) 504 | filename_current = "crashReport_" + str(int(start_time)) + "_current_" + str(num_crashes) 505 | if len(previous_interval_messages) > 0: 506 | print(" Stored previous interval fuzzed messages to: " + filename_previous) 507 | self.devil.save_data_collected(previous_interval_messages, filename_previous, False) 508 | print(" Stored current interval fuzzed messages to: " + filename_current) 509 | self.devil.save_data_collected(self.fuzzed_messages, filename_current, False) 510 | 511 | val = "yes" 512 | if not self.sm.carry_on: 513 | val = input("Please restart the ECU. Once complete, enter 'y' to continue / 'q' to quit fuzzing: ") 514 | else: 515 | time.sleep(1.) 516 | if val.lower() == "yes" or val.lower() == "y": 517 | self.pause_fuzzing = False 518 | elif val.lower() == "quit" or val.lower() == "q": 519 | self.done_fuzzing = True 520 | self.pause_fuzzing = False 521 | return 522 | else: 523 | with self.lock_fuzzed_messages: 524 | previous_interval_messages = copy.copy(self.fuzzed_messages) 525 | self.fuzzed_messages.clear() 526 | 527 | def create_fuzz_list(self): 528 | self.test_cases = [] 529 | for i in range(0, self.sm.num_messages): 530 | choice = self.sm.mode 531 | # either mutate or generate 532 | if choice == 2: 533 | choice = random.randint(0, 1) 534 | # mutate a message from the baseline 535 | if choice == 0: 536 | mutate_index = random.randint(0, len(self.baseline_messages) - 1) 537 | m = copy.copy(self.baseline_messages[mutate_index]) 538 | if self.sm["test_case_can_id"].updated: 539 | m.can_id = self.sm.test_case_can_id 540 | else: 541 | if self.sm["test_case_priority"].updated: 542 | m.priority = self.sm.test_case_priority 543 | if self.sm['test_case_reserved_bit'].updated: 544 | m.reserved_bit = self.sm.test_case_reserved_bit 545 | if self.sm['test_case_data_page_bit'].updated: 546 | m.data_page_bit = self.sm.test_case_data_page_bit 547 | if self.sm['test_case_pdu_format'].updated: 548 | m.pdu_format = self.sm.test_case_pdu_format 549 | if self.sm['test_case_pdu_specific'].updated: 550 | m.pdu_specific = self.sm.test_case_pdu_specific 551 | if self.sm["test_case_src_address"].updated: 552 | m.src_addr = self.sm.test_case_src_address 553 | if self.sm["test_case_data"].updated: 554 | m.data = self.sm.test_case_data 555 | # mutate_pdu_specific = True 556 | # if len(self.targets) > 0: 557 | # which = random.randint(0, len(self.targets) - 1) 558 | # target_addr = self.targets[which].address 559 | # m.dst_addr = target_addr 560 | # mutate_pdu_specific = False 561 | 562 | m = self.mutate(m, 563 | self.sm.mutate_priority, 564 | self.sm.mutate_reserved_bit, 565 | self.sm.mutate_data_page_bit, 566 | self.sm.mutate_pdu_format, 567 | self.sm.mutate_pdu_specific, 568 | self.sm.mutate_src_address, 569 | self.sm.mutate_data, 570 | self.sm.mutate_data_length) 571 | 572 | # generate a message 573 | elif choice == 1: 574 | test_case_values = {} 575 | if self.sm["test_case_can_id"].updated: 576 | test_case_values["can_id"] = self.sm.test_case_can_id 577 | else: 578 | if self.sm["test_case_priority"].updated: 579 | test_case_values["priority"] = self.sm.test_case_priority 580 | if self.sm["test_case_reserved_bit"].updated: 581 | test_case_values["reserved_bit"] = self.sm.test_case_reserved_bit 582 | if self.sm["test_case_data_page_bit"].updated: 583 | test_case_values["data_page_bit"] = self.sm.test_case_data_page_bit 584 | if self.sm["test_case_pdu_format"].updated: 585 | test_case_values["pdu_format"] = self.sm.test_case_pdu_format 586 | if self.sm["test_case_pdu_specific"].updated: 587 | test_case_values["pdu_specific"] = self.sm.test_case_pdu_specific 588 | if self.sm["test_case_src_address"].updated: 589 | test_case_values["src_addr"] = self.sm.test_case_src_address 590 | if self.sm["test_case_data"].updated: 591 | test_case_values["data"] = self.sm.test_case_data 592 | #if len(self.targets) > 0: 593 | # which = random.randint(0, len(self.targets) - 1) 594 | # test_case_values["dst_addr"] = self.targets[which].address 595 | m = self.generate(option=self.sm.generate_data_option, **test_case_values) 596 | self.test_cases.append(m) 597 | return 598 | 599 | def record_baseline(self): 600 | if self.devil.device.m2_used: 601 | self.devil.device.flush_m2() 602 | print("Baselining for " + str(self.sm.baseline_time) + " seconds...") 603 | self.devil.start_data_collection() 604 | time.sleep(self.sm.baseline_time) 605 | self.baseline_messages = self.devil.stop_data_collection() 606 | if len(self.baseline_messages) == 0: 607 | return [] 608 | 609 | self.baseline = [] 610 | for i in range(256): 611 | node = {'total_messages': 0, 'pgns': {}} 612 | self.baseline.append(node) 613 | for m in self.baseline_messages: 614 | self.baseline[m.src_addr]['total_messages'] += 1 615 | if m.pgn not in self.baseline[m.src_addr]['pgns']: 616 | self.baseline[m.src_addr]['pgns'][m.pgn] = 1 617 | else: 618 | self.baseline[m.src_addr]['pgns'][m.pgn] += 1 619 | print("Baselining complete.") 620 | 621 | 622 | # https://stackoverflow.com/questions/3160699/python-progress-bar/34482761#34482761 623 | def progressbar(it, prefix="", size=60, file=sys.stdout): 624 | count = len(it) 625 | 626 | def show(j): 627 | x = int(size * j / count) 628 | file.write("%s[%s%s] %i/%i\r" % (prefix, "#" * x, "." * (size - x), j, count)) 629 | file.flush() 630 | 631 | show(0) 632 | for i, item in enumerate(it): 633 | yield item 634 | show(i + 1) 635 | file.write("\n") 636 | file.flush() 637 | 638 | 639 | class FuzzerCommands(Command): 640 | intro = "Welcome to the truckdevil J1939 Fuzzer." 641 | prompt = "(truckdevil.j1939_fuzzer) " 642 | 643 | def __init__(self, device): 644 | super().__init__() 645 | self.fz = J1939Fuzzer(device) 646 | 647 | def do_settings(self, arg): 648 | """Show the settings and each setting value""" 649 | print(self.fz.sm) 650 | return 651 | 652 | def do_save(self, arg): 653 | """ 654 | Save settings, targets, generated test cases, baseline, or all information to a file. 655 | 656 | usage: save <(all, fuzz_settings, targets, test_cases, baseline)> 657 | 658 | Verbs: 659 | all Saves settings, targets, test_cases, and baseline info 660 | fuzz_settings Saves all current settings 661 | targets Saves list of targets 662 | test_cases Saves list of generated test cases 663 | baseline Saves the baseline information for all nodes 664 | """ 665 | argv = arg.split() 666 | if len(argv) < 2: 667 | print("expected selection and file name, see 'help save'") 668 | return 669 | selection = argv[0] 670 | file_name = argv[1] 671 | try: 672 | f = open(file_name, "xb") 673 | except FileExistsError: 674 | print("file already exists") 675 | return 676 | if selection == "all": 677 | fz = copy.copy(self.fz) 678 | fz.devil = None 679 | dill.dump(fz, f) 680 | print("everything saved to {}".format(file_name)) 681 | elif selection == "fuzz_settings": 682 | dill.dump(self.fz.sm, f) 683 | print("settings saved to {}".format(file_name)) 684 | elif selection == "targets": 685 | dill.dump(self.fz.targets, f) 686 | print("targets saved to {}".format(file_name)) 687 | elif selection == "test_cases": 688 | dill.dump(self.fz.test_cases, f) 689 | print("test cases saved to {}".format(file_name)) 690 | elif selection == "baseline": 691 | dill.dump([self.fz.sm.baseline_time, self.fz.baseline, self.fz.baseline_messages], f) 692 | print("baseline data saved to {}".format(file_name)) 693 | 694 | def do_load(self, arg): 695 | """ 696 | Load settings, targets, generated test cases, baseline, or all information from a file. 697 | 698 | usage: load <(all, fuzz_settings, targets, test_cases, baseline)> 699 | 700 | Verbs: 701 | all Loads settings, targets, test_cases, and baseline info 702 | fuzz_settings Loads all current settings 703 | targets Loads list of targets 704 | test_cases Loads list of generated test cases 705 | baseline Loads the baseline information for all nodes 706 | """ 707 | argv = arg.split() 708 | if len(argv) < 2: 709 | print("expected selection and file name, see 'help save'") 710 | return 711 | selection = argv[0] 712 | file_name = argv[1] 713 | f = open(file_name, "rb") 714 | if selection == "all": 715 | tmp_devil = self.fz.devil 716 | self.fz = dill.load(f) 717 | self.fz.devil = tmp_devil 718 | print("everything loaded from {}".format(file_name)) 719 | elif selection == "fuzz_settings": 720 | self.fz.sm = dill.load(f) 721 | print("settings loaded from {}".format(file_name)) 722 | elif selection == "targets": 723 | self.fz.targets = dill.load(f) 724 | print("targets loaded from {}".format(file_name)) 725 | elif selection == "test_cases": 726 | self.fz.test_cases = dill.load(f) 727 | print("test cases loaded from {}".format(file_name)) 728 | elif selection == "baseline": 729 | baseline_info = dill.load(f) 730 | self.fz.sm.set("baseline_time", int(baseline_info[0])) 731 | self.fz.baseline = baseline_info[1] 732 | self.fz.baseline_messages = baseline_info[2] 733 | print("baseline data loaded from {}".format(file_name)) 734 | 735 | def do_set(self, arg): 736 | """ 737 | Provide a setting name and a value to set the setting. For a list of 738 | available settings and their current and default values see the 739 | settings command. 740 | 741 | example: 742 | set baseline_time 100 743 | """ 744 | argv = arg.split() 745 | name = argv[0] 746 | if len(argv) == 1: 747 | print("expected value, see 'help set'") 748 | return 749 | try: 750 | if self.fz.sm[name].datatype == int: 751 | if argv[1].startswith("0x"): 752 | self.fz.sm.set(name, int(argv[1], 16)) 753 | else: 754 | self.fz.sm.set(name, int(argv[1])) 755 | elif self.fz.sm[name].datatype == float: 756 | self.fz.sm.set(name, float(argv[1])) 757 | elif self.fz.sm[name].datatype == bool: 758 | if argv[1] in ["True", "true", "on", 1]: 759 | self.fz.sm.set(name, True) 760 | elif argv[1] in ["False", "false", "off", 0]: 761 | self.fz.sm.set(name, False) 762 | else: 763 | self.fz.sm.set(name, argv[1]) 764 | else: 765 | self.fz.sm.set(name, argv[1]) 766 | except ValueError as e: 767 | print("Could not set: {}".format(e)) 768 | return 769 | 770 | def do_target(self, arg): 771 | """ 772 | Add, remove, clear, and modify targets 773 | 774 | usage: target <(add, modify, remove)>
[PGN [REBOOTDATA]] 775 | 776 | Verbs: 777 | add Adds a new target to the end of the list 778 | modify Change an existing target 779 | remove Delete a target from the list 780 | list Show a list of the current targets 781 | clear Empty the list of targets out 782 | 783 | Arguments: 784 | address An address for the target [0..255] 785 | PGN Paramater Group Number (PGN) 786 | REBOOTDATA Message the ECU returns when it reboots 787 | 788 | 789 | examples: 790 | target add 231 60928 0x1122AABB 791 | target list 792 | target modify 231 66425 0x0 793 | target remove 231 794 | target clear 795 | """ 796 | argv = arg.split() 797 | 798 | def safe_get(vec, index, default): 799 | try: 800 | rval = vec[index] 801 | except: 802 | return default 803 | return rval 804 | 805 | tgtcmd = safe_get(argv, 0, None) 806 | if tgtcmd is None or tgtcmd == "list": 807 | for tgt in self.fz.targets: 808 | print(tgt) 809 | return 810 | 811 | if "clear" == argv[0]: 812 | self.fz.targets.clear() 813 | return 814 | 815 | if len(argv) <= 1: 816 | print("address expected:\n" 817 | "\tusage: target <(add, modify, remove)>
[PGN [REBOOTDATA]]") 818 | return 819 | 820 | if "remove" == argv[0]: 821 | try: 822 | for addr in argv[1:]: 823 | addr = int(addr) 824 | self.fz.remove_target(addr) 825 | except ValueError as e: 826 | print("error: {}".format(e)) 827 | return 828 | 829 | addr = safe_get(argv, 1, -1) 830 | pgn = safe_get(argv, 2, None) 831 | data = safe_get(argv, 3, None) 832 | 833 | if "modify" == argv[0]: 834 | self.fz.modify_target(addr, pgn, data) 835 | return 836 | 837 | if "add" == argv[0]: 838 | try: 839 | newtgt = self.fz.Target(addr, pgn, data) 840 | except ValueError as e: 841 | print("Error: {}".format(e)) 842 | return 843 | 844 | self.fz.add_target(newtgt) 845 | return 846 | 847 | print("unrecognized command: {}".format(argv[0])) 848 | return 849 | 850 | def do_record_baseline(self, arg): 851 | """ 852 | Record a baseline for fuzzing against 853 | """ 854 | self.fz.record_baseline() 855 | if len(self.fz.baseline) == 0: 856 | print("No messages detected during baseline.") 857 | return 858 | 859 | def do_show_baseline(self, arg): 860 | """ 861 | Show the baseline results 862 | """ 863 | if len(self.fz.baseline_messages) == 0: 864 | print("No baseline has been recorded yet. See the record_baseline command.") 865 | print( 866 | "Recorded {:<6} messages in {:<6} seconds".format(len(self.fz.baseline_messages), self.fz.sm.baseline_time)) 867 | print("Baseline time: {:<6} messages per second".format( 868 | len(self.fz.baseline_messages) / self.fz.sm.baseline_time)) 869 | 870 | def do_generate_test_cases(self, arg): 871 | """ 872 | Generate the messages the fuzzer will send during the fuzzing 873 | """ 874 | if len(self.fz.baseline) == 0 and (self.fz.sm.mode != 1): 875 | print("No baseline recorded yet. See 'help record_baseline'") 876 | return 877 | print("Creating " + str(self.fz.sm.num_messages) + " messages to fuzz...") 878 | self.fz.create_fuzz_list() 879 | return 880 | 881 | def do_start_fuzzer(self, arg): 882 | """ 883 | Start the fuzzer 884 | """ 885 | if len(self.fz.baseline) == 0: 886 | print("No baseline recorded yet. See 'help record_baseline'") 887 | return 888 | if len(self.fz.test_cases) == 0: 889 | print("No test cases generated yet. See 'help generate_test_cases'") 890 | return 891 | 892 | self.fz.done_fuzzing = False 893 | self.fz.pause_fuzzing = False 894 | self.fz.fuzzed_messages = [] 895 | self.fz.lock_fuzzed_messages = threading.RLock() 896 | 897 | anomaly_check_thread = threading.Thread(target=self.fz.anomaly_check, daemon=False) 898 | anomaly_check_thread.start() 899 | 900 | try: 901 | for i in progressbar(range(self.fz.sm.num_messages), "Sending: ", 40): 902 | m = self.fz.test_cases[i] 903 | # TODO: add option to add tp_dst_addr to send_message based on setting 904 | self.fz.devil.send_message(m) 905 | with self.fz.lock_fuzzed_messages: 906 | self.fz.fuzzed_messages.append(m) 907 | time.sleep(self.fz.sm.message_frequency) 908 | while self.fz.pause_fuzzing: 909 | time.sleep(1) 910 | if self.fz.done_fuzzing: 911 | break 912 | self.fz.done_fuzzing = True 913 | except KeyboardInterrupt: 914 | self.fz.done_fuzzing = True 915 | 916 | return 917 | 918 | @staticmethod 919 | def do_back(self, arg=None): 920 | """ 921 | Return to the main menu 922 | """ 923 | return True 924 | 925 | @staticmethod 926 | def do_EOF(self, arg=None): 927 | """ 928 | Following a ctrl-d quit the whole program 929 | """ 930 | sys.exit(0) 931 | 932 | 933 | def main_mod(argv, device): 934 | fcli = FuzzerCommands(device) 935 | if len(argv) > 0: 936 | fcli.run_commands(argv) 937 | else: 938 | fcli.cmdloop() 939 | --------------------------------------------------------------------------------