การวินิจฉัย

แพลตฟอร์ม SDV มีชุด API ที่ใช้ระหว่าง Diagnostics Manager ที่ OEM จัดหาให้กับชุดบริการ SDV รวมถึงยูทิลิตีและความสามารถของแพลตฟอร์มทั่วไปเพื่อรองรับ Use Case การวินิจฉัยของ OEM การวินิจฉัยเป็นสิ่งสำคัญสำหรับความพยายามด้าน SDV, บริการยานยนต์ และเทคโนโลยีที่เรามอบให้แก่ OEM เนื่องจากชุดการวินิจฉัยเป็นองค์ประกอบสำคัญของระบบปฏิบัติการยานยนต์ทุกระบบ

OEM จะติดตั้งใช้งานอินสแตนซ์ของ Diagnostics Manager (โดยปกติคือ 1 อินสแตนซ์ต่อ ECU หรือ 1 อินสแตนซ์ต่อ VM) เพื่อจัดการคำขอจากไคลเอ็นต์การวินิจฉัยโดยการสื่อสารกับชุดบริการ SDV ในระบบ โดย SDV จะมีชุด API การวินิจฉัยมาตรฐาน ยูทิลิตี และการสนับสนุนแพลตฟอร์มโดยรวมสำหรับการใช้การวินิจฉัยของ OEM เป้าหมายของเราคือ

  • ช่วยให้ OEM สามารถใช้ Diagnostics Manager ตามมาตรฐาน UDS
  • อนุญาตให้ Diagnostics Manager มอบหมายคำขอของผู้ทดสอบไปยังแพ็กเกจบริการ SDV
  • อนุญาตให้ชุดบริการ SDV แสดงข้อมูลการวินิจฉัยในลักษณะที่ไม่ขึ้นอยู่กับยานพาหนะ

เพื่อจุดประสงค์นี้ SDV จึงมีชุด API เพื่อกำหนดมาตรฐานการโต้ตอบระหว่าง ชุดบริการ SDV (ซึ่งอาจให้บริการโดยบุคคลที่สาม) กับการติดตั้งใช้งานสแต็กการวินิจฉัยของ OEM

กลุ่มการวินิจฉัย

รูปที่ 1 ชุดเครื่องมือการวินิจฉัย

แพ็กเกจบริการ SDV สามารถเปิดเผยข้อมูลและการวินิจฉัย ใช้ฟังก์ชันการวินิจฉัย และรายงานการทำงานผิดปกติไปยัง Diagnostics Manager

การจัดหา API การวินิจฉัยมาตรฐานทั่วทั้ง SDV ช่วยให้เราลดความซับซ้อนในการติดตั้งใช้งาน ชุดบริการ SDV และหลีกเลี่ยงความจำเป็นในการติดตั้งใช้งานการวินิจฉัยซ้ำเพื่อเรียกใช้ใน ยานพาหนะต่างๆ จาก OEM ที่แตกต่างกัน

API ของบริการวินิจฉัย

SDV Diagnostics API กำหนดบริการต่อไปนี้ ซึ่งสอดคล้องกับบริการ UDS (ISO 14229-1) ที่เฉพาะเจาะจง

  • service AuthenticationService: 0x29 (การตรวจสอบสิทธิ์) โดยมีกลไกให้ไคลเอ็นต์พิสูจน์ตัวตนเพื่อเข้าถึงข้อมูลหรือบริการที่ถูกจำกัด
  • service DataItemService: 0x22 (ReadDataByIdentifier) และ 0x2E (WriteDataByIdentifier) ซึ่งช่วยให้อ่านและเขียนองค์ประกอบข้อมูลที่ระบุโดย DID ได้
  • service EcuResetService: 0x11 (ECUReset) ซึ่งช่วยให้ผู้ทดสอบขอรีเซ็ต ECU ได้
  • service FileTransferService: 0x34 (RequestDownload), 0x35 (RequestUpload), 0x36 (TransferData), 0x37 (RequestTransferExit) และ 0x38 (RequestFileTransfer) โดยจะจัดการการเริ่มต้นและการประมวลผลการดาวน์โหลดและการอัปโหลดไฟล์
  • service IoControlService: 0x2F (InputOutputControlByIdentifier) ซึ่งช่วยให้ผู้ทดสอบภายนอกควบคุมอินพุตและเอาต์พุตของระบบเพื่อวัตถุประสงค์ในการทดสอบได้
  • service RoutineControlService: 0x31 (RoutineControl) ซึ่งช่วยให้ผู้ทดสอบสามารถเริ่ม หยุด และขอผลลัพธ์สำหรับกิจวัตร (ฟังก์ชัน) ที่เฉพาะเจาะจงซึ่งบริการ SDV ได้นำไปใช้
  • service SecurityAccessService: 0x27 (SecurityAccess) โดยจะจัดการการแลกเปลี่ยน Seed และคีย์ที่จำเป็นต่อการปลดล็อกระดับความปลอดภัยที่เฉพาะเจาะจง

