Skip to content

List all sensors #293

@craigsammisutherland

Description

@craigsammisutherland

There is a function for listing all the attached motors, but nothing for listing the sensors. Based on list_motors, I came up with the following function that seems to list all the sensors:

def list_sensors(name_pattern=ev3.Sensor.SYSTEM_DEVICE_NAME_CONVENTION, **kwargs):
   classpath = abspath(ev3.Device.DEVICE_ROOT_PATH + '/' + ev3.Sensor.SYSTEM_CLASS_NAME)
   return (ev3.Sensor(name_pattern=name, name_exact=True) 
           for name in ev3.list_device_names(classpath, name_pattern, **kwargs))

Is this correct? If so, is it worthwhile adding to the library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions