Skip to content

Commit

Permalink
test added
Browse files Browse the repository at this point in the history
  • Loading branch information
remibettan committed Mar 11, 2024
1 parent 25a2c59 commit 5baa112
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions unit-tests/live/d500/test-temperatures-xu-vs-hwmc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2024 Intel Corporation. All Rights Reserved.

# test:device D500*

import pyrealsense2 as rs
from rspy import test

# This test checks that the same values of temperature are received whether XU command or HWM Command are used.

dev = test.find_first_device_or_exit()
depth_sensor = dev.first_depth_sensor()
dp_device = dev.as_debug_protocol()


######################################## HELPERS ##########################################

def get_temperatures_from_xu():
pvt_temp = -10
ohm_temp = -10
proj_temp = -10

test.check(depth_sensor.supports(rs.option.soc_pvt_temperature))
test.check(depth_sensor.supports(rs.option.ohm_temperature))
test.check(depth_sensor.supports(rs.option.projector_temperature))

pvt_temp = depth_sensor.get_option(rs.option.soc_pvt_temperature)
ohm_temp = depth_sensor.get_option(rs.option.ohm_temperature)
proj_temp = depth_sensor.get_option(rs.option.projector_temperature)

return pvt_temp, ohm_temp, proj_temp


def parse_temperature_from_hwm(hwm_answer):
temperature = -10.0
relevant_data = hwm_answer[4:]
temperatures_list = []

test.check_equal(len(relevant_data), 20)
whole_number_part = 0
decimal_part = 0
for i in range(len(relevant_data)):
if i % 2 == 0:
decimal_part = relevant_data[i]
else:
whole_number_part = relevant_data[i]
current_temp = whole_number_part + decimal_part / 256.0
temperatures_list.append(current_temp)
whole_number_part = 0
decimal_part = 0
return temperatures_list


def get_temperatures_from_hwm():
pvt_temp = -10
ohm_temp = -10
proj_temp = -10

gtemp_opcode = 0x2a

# getting all the available temperatures
param_for_all_temp = 0
all_temp_cmd = dp_device.build_command(opcode=gtemp_opcode, param1=param_for_all_temp)
all_temp_list = parse_temperature_from_hwm(dp_device.send_and_receive_raw_data(all_temp_cmd))

# get pvt temperature
pvt_temp_index = 7
pvt_temp = all_temp_list[pvt_temp_index - 1]

# get ohm temperature
ohm_temp_index = 2
ohm_temp = all_temp_list[ohm_temp_index - 1]

# get projector temperature
proj_temp_index = 1
proj_temp = all_temp_list[proj_temp_index - 1]

return pvt_temp, ohm_temp, proj_temp


#############################################################################################

test.start("Compare Temperature readings XU vs HWMC")

pvt_temp_xu, ohm_temp_xu, projector_temp_xu = get_temperatures_from_xu()

pvt_temp_hwm, ohm_temp_hwm, projector_temp_hwm = get_temperatures_from_hwm()

tolerance = 0.1
test.check_approx_abs(pvt_temp_xu, pvt_temp_hwm, tolerance)
test.check_approx_abs(ohm_temp_xu, ohm_temp_hwm, tolerance)
test.check_approx_abs(projector_temp_xu, projector_temp_xu, tolerance)

test.finish()
#############################################################################################

test.print_results_and_exit()

0 comments on commit 5baa112

Please sign in to comment.