Ejemplo n.º 1
0
def reset_update_counter(device):
    product_line = device.get_info(rs.camera_info.product_line)
    cmd = None

    if product_line == "L500":
        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"
    elif product_line == "D400":
        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"
    else:
        log.f("Incompatible product line:", product_line)

    send_hardware_monitor_command(device, cmd)
Ejemplo n.º 2
0
def find_first_device_or_exit():
    """
    :return: the first device that was found, if no device is found the test is skipped. That way we can still run
        the unit-tests when no device is connected and not fail the tests that check a connected device
    """
    import pyrealsense2 as rs
    c = rs.context()
    if not c.devices.size():  # if no device is connected we skip the test
        log.f("No device found")
    dev = c.devices[0]
    log.d( 'found', dev )
    return dev
Ejemplo n.º 3
0
def find_devices_by_product_line_or_exit( product_line ):
    """
    :param product_line: The product line of the wanted devices
    :return: A list of devices of specific product line that was found, if no device is found the test is skipped.
        That way we can still run the unit-tests when no device is connected
        and not fail the tests that check a connected device
    """
    import pyrealsense2 as rs
    c = rs.context()
    devices_list = c.query_devices(product_line)
    if devices_list.size() == 0:
        log.f( "No device of the", product_line, "product line was found" )
    log.d( 'found', devices_list.size(), product_line, 'devices:', [dev for dev in devices_list] )
    return devices_list
Ejemplo n.º 4
0
def find_image_or_exit(product_name, fw_version_regex=r'(\d+\.){3}(\d+)'):
    """
    Searches for a FW image file for the given camera name and optional version. If none are
    found, exits with an error!
    
    :param product_name: the name of the camera, from get_info(rs.camera_info.name)
    :param fw_version_regex: optional regular expression specifying which FW version image to find
    
    :return: the image file corresponding to product_name and fw_version if exist, otherwise exit
    """
    pattern = re.compile(r'^Intel RealSense (((\S+?)(\d+))(\S*))')
    match = pattern.search(product_name)
    if not match:
        raise RuntimeError("Failed to parse product name '" + product_name +
                           "'")

    # For a product 'PR567abc', we want to search, in order, these combinations:
    #     PR567abc
    #     PR306abX
    #     PR306aXX
    #     PR306
    #     PR30X
    #     PR3XX
    # Each of the above, combined with the FW version, should yield an image name like:
    #     PR567aXX_FW_Image-<fw-version>.bin
    suffix = 5  # the suffix
    for j in range(1, 3):  # with suffix, then without
        start_index, end_index = match.span(j)
        for i in range(0, len(match.group(suffix))):
            pn = product_name[start_index:end_index - i]
            image_name = '(^|/)' + pn + i * 'X' + "_FW_Image-" + fw_version_regex + r'\.bin$'
            for image in file.find(repo.root, image_name):
                return os.path.join(repo.root, image)
        suffix -= 1
    #
    # If we get here, we didn't find any image...
    global product_line
    log.f("Could not find image file for", product_line)
Ejemplo n.º 5
0
n_assertions = 0
n_failed_assertions = 0
n_tests = 0
n_failed_tests = 0
test_failed = False
test_in_progress = False
test_info = {} # Dictionary for holding additional information to print in case of a failed check.

# if --context flag was sent, the test is running under a specific context which could affect its run
context = None
if '--context' in sys.argv:
    context_index = sys.argv.index( '--context' )
    try:
        context = sys.argv.pop(context_index + 1)
    except IndexError:
        log.f( "Received context flag but no context" )
    sys.argv.pop( context_index )


