legoEv3/ev3dev2/__pycache__/port.cpython-35.pyc
h^[ @ sQ d d l Z d d l m Z e j d k r7 e d Gd d d e Z d S)
N )Device z"Must be using Python 3.4 or higherc s e Z d Z d Z d Z d Z d d d d d d g Z d
e d f d d
Z e d d Z e d d Z
e d d Z e d d Z e j
d d Z e d d Z e j
d d Z e d d Z S)LegoPortaP
The `lego-port` class provides an interface for working with input and
output ports that are compatible with LEGO MINDSTORMS RCX/NXT/EV3, LEGO
WeDo and LEGO Power Functions sensors and motors. Supported devices include
the LEGO MINDSTORMS EV3 Intelligent Brick, the LEGO WeDo USB hub and
various sensor multiplexers from 3rd party manufacturers.
Some types of ports may have multiple modes of operation. For example, the
input ports on the EV3 brick can communicate with sensors using UART, I2C
or analog validate signals - but not all at the same time. Therefore there
are multiple modes available to connect to the different types of sensors.
In most cases, ports are able to automatically detect what type of sensor
or motor is connected. In some cases though, this must be manually specified
using the `mode` and `set_device` attributes. The `mode` attribute affects
how the port communicates with the connected device. For example the input
ports on the EV3 brick can communicate using UART, I2C or analog voltages,
but not all at the same time, so the mode must be set to the one that is
appropriate for the connected sensor. The `set_device` attribute is used to
specify the exact type of sensor that is connected. Note: the mode must be
correctly set before setting the sensor type.
Ports can be found at `/sys/class/lego-port/port<N>` where `<N>` is
incremented each time a new port is registered. Note: The number is not
related to the actual port at all - use the `address` attribute to find
a specific port.
z lego-port*_address_driver_name_modes_mode_set_device_statusNFc sr | d k r | | d <t t | j | j | | | d | _ d | _ d | _ d | _ d | _ d | _ d S)Naddress)
superr __init__SYSTEM_CLASS_NAMEr r r
r r r
)selfr Zname_patternZ
name_exactkwargs) __class__ ./usr/lib/python3/dist-packages/ev3dev2/port.pyr I s
" zLegoPort.__init__c C s" | j | j d \ | _ } | S)z
Returns the name of the port. See individual driver documentation for
the name that will be returned.
r )get_attr_stringr )r valuer r r r V s zLegoPort.addressc C s" | j | j d \ | _ } | S)z
Returns the name of the driver that loaded this device. You can find the
complete list of drivers in the [list of port drivers].
driver_name)r r )r r r r r r _ s zLegoPort.driver_namec C s" | j | j d \ | _ } | S)zD
Returns a list of the available modes of the port.
modes)Zget_attr_setr
)r r r r r r h s zLegoPort.modesc C s" | j | j d \ | _ } | S)a<
Reading returns the currently selected mode. Writing sets the mode.
Generally speaking when the mode changes any sensor or motor devices
associated with the port will be removed new ones loaded, however this
this will depend on the individual driver implementing this class.
mode)r r )r r r r r r p s z
LegoPort.modec C s | j | j d | | _ d S)Nr )set_attr_stringr )r r r r r r { s c C s t d d S)an
For modes that support it, writing the name of a driver will cause a new
device to be registered for that driver and attached to this port. For
example, since NXT/Analog sensors cannot be auto-detected, you must use
this attribute to load the correct driver. Returns -EOPNOTSUPP if setting a
device is not supported.
z$set_device is a write-only property!N) Exception)r r r r
set_device s zLegoPort.set_devicec C s | j | j d | | _ d S)Nr )r r )r r r r r r s c C s" | j | j d \ | _ } | S)a&
In most cases, reading status will return the same value as `mode`. In
cases where there is an `auto` mode additional values may be returned,
such as `no-device` or `error`. See individual port driver documentation
for the full list of possible values.
status)r r
)r r r r r r s zLegoPort.status)__name__
__module____qualname____doc__r ZSYSTEM_DEVICE_NAME_CONVENTION __slots__r propertyr r r r setterr r r r )r r r ! s$
r )r r )sys r version_infoSystemErrorr r r r r <module> s