1

Fixed USB /dev/name for USB Micro Teleinfo device

Today I received a mail from a user who asked me how to fix /dev/ttyUSBx  name for Micro Teleinfo devices. This make sense because on linux, ordering number can sometime be different if you have multiple USB Serial device connected (whatever chip in it such as FTDI, PL2303, CP2302, CH340, …)

Linux USB/Serial called /dev/ttyUSBx

The first detected device will be named /dev/ttyUSB0 , the 2nd /dev/ttyUSB1  and so on. But you can’t be sure  that this order will be the same on each boot. The only thing that is sure is that if you have only one, it will be called each boot /dev/ttyUSB0 which works for majority of you. Here I will present a method to prevent this and more have a named device to be more precise. What about having USB Serial holding teleinfo named /dev/teleinfo  or a Arduino named  /dev/arduino  or /dev/nano  ?

How to fix this?

It’s quite simple, in fact, just follow this tutorial based on Linux udev deamon that does all the dirty job. Note that this tutorial is done on a Raspberry PI V2 with debian Wheezy on it. I can see using lsb_release . If it’s not installed use this command to install it

If you have another version such latest Jessie and there are some differences, please let me know so I can update this post.

And here is my config:

Connect Micro Teleinfo USB device

Now I’ve connected 2 Micro Teleinfo devices and I can see the USB device #5 and #6, with ID 0403:005 with /dev/ttyUSB0 and /dev/ttyUSB1

Identify device Serial Number

Now let’s go deep into device Serial number identification, each Micro Teleinfo board has it own serial number that I put in when I test the boards.

Let’s look at the serial numbers with udevadm walking and grabbing serial number

Ok, has you can see, /dev/ttyUSB0  has serial number   TINFO-144  and /dev/ttyUSB1  serial number  TINFO-142

Let’s imagine you connected the device TINFO-144 to your Teleinfo Solar PV (your production counter) and TINFO-142 connected to your ErDF counter (the one you pay to your provider for your consumption) and want to have the PV production called /dev/teleinfo_pv  and the other /dev/teleinfo_erdf

Use udev rules to the rescue

We just need to create a file for udev deamon in /etc/udev/rules.d  folder. I called this one 88-usb-serial.rules

Here is the complete file  :

Don’t forget to change file to reflect your serial numbers. The MODE=”0777″ is not mandatory, it’s just to set all rights to everyone to the devices.

The first time, so now because you just created the file, you need to reboot the Pi and here are the results after reboot :

As you can see, a symbolic link as been added to the correct /dev/ttyUSB  and as the usb number can change, the link will always be mapped to the correct one.

Once rebooted, for the the other time, if you want to add new devices, you just need to change the 88-usb-serial.rules file and issue these two commands :

This one to reload rules

udevadm control --reload-rules 

and the 2nd to enumerate again all devices

Note that prolific devices don’t seem to have a serial number so a good way to identify them is to add the DRIVERS in the file as follow :
SUBSYSTEM=="tty", DRIVERS=="pl2303", SYMLINK+="ttyUSBpl"

Hope you like this tip, and don’t forget, you can use this method for any other device.

 

 

 

Charles

Charles

Comments on this topic in community Forums.