นอกจากนี้ SDV Diagnostics API ยังกําหนด service FaultListenerService และ message Event ตาม Diagnostic Event Manager (AUTOSAR_SWS_DiagnosticEventManager) ของ AUTOSAR ซึ่งช่วยให้ แอปพลิเคชันรายงานเหตุการณ์การวินิจฉัยและการทํางานผิดปกติได้

นอกจากนี้ service DiagnosticsManagerService ยังกำหนดบริการแพลตฟอร์ม SDV ที่ช่วยให้บริการอื่นๆ สามารถค้นหาพารามิเตอร์การเชื่อมต่อการวินิจฉัยปัจจุบัน (ที่อยู่ต้นทาง ที่อยู่เป้าหมาย) และประเภทเซสชัน

คู่มือนักพัฒนาซอฟต์แวร์เกี่ยวกับแพ็กเกจบริการ

ในฐานะนักพัฒนาซอฟต์แวร์ชุดบริการ diagnostics_declaration และ เซิร์ฟเวอร์ต่อไปนี้สามารถกำหนดได้ในไฟล์ .vsidl ที่เกี่ยวข้อง

service_bundle {
    name: "<BUNDLE-NAME>"
    ...
    server {
        service: "com.sdv.google.diagnostics.data_item.DataItemService"
    }
    server {
        service: "com.sdv.google.diagnostics.routine_control.RoutineControlService"
    }
    server {
        service: "com.sdv.google.diagnostics.io_control.IoControlService"
    }
    server {
        service: "com.sdv.google.diagnostics.fault.FaultListenerService"
    }
    ...
    diagnostics_declaration {
        data_item {
            ...
        }

        routine {
            ...
        }

        event {
            ...
        }

        io_control {
            ...
        }
    }
    ...
}

DiagnosticsDeclaration ข้อความหมายถึง

package sdv.diagnostics.v1;

message DiagnosticsDeclaration {
  // Diagnostics data item declaration.
  //
  // See com.sdv.google.diagnostics.data_item.DataItemService service.
  message DataItem {
    // Required. Id of the data item.
    string id = 1;

    // Required. Fully qualified name of the message that defines a structure of
    // the data item.
    string message_name = 2;

    // Flag that indicates whether the data item is writable by the Diagnostics
    // Manager.
    //
    // Effectively, this indicates whether the call to DataItemService::Write,
    // is supported for this data item id.
    bool is_writable = 3;
  }

  // Declaration of diagnostics data for input/output control.
  //
  // See com.sdv.google.diagnostics.io_control.IoControl service.
  message InputOutputControlData {
    // Id of the input/output control data.
    string id = 1;

    // Fully qualified name of the message that defines a structure of the data.
    string message_name = 2;
  }

  // Declaration of diagnostics routine.
  //
  // See com.sdv.google.diagnostics.routine_control.RoutineControl.
  message Routine {
    // Information about routine control method.
    message Method {
      // Fully qualified name of the request message.
      string request = 1;

      // Fully qualified name of the response message.
      string response = 2;
    }

    // Id of the routine.
    string id = 1;

    // Information about routine start method.
    //
    // See com.sdv.google.diagnostics.routine_control.RoutineControl::Start.
    Method start = 2;

    // Information about routine stop method.
    //
    // See com.sdv.google.diagnostics.routine_control.RoutineControl::Stop.
    Method stop = 3;

    // Information about routine result method.
    //
    // See
    // com.sdv.google.diagnostics.routine_control.RoutineControl::RequestResult.
    Method result = 4;
  }

  // Declaration of diagnostics event and corresponding fault listener.
  //
  // See com.sdv.google.diagnostics.event.Event.
  // See com.sdv.google.diagnostics.fault.FaultListener.
  message Event {
    // Id of the event.
    string id = 1;

    // Fully qualified message name of the event's extended data message.
    string extended_data_message_name = 2;

    // Fault status changes which service wants to be notified of.
    //
    // See com.sdv.google.diagnostics.fault.FaultListener.StatusMask.
    uint32 fault_listener_mask = 3;

    // User-defined service unit name of a corresponding event publisher.
    string service_unit_name = 4;
  }

  // Diagnostic data items exposed by the service bundle.
  repeated DataItem data_item = 1;

  // Diagnostic data exposed for input/output control by the service bundle.
  repeated InputOutputControlData io_control = 2;

  // Diagnostic routines exposed by the service bundle.
  repeated Routine routine = 3;

  // Diagnostic events sent by the service bundle.
  repeated Event event = 4;
}

หากมีการกำหนดservice_bundleบล็อกที่มี diagnostics_declaration ไว้ในแคตตาล็อก vsidl_rc_generator จะสร้าง prebuilt_etc เป้าหมายสำหรับแพ็กเกจบริการทุกแพ็กเกจที่ประกาศเซิร์ฟเวอร์ข้างต้น และ diagnostics_declaration

prebuilt_etc {
    name: "<APEX-NAME>.<BUNDLE-NAME>-diag-config.binpb",
    filename: "DiagService-diag-config.binpb",
    sub_dir: "vsidl_provider",
    src: ":generate_vsidl_files_single_bundle_<APEX-NAME>.<BUNDLE-NAME>{diagnostics-config.binpb}",
    installable: false,
}

