9 import pyrealsense2
as rs, sys, os, subprocess, re
10 from rspy
import devices, log, test, file, repo
12 if not devices.acroname:
13 log.i(
"No Acroname library found; skipping device FW update" )
16 from rspy
import acroname
18 devices.acroname.discover()
19 except acroname.NoneFoundError
as e:
25 devices.acroname =
None 32 command = command.lower()
33 command = command.replace(
" ",
"")
34 current_uint8_t_string =
'' 35 for i
in range(0, len(command)):
36 current_uint8_t_string += command[i]
37 if len(current_uint8_t_string) >= 2:
38 command_input.append(int(
'0x' + current_uint8_t_string, 0))
39 current_uint8_t_string =
'' 40 if current_uint8_t_string !=
'':
41 command_input.append(int(
'0x' + current_uint8_t_string, 0))
44 raw_result = rs.debug_protocol( device ).send_and_receive_raw_data( command_input )
49 product_line = device.get_info( rs.camera_info.product_line )
52 if product_line ==
"L500":
53 cmd =
"14 00 AB CD 09 00 00 00 30 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00" 54 elif product_line ==
"D400":
55 cmd =
"14 00 AB CD 09 00 00 00 30 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00" 57 log.f(
"Incompatible product line:", product_line )
63 product_line = device.get_info( rs.camera_info.product_line )
66 if product_line ==
"L500":
67 cmd =
"14 00 AB CD 0A 00 00 00 30 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00" 68 elif product_line ==
"D400":
69 cmd =
"14 00 AB CD 86 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" 71 log.f(
"Incompatible product line:", product_line )
78 for tool
in file.find( repo.root,
'(^|/)rs-fw-update.exe$' ):
79 fw_updater_exe = os.path.join( repo.root, tool)
80 if not fw_updater_exe:
81 log.f(
"Could not find the update tool file (rs-fw-update.exe)" )
83 devices.query( monitor_changes =
False )
84 sn_list = devices.all()
86 if len( sn_list ) != 1:
87 log.f(
"Expected 1 device, got", len( sn_list ) )
88 device = devices.get( list( sn_list )[0] )
89 log.d(
'found:', device )
90 current_fw_version = repo.pretty_fw_version( device.get_info( rs.camera_info.firmware_version ))
91 log.d(
'FW version:', current_fw_version )
92 product_line = device.get_info( rs.camera_info.product_line )
93 log.d(
'product line:', product_line )
94 bundled_fw_version = repo.pretty_fw_version( device.get_info( rs.camera_info.recommended_firmware_version ) )
95 log.d(
'bundled FW version:', bundled_fw_version )
98 log.d(
'update counter:', update_counter )
100 log.d(
'resetting update counter' )
104 image_name = product_line[0:2] +
"XX_FW_Image-" + bundled_fw_version +
".bin" 105 image_mask =
'(^|/)' + image_name +
'$' 107 for image
in file.find( repo.root, image_mask ):
108 image_file = os.path.join( repo.root, image)
110 log.f(
"Could not find image file for " + product_line +
" device with FW version: " + bundled_fw_version )
111 test.start(
"Update FW" )
113 cmd = [fw_updater_exe,
'-f', image_file]
114 log.d(
'running:', cmd )
115 subprocess.run( cmd )
116 except Exception
as e:
117 test.unexpected_exception()
120 devices.query( monitor_changes =
False )
121 sn_list = devices.all()
122 device = devices.get( list( sn_list )[0] )
123 current_fw_version = repo.pretty_fw_version( device.get_info( rs.camera_info.firmware_version ))
124 test.check_equal( current_fw_version, bundled_fw_version )
125 if update_counter < 19:
132 test.print_results_and_exit()
def send_hardware_monitor_command(device, command)
def get_update_counter(device)
virtual frame finish(frame f)
def reset_update_counter(device)