Home / Tutorials / Tutorial: Using the Mindsensors EV3Console in Linux

Tutorial: Using the Mindsensors EV3Console in Linux

If you have the Mindsensors EV3Console and you’re keen to use it on Linux, you’ll find that it is not immediately detected by the drivers built-in to Ubuntu 13.04.  Have no fear, though, it’s fairly easy to fix.  The specific distribution used here is Ubuntu 13.04.  If you’re using something else, you may need to tweak some path names and parameters.

udev to the rescue

udev is a system that allows you to automatically run some pre-defined rules when a device matching a specific signature is added or removed.  We’ll do the same for the EV3Console.

The VID (Vendor ID) and PID (Product ID) of the EV3Console is 0403 and abb9.  We can use these values to create the following udev rule in a file named /etc/udev/rules.d/70-mindsensors-ev3-console.rules:

root@ubuntu:/etc/udev/rules.d# cat 70-mindsensors-ev3-console.rules 
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="abb9", GROUP="users", MODE="0666", RUN+="/lib/udev/ev3console", SYMLINK+="ttyEV3"

That will also fix the permissions of the serial device that the EV3Console has created and make a fancy symlink from /dev/ttyEV3 to it.  That way you don’t have to look up what device was attached to it.  The script that it executes, /lib/udev/ev3console,  has the following contents:

root@ubuntu:/etc/udev/rules.d# cat /lib/udev/ev3console 
#!/bin/sh

/sbin/modprobe ftdi_sio && \
  echo 0403 abb9 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id

Ensure that this ev3console script is executable.

Now when you plug it in, the /dev/ttyEV3 symlink will point to the correct USB TTY, which will have the permissions specified in the udev rule.

root@ubuntu:/etc/udev/rules.d# ls -l /dev/ttyEV3 
lrwxrwxrwx 1 root root 7 Aug 15 04:27 /dev/ttyEV3 –> ttyUSB0 
root@ubuntu:/etc/udev/rules.d# ls -l /dev/ttyUSB0 
crw-rw-rw- 1 root users 188, 0 Aug 15 04:27 /dev/ttyUSB0

You can tighten up the permissions to this device if you like, by creating a new group and adding yourself to it. You’ll have to tweak the GROUP and MODE parts of the udev rules as well.

Accessing the console

You can now access the console at /dev/ttyEV3.  I like to use the screen program for this, but there are many others.  The EV3’s serial console operates at 115200 baud, using 8N1 (8 bit, no parity, 1 stop bit).

xander@ubuntu:~$ screen /dev/ttyEV3 115200

This should open a full screen session to your EV3.

2013-08-18_07-39-43

 

You can exit the screen session with CTRL-A SHIFT-k.

How does it work?

The EV3Console uses an FTDI USB to UART bridge but the Product ID is not something that’s been added to the FTDI kernel module, yet.  The cool thing is, you can dynamically add new IDs to the kernel module’s list of recognised devices.  Simply echo the VID and PID into the /sys/bus/usb-serial/drivers/ftdi_sio/new_id file and you’re done.  Now when it’s plugged in, you’ll see the following appear in your logs:

[2717184.665929] usb 2-2.1: new full-speed USB device number 15 using uhci_hcd 
[2717184.787965] usb 2-2.1: New USB device found, idVendor=0403, idProduct=abb9 
[2717184.787968] usb 2-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 
[2717184.787970] usb 2-2.1: Product: EV3Consol 
[2717184.787972] usb 2-2.1: Manufacturer: mindsensors.com 
[2717184.795042] ftdi_sio 2-2.1:1.0: FTDI USB Serial Device converter detected 
[2717184.795060] usb 2-2.1: Detected FT232RL 
[2717184.795062] usb 2-2.1: Number of endpoints 2 
[2717184.795063] usb 2-2.1: Endpoint 1 MaxPacketSize 64 
[2717184.795065] usb 2-2.1: Endpoint 2 MaxPacketSize 64 
[2717184.795066] usb 2-2.1: Setting MaxPacketSize 64 
[2717184.798242] usb 2-2.1: FTDI USB Serial Device converter now attached to ttyUSB0

Pretty nifty, eh?

Please note that I am not an expert on udev, in fact, this was the first time I’ve ever really looked into it.  I am sure there are nicer ways to doing this.  If you have suggestions, please leave a comment.

About Xander

Xander Soldaat is a Software Engineer and former Infrastructure Architect. He loves building and programming robots. He recently had the opportunity to turn his robotics hobby into his profession and has started working for Robomatter, the makers of ROBOTC and Robot Virtual Words.