ต้องเพิ่มเป้าหมายเหล่านี้ลงใน prebuilts ของบล็อกคำจำกัดความ Apex ที่เกี่ยวข้องตามที่ระบุ โดยบล็อกความคิดเห็นที่สร้างขึ้นโดยอัตโนมัติที่เกี่ยวข้องเหนือบล็อก prebuilt_etc {}

apex {
    name: "<APEX-NAME>",
    ...
    prebuilts: [
        ...
        "<APEX-NAME>.<BUNDLE-NAME>-diag-config.binpb",
        ...
    ],
    ...
}

นอกจากนี้ คุณยังต้องเพิ่มเป้าหมายเหล่านี้ในฟิลด์ diagnostics_config_path ของ รายการ sdv_service_bundle_metadata ของแพ็กเกจในไฟล์ sdv_service_bundles_manifest.textproto ที่เกี่ยวข้องด้วย นอกจากนี้ คุณต้องระบุนโยบายการให้สิทธิ์เพื่อเปิดใช้การสื่อสาร RPC ระหว่างชุดบริการกับบริการตัวจัดการการวินิจฉัย ดังนี้

sdv_service_bundle_metadata {
  name: "<BUNDLE-NAME>"
  ...
  diagnostics_config_path: "etc/vsidl_provider/<BUNDLE-NAME>-diag-config.binpb"
  authorization_policy_path: "etc/authz/permissions.textproto"
  ...
}

สิทธิ์ในไฟล์ permissions.textproto ควรระบุบทบาทของไคลเอ็นต์หรือเซิร์ฟเวอร์ ตัวอย่างเช่น หากแพ็กเกจบริการใช้รายการข้อมูลการวินิจฉัย

server {
    service: "com.sdv.google.diagnostics.data_item.DataItemService"
    allow_all_channels: true
}

คู่มือนักพัฒนาแพลตฟอร์ม

ในฐานะนักพัฒนาแพลตฟอร์ม OEM ต้องใช้ Agent ของ Diagnostics Manager rust_binary target ดังนี้

rust_binary {
    name: "<DIAGNOSTICS-AGENT-BINARY-EXECUTABLE-NAME>",
    ...
    product_specific: true,
    ...
}

นอกจากนี้ ในไฟล์บิลด์ คุณต้องตั้งค่า/เขียนทับตัวแปรต่อไปนี้ SDV_DIAGNOSTICS_AGENT_MODULE := <DIAGNOSTICS-AGENT-BINARY-EXECUTABLE-NAME>

เพื่อความสะดวก คุณสามารถใช้libsdv_uds_serde_v1ไลบรารีสำหรับการแปล Proto ↔ UDS และใช้ไลบรารีผู้ให้บริการ VSIDL สำหรับการสะท้อน

ไฟล์ .vsidl ของตัวแทนการวินิจฉัยควรมีเนื้อหาต่อไปนี้

package: "com.sdv.oem.diagnostics"

service_bundle {
    name: "DiagnosticsAgent"

    server {
        service: "com.sdv.google.diagnostics.DiagnosticsManagerService"
    }

    client {
        service: "com.sdv.google.diagnostics.data_item.DataItemService"
    }

    client {
        service: "com.sdv.google.diagnostics.routine_control.RoutineControlService"
    }

    client {
        service: "com.sdv.google.diagnostics.io_control.IoControlService"
    }

    client {
        service: "com.sdv.google.diagnostics.fault.FaultListenerService"
    }

    client {
        service: "com.sdv.google.diagnostics.ecu_reset.EcuResetService"
    }

    client {
        service: "com.sdv.google.diagnostics.security_access.SecurityAccessService"
    }

    client {
        service: "com.sdv.google.diagnostics.authentication.AuthenticationService"
    }

    client {
        service: "com.sdv.google.diagnostics.file_transfer.FileTransferService"
    }
}

เนื่องจากเอเจนต์ตัวจัดการการวินิจฉัยเป็นไฟล์ที่ดำเนินการได้แบบไบนารี sdv_service_bundle_metadata ของแพ็กเกจจึงกำหนดเป็นการประกาศเฉพาะการกำหนดค่า

sdv_service_bundle_metadata {
    # This name must match the agent's Bundle Name
    name: "DiagnosticsAgent"
    version_number: 1
    version_name: "1"

    # Reference the manifest itself to mark this as a config-only declaration.
    native_library_path: "etc/sdv_service_bundles_manifest.textproto"

    authorization_policy_path: "etc/authz/permissions.textproto"
}

นโยบายการให้สิทธิ์ตัวแทนการวินิจฉัยควรกำหนดสิทธิ์สำหรับบริการที่ตัวแทนโต้ตอบด้วย เช่น หากเรียกใช้บริการโอนไฟล์

client {
    service: "com.sdv.google.diagnostics.file_transfer.FileTransferService"
    allow_all_channels: true
}