Skip to content

Commit

Permalink
test added, python wrapper corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
remibettan committed May 11, 2021
1 parent 48f1f2c commit 9647eb7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
51 changes: 51 additions & 0 deletions unit-tests/func/dfu/test-device-fw-compatibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2021 Intel Corporation. All Rights Reserved.

# test:device L500*
# test:device D400*

import pyrealsense2 as rs
from rspy import test


def check_firmware_not_compatible(updatable_device, old_fw_image):
test.check(not updatable_device.check_firmware_compatibility(old_fw_image))

def check_firmware_compatible(updatable_device, old_fw_image):
test.check(updatable_device.check_firmware_compatibility(old_fw_image))


ctx = rs.context()
dev = ctx.query_devices()[0]
updatable_device = dev.as_updatable()

#############################################################################################
test.start("checking firmware compatibility with device")
pid = dev.get_info(rs.camera_info.product_id)
if pid == '0B3A': # D435I
print("device D435i found")
with open("Signed_Image_UVC_5_12_6_0.bin", 'rb') as binary_file:
old_fw_image = bytearray(binary_file.read())
check_firmware_not_compatible(updatable_device, old_fw_image)
with open("Signed_Image_UVC_5_12_7_100.bin", 'rb') as binary_file:
old_fw_image = bytearray(binary_file.read())
check_firmware_compatible(updatable_device, old_fw_image)
elif pid == '0B07': # D435
print("device D435 found")
with open("Signed_Image_UVC_5_8_14_0.bin", 'rb') as binary_file:
old_fw_image = bytearray(binary_file.read())
check_firmware_not_compatible(updatable_device, old_fw_image)
with open("Signed_Image_UVC_5_8_15_0.bin", 'rb') as binary_file:
old_fw_image = bytearray(binary_file.read())
check_firmware_compatible(updatable_device, old_fw_image)
elif pid == '0B64': # L515
print("device L515 found")
with open("Signed_Image_UVC_1_4_0_10.bin", 'rb') as binary_file:
old_fw_image = bytearray(binary_file.read())
check_firmware_not_compatible(updatable_device, old_fw_image)
with open("Signed_Image_UVC_1_4_1_0.bin", 'rb') as binary_file:
old_fw_image = bytearray(binary_file.read())
check_firmware_compatible(updatable_device, old_fw_image)

test.finish()
test.print_results_and_exit()
5 changes: 2 additions & 3 deletions wrappers/python/pyrs_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ void init_device(py::module &m) {
.def("update_unsigned", [](rs2::updatable& self, const std::vector<uint8_t>& fw_image, std::function<void(float)> f, int update_mode) { return self.update_unsigned(fw_image, f, update_mode); },
"Update an updatable device to the provided unsigned firmware. This call is executed on the caller's thread and it supports progress notifications via the callback.",
"fw_image"_a, "callback"_a, "update_mode"_a = RS2_UNSIGNED_UPDATE_MODE_UPDATE, py::call_guard<py::gil_scoped_release>())
.def("check_firmware_compatibility", [](rs2::updatable& self, const std::vector<uint8_t>& fw_image) { return self.check_firmware_compatibility(fw_image); },
"Check firmware compatibility with device. This method should be called before burning a signed firmware.",
"fw_image"_a);
.def("check_firmware_compatibility", &rs2::updatable::check_firmware_compatibility, "Check firmware compatibility with device. "
"This method should be called before burning a signed firmware.", "image"_a);

py::class_<rs2::update_device, rs2::device> update_device(m, "update_device");
update_device.def(py::init<rs2::device>())
Expand Down

0 comments on commit 9647eb7

Please sign in to comment.