    p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)
  MAZDA_VERSION_RESPONSE =  bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
    p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)
  
  # brand, request, response, response offset
  REQUESTS = [
    # Hyundai
    (
      "hyundai",
 
</s> remove   )
 </s> add   ),
  # Nissan
  (
    "nissan",
    [NISSAN_DIAGNOSTIC_REQUEST_KWP, NISSAN_VERSION_REQUEST_KWP],
    [NISSAN_DIAGNOSTIC_RESPONSE_KWP, NISSAN_VERSION_RESPONSE_KWP],
    DEFAULT_RX_OFFSET,
  ),
  (
    "nissan",
    [NISSAN_DIAGNOSTIC_REQUEST_KWP, NISSAN_VERSION_REQUEST_KWP],
    [NISSAN_DIAGNOSTIC_RESPONSE_KWP, NISSAN_VERSION_RESPONSE_KWP],
    NISSAN_RX_OFFSET,
  ),
  (
    "nissan",
    [NISSAN_VERSION_REQUEST_STANDARD],
    [NISSAN_VERSION_RESPONSE_STANDARD],
    NISSAN_RX_OFFSET,
  ),
NISSAN_DIAGNOSTIC_REQUEST_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, 0xc0])
NISSAN_DIAGNOSTIC_RESPONSE_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, 0xc0])

NISSAN_VERSION_REQUEST_KWP = b'\x21\x83'
NISSAN_VERSION_RESPONSE_KWP = b'\x61\x83'

NISSAN_VERSION_REQUEST_STANDARD = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
  p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)
NISSAN_VERSION_RESPONSE_STANDARD =  bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
  p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)

NISSAN_RX_OFFSET = 0x20

    p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)
  MAZDA_VERSION_RESPONSE =  bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
    p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)
  
NISSAN_DIAGNOSTIC_REQUEST_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, 0xc0])
NISSAN_DIAGNOSTIC_RESPONSE_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, 0xc0])

NISSAN_VERSION_REQUEST_KWP = b'\x21\x83'
NISSAN_VERSION_RESPONSE_KWP = b'\x61\x83'

NISSAN_VERSION_REQUEST_STANDARD = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
  p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)
NISSAN_VERSION_RESPONSE_STANDARD =  bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
  p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER)

NISSAN_RX_OFFSET = 0x20

  # brand, request, response, response offset
  REQUESTS = [
    # Hyundai
    (
      "hyundai",
keep keep keep add keep keep keep keep keep
 Fingerprinting v2 support for Nissan vehicles (#22655)

* Add Nissan FPv2

* Update Nissan version response

* Add second Nissan FPv2 query

* Add multiple offsets for Nissan

* Nissan offset fix

* Add Nissan diagnostic request

* Use 21 83 for Nissan version request

* Add partial 2018 Leaf FPv2

* Update 2018 Leaf FPv2

* Nissan FPv2: more RX offsets, add no diagostic request scan for 0x20

* Add FPv2 imports to Nissan values

* Change LEAF to LEAF_IC

It is an instrument cluster leaf. With this minor change it works :).

* fixed ecu addr for nissan eps

* Remove FW not used for fpv2

* Remove unused offsets

* add fw versions for 2018 Nissan Leaf JP

* add standard ecu fw query

* add esp fw

* add nissan xtrail

* Add missing ESP FW for 2018 Nissan Leaf IC

* Add fwdCamera FW for Xtrail 2017

* add missing comma

* Add 0x8 default offset

needed e.g. for xtrail engine ecu

* Apply suggestions from code review

Co-authored-by: Willem Melching <willem.melching@gmail.com>

* Fix variable naming

* remove unnecessary part of standard fw query

* add fw versions for CAN-GW ECU

* transmission eco does not reliable answer -> remove

* add Altima FWs (part 1)

* add Altima EPS FW

* Remove NISSAN_KWP_DIAGNOSTIC_REQUEST and cleanup

* Revert "Remove NISSAN_KWP_DIAGNOSTIC_REQUEST and cleanup"

This reverts commit 808d6f1562e9a6cb57ea365d184b74d51f6da017.

* cleanup

Co-authored-by: Martin Lillepuu <martin@mlp.ee>
Co-authored-by: Julian Pieles <julian@pieles.digital>
Co-authored-by: Willem Melching <willem.melching@gmail.com> 
selfdrive/car/fw_versions.py