Fix multiply serial USB ports (ttyUSB) on a RPi with a symlink

Hello All,

I have the following configuration:

  • USB > RS-485 to communicate with my „climate“ modbus
  • USB > RS-485 to communicate with my „outdoor lights“ modbus
  • Z-wave stick

I’ve got it all working but when I reboot my pi I sometimes have to change the SerialPort Port setting…

I tried to follow this PersistentUSBDevices - Domoticz (sorry I used domoticz in the past) tutorial but for some reason I cannot select the new created symlink in IP-symcon. And if I set it using the IPS_SetProperty function. It sais the Value is not available.

2017-03-04 22_44_11-mRemoteNG - confCons.xml - ServerPI.png



2017-03-04 22_22_59-IP-Symcon Management Console [My Server].png

I hope one of you can help me out.

Hi, many here in this Forum have the same problem and no one have a fix. The symcon team unfortunately does not fix the annoying problem.

Maybe there is a way to make a workaround with a script???

Thank you for you reply! I have no clue how to do this with a script, do you have an example for me?

Ok, I think I fixed it! Maybe good a work around for the rest who are looking for this solution. Here my tutorial:

Step 1:
In this step we are going to find the information to identify our USB serial device.

Using putty or your favorite ssh client, run:

sudo lsusb -v | more

find and note these values for each of your device:
*idVendor (without „0x“)
*idProduct (without „0x“)
*iSerial (if this is zero, you can ignore it)

I found these values for my RS485 converter:
idVendor: 0403
idProduct: 6001
iSerial: A9U95FZF

Step 2:
In this step we are going to create a rule for the udev to make a symlink. I wanted the name symlink ttyUSB-MBclima so I can easily remember and recognize it. Of course you can enter your own name

Run:

sudo nano /etc/udev/rules.d/99-usb-serial.rules

Add the following line with the values for each device you found:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A9U95FZF", SYMLINK+="ttyUSB-MBclima"

Step 3:
Now we are going to restart your device and check if the symlinks are created:

Run:

cd /dev
ls -l

the last command will give you a list of all the files in this directory. look for something like this:

lrwxrwxrwx 1 root root           7 Mar  6 18:17 ttyUSB-MBclima -> ttyUSB0

this is your symlink.

Step 4:
Make the script:

Make a script and add this:

$rightTTYport = "/dev/".exec("readlink /dev/ttyUSB-MBclima");

IPS_SetProperty(50297 /*[MB_Clima]*/, "Port", $rightTTYport);

Change the following values to the right values as it is configured in your setup:

  • ttyUSB-MBclima (the name of the symlink you have created in step 2)
  • 50297 /[MB_Clima]/ (the objectID of used serial connection in „I/O instances“)

Step 5:
Run the script at startup of IP-symcon

Go to „Core Instances“ > „Events“ and add the created script to „Startup Script“ field.

That’s it! I tested it and it works like a charm!

Thanks, i will give it a try

Forgot to add IPS_ApplyChanges() to the script… Why can’t i change my messages

The script should look like this:

<?
$ID = 50297 /*[MB_Clima]*/;
$rightTTYport = "/dev/".exec("readlink /dev/ttyUSB-MBclima");

IPS_SetProperty($ID, "Port", $rightTTYport);
IPS_ApplyChanges($ID)

?>

works realy great!! thanks a lot - was frustrated by loosing USB connection every reboot :wink:
you made my day !!

Sorry fürs hochziehen des alten Beitrags, aber Google findet diese Themen immer noch :slight_smile:

IP-Symcon 5.6 wird Symlinks auf /dev/ttyUSB* erkennen und ebenfalls unterstützten

paresy