User Space Drivers¶
This driver provides a configfs interface for creating user-defined devices that use the various ev3dev drivers. Currently, only ports, sensors and LEDs are implemented. Motors could be added in the future.
All commands assume root privileges.
Here is an example of how to create a port and a sensor:
Make sure module is loaded:
Go to the configfs directory for this driver:
Create a new port called p1:
Check out the new port - there should be
cd p1 ls
This also creates a new port that is linked to
Now create a sensor named
s1attached to this port:
Check out the sensor:
These attributes correspond to attributes in the
lego-sensorclass. Set them as appropriate. For example:
echo "my-driver" > sensors/s1/driver_name
Once the attributes have been set, export the sensor by linking it to
ln -s sensors/s1 live
There will be two new devices created, one in
/sys/class/user-lego-sensor/and one in
lego-sensorclass device is used just as any other sensor. The
user-lego-sensordevice is used to feed data into the sensor. See the user-lego-sensor-class docs for more info.
To remove the sensor and port, perform the operations in reverse:
rm link/s1 rmdir sensors/s1 cd .. rmdir p1
The user-lego-sensor Subsystem¶
user-lego-sensor class provides an interface for implementing user-defined
sensors in userspace.
Since the name of the
sensor<N> device node does not correspond to the port
that a sensor is plugged in to, you must look at the
address attribute if
you need to know which port a sensor is plugged in to. This will match the
address of the corresponding sensor in the
Sensors can be found at
is incremented each time a sensor is loaded.
<N> does not correspond to the address of sensor.
||write-only||Writing stores the data which can be read using the
||write-only||Writing stores the value which can be read using the