UDS_SERVICES: dict[int, dict] = {
    0x10: {
        "name": "DiagnosticSessionControl",
        "abbr": "DSC",
        "group": "Session Management",
        "positive_response_sid": 0x50,
        "subfunctions": {
            0x01: "defaultSession",
            0x02: "programmingSession",
            0x03: "extendedDiagnosticSession",
        },
        "available_in": ["default", "programming", "extended"],
        "description": (
            "Enables switching between diagnostic sessions. "
            "Controls which services and subfunctions are accessible."
        ),
        "request_format": "10 <subFunction>",
        "response_format": (
            "50 <subFunction> <p2ServerMax_high> <p2ServerMax_low> "
            "<p2StarServerMax_high> <p2StarServerMax_low>"
        ),
        "min_length": 2,
        "max_length": 2,
        "example_request": "10 03",
        "example_response": "50 03 00 19 01 F4",
    },
    0x11: {
        "name": "ECUReset",
        "abbr": "ER",
        "group": "Session Management",
        "positive_response_sid": 0x51,
        "subfunctions": {
            0x01: "hardReset",
            0x02: "keyOffOnReset",
            0x03: "softReset",
        },
        "available_in": ["default", "programming", "extended"],
        "description": "Requests an ECU reset with specific reset type.",
        "request_format": "11 <resetType>",
        "response_format": "51 <resetType>",
        "min_length": 2,
        "max_length": 2,
        "example_request": "11 01",
        "example_response": "51 01",
    },
    0x14: {
        "name": "ClearDiagnosticInformation",
        "abbr": "CDI",
        "group": "DTC Management",
        "positive_response_sid": 0x54,
        "subfunctions": {},
        "available_in": ["default", "extended"],
        "description": "Clears DTCs within the specified DTC group.",
        "request_format": "14 <groupOfDTC 3 bytes>",
        "response_format": "54",
        "min_length": 4,
        "max_length": 4,
        "example_request": "14 FF FF FF",
        "example_response": "54",
    },
    0x19: {
        "name": "ReadDTCInformation",
        "abbr": "RDI",
        "group": "DTC Management",
        "positive_response_sid": 0x59,
        "subfunctions": {
            0x01: "reportNumberOfDTCByStatusMask",
            0x02: "reportDTCByStatusMask",
            0x03: "reportDTCSnapshotIdentification",
            0x04: "reportDTCSnapshotRecordByDTCNumber",
            0x05: "reportDTCExtDataRecordByDTCNumber",
            0x06: "reportNumberOfDTCBySeverityMaskRecord",
            0x07: "reportDTCBySeverityMaskRecord",
            0x08: "reportSeverityInformationOfDTC",
            0x09: "reportSupportedDTC",
            0x0A: "reportAllSupportedDTC",
            0x0B: "reportFirstTestFailedDTC",
            0x0C: "reportFirstConfirmedDTC",
            0x0D: "reportMostRecentTestFailedDTC",
            0x0E: "reportMostRecentConfirmedDTC",
            0x0F: "reportMirrorMemoryDTCByStatusMask",
            0x10: "reportMirrorMemoryDTCExtDataRecordByDTCNumber",
            0x11: "reportNumberOfMirrorMemoryDTCByStatusMask",
            0x12: "reportNumberOfEmissionsRelatedOBDDTCByStatusMask",
            0x13: "reportEmissionsRelatedOBDDTCByStatusMask",
            0x14: "reportDTCFaultDetectionCounter",
            0x15: "reportDTCWithPermanentStatus",
        },
        "available_in": ["default", "extended"],
        "description": "Reads DTCs, status, snapshots, and extended data.",
        "request_format": "19 <subFunction> <params...>",
        "response_format": "59 <subFunction> <data...>",
        "min_length": 2,
        "max_length": 0,
        "example_request": "19 02 08",
        "example_response": "59 02 08 01 23 45 40",
    },
    0x22: {
        "name": "ReadDataByIdentifier",
        "abbr": "RDBI",
        "group": "Data Transmission",
        "positive_response_sid": 0x62,
        "subfunctions": {},
        "available_in": ["default", "programming", "extended"],
        "description": "Reads ECU data by identifier (DID).",
        "request_format": "22 <DID> [<DID>...]",
        "response_format": "62 <DID> <data...>",
        "min_length": 3,
        "max_length": 0,
        "example_request": "22 F1 90",
        "example_response": "62 F1 90 31 48 47 ...",
    },
    0x23: {
        "name": "ReadMemoryByAddress",
        "abbr": "RMBA",
        "group": "Data Transmission",
        "positive_response_sid": 0x63,
        "subfunctions": {},
        "available_in": ["programming", "extended"],
        "description": "Reads memory at a specified address range.",
        "request_format": "23 <ALFID> <address> <size>",
        "response_format": "63 <data...>",
        "min_length": 4,
        "max_length": 0,
        "example_request": "23 44 00 00 10 00 10",
        "example_response": "63 <data...>",
    },
    0x24: {
        "name": "ReadScalingDataByIdentifier",
        "abbr": "RSDBI",
        "group": "Data Transmission",
        "positive_response_sid": 0x64,
        "subfunctions": {},
        "available_in": ["default", "extended"],
        "description": "Reads scaling information for a DID.",
        "request_format": "24 <DID>",
        "response_format": "64 <DID> <data...>",
        "min_length": 3,
        "max_length": 3,
        "example_request": "24 F1 86",
        "example_response": "64 F1 86 01 02",
    },
    0x27: {
        "name": "SecurityAccess",
        "abbr": "SA",
        "group": "Session Management",
        "positive_response_sid": 0x67,
        "subfunctions": {
            0x01: "requestSeedLevel1",
            0x02: "sendKeyLevel1",
            0x03: "requestSeedLevel2",
            0x04: "sendKeyLevel2",
            0x05: "requestSeedLevel3",
            0x06: "sendKeyLevel3",
        },
        "available_in": ["programming", "extended"],
        "description": "Seed-key access to unlock protected services.",
        "request_format": "27 <subFunction> [<key/seed...>]",
        "response_format": "67 <subFunction> <seed...>",
        "min_length": 2,
        "max_length": 0,
        "example_request": "27 01",
        "example_response": "67 01 12 34 56 78",
    },
    0x28: {
        "name": "CommunicationControl",
        "abbr": "CC",
        "group": "Session Management",
        "positive_response_sid": 0x68,
        "subfunctions": {
            0x00: "enableRxAndTx",
            0x01: "enableRxDisableTx",
            0x02: "disableRxEnableTx",
            0x03: "disableRxAndTx",
        },
        "available_in": ["extended"],
        "description": "Controls ECU communication behavior.",
        "request_format": "28 <subFunction> <communicationType>",
        "response_format": "68 <subFunction>",
        "min_length": 3,
        "max_length": 3,
        "example_request": "28 03 01",
        "example_response": "68 03",
    },
    0x29: {
        "name": "Authentication",
        "abbr": "AUTH",
        "group": "Session Management",
        "positive_response_sid": 0x69,
        "subfunctions": {
            0x01: "requestChallenge",
            0x02: "verifyResponse",
            0x03: "authenticationComplete",
        },
        "available_in": ["extended", "programming"],
        "description": "ISO 14229-1:2020 authentication services.",
        "request_format": "29 <subFunction> <data...>",
        "response_format": "69 <subFunction> <data...>",
        "min_length": 2,
        "max_length": 0,
        "example_request": "29 01",
        "example_response": "69 01 12 34",
    },
    0x2A: {
        "name": "ReadDataByPeriodicIdentifier",
        "abbr": "RDBPI",
        "group": "Data Transmission",
        "positive_response_sid": 0x6A,
        "subfunctions": {
            0x01: "stopSending",
            0x02: "sendAtSlowRate",
            0x03: "sendAtMediumRate",
            0x04: "sendAtFastRate",
        },
        "available_in": ["default", "extended"],
        "description": "Request periodic transmission of DIDs.",
        "request_format": "2A <transmissionMode> <DID>...",
        "response_format": "6A <transmissionMode>",
        "min_length": 3,
        "max_length": 0,
        "example_request": "2A 02 F1 90",
        "example_response": "6A 02",
    },
    0x2C: {
        "name": "DynamicallyDefineDataIdentifier",
        "abbr": "DDDID",
        "group": "Data Transmission",
        "positive_response_sid": 0x6C,
        "subfunctions": {
            0x01: "defineByIdentifier",
            0x02: "defineByMemoryAddress",
            0x03: "clearDynamicallyDefinedDataIdentifier",
        },
        "available_in": ["extended"],
        "description": "Create or clear dynamic DIDs.",
        "request_format": "2C <subFunction> <dynamicDID> <data...>",
        "response_format": "6C <subFunction> <dynamicDID>",
        "min_length": 4,
        "max_length": 0,
        "example_request": "2C 01 F2 00 F1 90",
        "example_response": "6C 01 F2 00",
    },
    0x2E: {
        "name": "WriteDataByIdentifier",
        "abbr": "WDBI",
        "group": "Data Transmission",
        "positive_response_sid": 0x6E,
        "subfunctions": {},
        "available_in": ["extended", "programming"],
        "description": "Writes data to a specified DID.",
        "request_format": "2E <DID> <data...>",
        "response_format": "6E <DID>",
        "min_length": 4,
        "max_length": 0,
        "example_request": "2E F1 90 31 32",
        "example_response": "6E F1 90",
    },
    0x2F: {
        "name": "InputOutputControlByIdentifier",
        "abbr": "IOCBI",
        "group": "I/O Control",
        "positive_response_sid": 0x6F,
        "subfunctions": {
            0x00: "returnControlToECU",
            0x01: "resetToDefault",
            0x02: "freezeCurrentState",
            0x03: "shortTermAdjustment",
        },
        "available_in": ["extended"],
        "description": "Control an I/O signal or actuator by DID.",
        "request_format": "2F <DID> <controlOption> <data...>",
        "response_format": "6F <DID> <controlOption>",
        "min_length": 4,
        "max_length": 0,
        "example_request": "2F 12 34 03 FF",
        "example_response": "6F 12 34 03",
    },
    0x31: {
        "name": "RoutineControl",
        "abbr": "RC",
        "group": "Routine Control",
        "positive_response_sid": 0x71,
        "subfunctions": {
            0x01: "startRoutine",
            0x02: "stopRoutine",
            0x03: "requestRoutineResults",
        },
        "available_in": ["extended", "programming"],
        "description": "Start, stop, or query a routine by identifier.",
        "request_format": "31 <subFunction> <routineID> <data...>",
        "response_format": "71 <subFunction> <routineID> <data...>",
        "min_length": 4,
        "max_length": 0,
        "example_request": "31 01 FF 00",
        "example_response": "71 01 FF 00 00",
    },
    0x34: {
        "name": "RequestDownload",
        "abbr": "RD",
        "group": "Upload / Download",
        "positive_response_sid": 0x74,
        "subfunctions": {},
        "available_in": ["programming"],
        "description": "Initiate a download (flash programming) sequence.",
        "request_format": "34 <dataFormatIdentifier> <ALFID> <address> <size>",
        "response_format": "74 <lengthFormatIdentifier> <maxNumberOfBlockLength>",
        "min_length": 4,
        "max_length": 0,
        "example_request": "34 00 44 00 00 10 00 10",
        "example_response": "74 20 04 00",
    },
    0x35: {
        "name": "RequestUpload",
        "abbr": "RU",
        "group": "Upload / Download",
        "positive_response_sid": 0x75,
        "subfunctions": {},
        "available_in": ["programming", "extended"],
        "description": "Initiate an upload (read ECU memory) sequence.",
        "request_format": "35 <dataFormatIdentifier> <ALFID> <address> <size>",
        "response_format": "75 <lengthFormatIdentifier> <maxNumberOfBlockLength>",
        "min_length": 4,
        "max_length": 0,
        "example_request": "35 00 44 00 00 10 00 10",
        "example_response": "75 20 04 00",
    },
    0x36: {
        "name": "TransferData",
        "abbr": "TD",
        "group": "Upload / Download",
        "positive_response_sid": 0x76,
        "subfunctions": {},
        "available_in": ["programming"],
        "description": "Transfer data blocks during download/upload.",
        "request_format": "36 <blockSequenceCounter> <data...>",
        "response_format": "76 <blockSequenceCounter>",
        "min_length": 2,
        "max_length": 0,
        "example_request": "36 01 AA BB",
        "example_response": "76 01",
    },
    0x37: {
        "name": "RequestTransferExit",
        "abbr": "RTE",
        "group": "Upload / Download",
        "positive_response_sid": 0x77,
        "subfunctions": {},
        "available_in": ["programming"],
        "description": "Finalize transfer and exit download/upload.",
        "request_format": "37 <data...>",
        "response_format": "77 <data...>",
        "min_length": 1,
        "max_length": 0,
        "example_request": "37",
        "example_response": "77",
    },
    0x38: {
        "name": "RequestFileTransfer",
        "abbr": "RFT",
        "group": "Upload / Download",
        "positive_response_sid": 0x78,
        "subfunctions": {
            0x01: "addFile",
            0x02: "deleteFile",
            0x03: "replaceFile",
            0x04: "readFile",
        },
        "available_in": ["programming"],
        "description": "File-based OTA transfer service.",
        "request_format": "38 <modeOfOperation> <filePath> <data...>",
        "response_format": "78 <modeOfOperation> <data...>",
        "min_length": 2,
        "max_length": 0,
        "example_request": "38 01 2F 66 69 6C 65",
        "example_response": "78 01",
    },
    0x3D: {
        "name": "WriteMemoryByAddress",
        "abbr": "WMBA",
        "group": "Data Transmission",
        "positive_response_sid": 0x7D,
        "subfunctions": {},
        "available_in": ["programming"],
        "description": "Writes memory at a specified address range.",
        "request_format": "3D <ALFID> <address> <data...>",
        "response_format": "7D",
        "min_length": 4,
        "max_length": 0,
        "example_request": "3D 44 00 00 10 00 AA BB",
        "example_response": "7D",
    },
    0x3E: {
        "name": "TesterPresent",
        "abbr": "TP",
        "group": "Session Management",
        "positive_response_sid": 0x7E,
        "subfunctions": {0x00: "zeroSubFunction"},
        "available_in": ["default", "programming", "extended"],
        "description": "Keep-alive to prevent session timeout.",
        "request_format": "3E <subFunction>",
        "response_format": "7E <subFunction>",
        "min_length": 2,
        "max_length": 2,
        "example_request": "3E 00",
        "example_response": "7E 00",
    },
    0x83: {
        "name": "AccessTimingParameter",
        "abbr": "ATP",
        "group": "Session Management",
        "positive_response_sid": 0xC3,
        "subfunctions": {
            0x01: "readExtendedTimingParameterSet",
            0x02: "setTimingParametersToDefault",
            0x03: "readCurrentlyActiveTimingParameters",
        },
        "available_in": ["extended"],
        "description": "Read or set timing parameters.",
        "request_format": "83 <subFunction> [<params...>]",
        "response_format": "C3 <subFunction> <params...>",
        "min_length": 2,
        "max_length": 0,
        "example_request": "83 03",
        "example_response": "C3 03 00 19 01 F4",
    },
    0x84: {
        "name": "SecuredDataTransmission",
        "abbr": "SDT",
        "group": "Session Management",
        "positive_response_sid": 0xC4,
        "subfunctions": {},
        "available_in": ["extended", "programming"],
        "description": "Transmit secured data blocks.",
        "request_format": "84 <data...>",
        "response_format": "C4 <data...>",
        "min_length": 1,
        "max_length": 0,
        "example_request": "84 01 02 03",
        "example_response": "C4 01",
    },
    0x85: {
        "name": "ControlDTCSetting",
        "abbr": "CDS",
        "group": "Session Management",
        "positive_response_sid": 0xC5,
        "subfunctions": {
            0x01: "on",
            0x02: "off",
        },
        "available_in": ["extended"],
        "description": "Enable or disable DTC setting.",
        "request_format": "85 <subFunction>",
        "response_format": "C5 <subFunction>",
        "min_length": 2,
        "max_length": 2,
        "example_request": "85 02",
        "example_response": "C5 02",
    },
    0x86: {
        "name": "ResponseOnEvent",
        "abbr": "ROE",
        "group": "Session Management",
        "positive_response_sid": 0xC6,
        "subfunctions": {
            0x00: "stopResponseOnEvent",
            0x01: "onDTCStatusChange",
            0x02: "onTimer",
            0x03: "onChangeOfDataIdentifier",
        },
        "available_in": ["extended"],
        "description": "Configure ECU to respond on events.",
        "request_format": "86 <subFunction> <eventType> <params...>",
        "response_format": "C6 <subFunction>",
        "min_length": 2,
        "max_length": 0,
        "example_request": "86 01 00",
        "example_response": "C6 01",
    },
    0x87: {
        "name": "LinkControl",
        "abbr": "LC",
        "group": "Session Management",
        "positive_response_sid": 0xC7,
        "subfunctions": {
            0x01: "verifyBaudrateTransition",
            0x02: "transitionBaudrate",
        },
        "available_in": ["extended"],
        "description": "Link-layer speed change control.",
        "request_format": "87 <subFunction> <baudrateIdentifier>",
        "response_format": "C7 <subFunction>",
        "min_length": 3,
        "max_length": 3,
        "example_request": "87 01 0A",
        "example_response": "C7 01",
    },
}