def set_env_vars( env_vars ):
    """
    We want certain environment variables set when we get here. We assume they're not set.

    However, it is impossible to change the current running environment to see them. Instead, we rerun ourselves
    in a child process that inherits the environment we set.

    To do this, we depend on a specific argument in sys.argv that tells us this is the rerun (meaning child
    process). When we see it, we assume the variables are set and don't do anything else.

    For this to work well, the environment variable requirement (set_env_vars call) should appear as one of the
    first lines of the test.
Ejemplo n.º 6
0
#test:priority 0
#test:device each(L500*)
#test:device each(D400*)

import pyrealsense2 as rs, sys, os, subprocess
from rspy import devices, log, test, file, repo

if not devices.acroname:
    log.i("No Acroname library found; skipping device FW update")
    sys.exit(0)
# Following will throw if no acroname module is found
from rspy import acroname
try:
    devices.acroname.discover()
except acroname.NoneFoundError as e:
    log.f(e)
# Remove acroname -- we're likely running inside run-unit-tests in which case the
# acroname hub is likely already connected-to from there and we'll get an error
# thrown ('failed to connect to acroname (result=11)'). We do not need it -- just
# needed to verify it is available above...
devices.acroname = None


def send_hardware_monitor_command(device, command):
    command_input = []  # array of uint_8t

    # Parsing the command to array of unsigned integers(size should be < 8bits)
    # threw out spaces
    command = command.lower()
    command = command.replace(" ", "")
    current_uint8_t_string = ''
max_time_for_device_creation = 1.5
print("Device creation time is: {:.3f} [sec] max allowed is: {:.1f} [sec] ".
      format(device_creation_time, max_time_for_device_creation))
test.check(device_creation_time < max_time_for_device_creation)
test.finish()

# Set maximum delay for first frame according to product line
product_line = dev.get_info(rs.camera_info.product_line)
if product_line == "D400":
    max_delay_for_depth_frame = 1.5
    max_delay_for_color_frame = 1.5
elif product_line == "L500":
    max_delay_for_depth_frame = 2.5  # L515 depth frame has a 1.5 seconds built in delay at the FW side + 1.0 second for LRS
    max_delay_for_color_frame = 1.5
else:
    log.f("This test support only D400 + L515 devices")

ds = dev.first_depth_sensor()
cs = dev.first_color_sensor()

dp = next(p for p in ds.profiles
          if p.fps() == 30 and p.stream_type() == rs.stream.depth
          and p.format() == rs.format.z16)

cp = next(p for p in cs.profiles
          if p.fps() == 30 and p.stream_type() == rs.stream.color
          and p.format() == rs.format.rgb8)

#####################################################################################################
test.start("Testing first depth frame delay on " + product_line +
           " device - " + platform.system() + " OS")
Ejemplo n.º 8
0
 except getopt.GetoptError as err:
     print('-F-', err)  # something like "option -a not recognized"
     usage()
 if args:
     usage()
 try:
     if acroname:
         if not acroname.hub:
             acroname.connect()
     action = 'list'
     for opt, arg in opts:
         if opt in ('--list'):
             action = 'list'
         elif opt in ('--all'):
             if not acroname:
                 log.f('No acroname available')
             acroname.enable_ports(sleep_on_change=5)
         elif opt in ('--port'):
             if not acroname:
                 log.f('No acroname available')
             all_ports = acroname.all_ports()
             str_ports = arg.split(',')
             ports = [
                 int(port) for port in str_ports
                 if port.isnumeric() and int(port) in all_ports
             ]
             if len(ports) != len(str_ports):
                 log.f('Invalid ports', str_ports)
             acroname.enable_ports(ports,
                                   disable_other_ports=True,
                                   sleep_on_change=5)
Ejemplo n.º 9
0
#test:device each(L500*)
#test:device each(D400*)

import pyrealsense2 as rs, sys, os, subprocess
from rspy import devices, log, test, file, repo
import re, platform

if not devices.acroname:
    log.i("No Acroname library found; skipping device FW update")
    sys.exit(0)
# Following will throw if no acroname module is found
from rspy import acroname
try:
    devices.acroname.discover()
except acroname.NoneFoundError as e:
    log.f(e)
# Remove acroname -- we're likely running inside run-unit-tests in which case the
# acroname hub is likely already connected-to from there and we'll get an error
# thrown ('failed to connect to acroname (result=11)'). We do not need it -- just
# needed to verify it is available above...
devices.acroname = None


def send_hardware_monitor_command(device, command):
    command_input = []  # array of uint_8t

    # Parsing the command to array of unsigned integers(size should be < 8bits)
    # threw out spaces
    command = command.lower()
    command = command.replace(" ", "")
    current_uint8_t_string = ''
Ejemplo n.º 10
0
#test:priority 0
#test:device each(L500*)
#test:device each(D400*)

import pyrealsense2 as rs, sys, os, subprocess, re
from rspy import devices, log, test, file, repo

if not devices.acroname:
    log.i("No Acroname library found; skipping device FW update")
    sys.exit(0)
# Following will throw if no acroname module is found
from rspy import acroname
try:
    devices.acroname.discover()
except acroname.NoneFoundError as e:
    log.f(e)
# Remove acroname -- we're likely running inside run-unit-tests in which case the
# acroname hub is likely already connected-to from there and we'll get an error
# thrown ('failed to connect to acroname (result=11)'). We do not need it -- just
# needed to verify it is available above...
devices.acroname = None


def send_hardware_monitor_command(device, command):
    command_input = []  # array of uint_8t

    # Parsing the command to array of unsigned integers(size should be < 8bits)
    # threw out spaces
    command = command.lower()
    command = command.replace(" ", "")
    current_uint8_t_string = ''
Ejemplo n.º 11
0
        base = os.path.dirname(build_dir)
        if base == build_dir:
            log.d(
                'could not find CMakeCache.txt; cannot assume build dir from',
                dir)
            break
        build_dir = base


if len(args) > 1:
    usage()
exe_dir = None  # the directory in which we expect to find exes
if len(args) == 1:
    exe_dir = args[0]
    if not os.path.isdir(exe_dir):
        log.f('Not a directory:', exe_dir)
    build_dir = find_build_dir(exe_dir)
else:
    build_dir = repo.build  # may not actually contain exes
    #log.d( 'repo.build:', build_dir )

# Python scripts should be able to find the pyrealsense2 .pyd or else they won't work. We don't know
# if the user (Travis included) has pyrealsense2 installed but even if so, we want to use the one we compiled.
# we search the librealsense repository for the .pyd file (.so file in linux)
pyrs = ""
if linux:
    for so in file.find(exe_dir or build_dir or repo.root,
                        '(^|/)pyrealsense2.*\.so$'):
        pyrs = so
else:
    for pyd in file.find(exe_dir or build_dir or repo.root,
Ejemplo n.º 12
0
                log.debug_indent()
                devices.enable_only(serial_numbers, recycle=True)
            except RuntimeError as e:
                log.w(log.red + test.name + log.reset + ': ' + str(e))
            else:
                test_wrapper(test, configuration)
            finally:
                log.debug_unindent()
        #
    finally:
        log.debug_unindent()

log.progress()
#
if not n_tests:
    log.f('No unit-tests found!')
#
if list_only:
    if list_tags and list_tests:
        for t in sorted(tests, key=lambda x: x.name):
            print(t.name, "has tags:", ' '.join(t.config.tags))
    #
    elif list_tags:
        for t in sorted(list(available_tags)):
            print(t)
    #
    elif list_tests:
        for t in sorted(tests, key=lambda x: x.name):
            print(t.name)
#
else: