I have a server running Debian Linux which has a built in serial port which is coming up as ttyS0. I have a plug in PCI card with two serial ports that are being registered with Linux as ttyS2 and ttyS3.

Unfortunately I am trying to run some software which assumes that ttyS0 and ttyS1 are available. Is it possible to remap the serial port device names (using a udev rule?) such that ttyS0 remains as it is and ttyS2 becomes ttyS1?

link|improve this question
Is this open source? If it is can you link to it, might be easy to fix the software. – Kyle Brandt Apr 30 '10 at 13:27
It's a fragile piece of proprietary test software unfortunately. The long term plan is to fix it so that it will work on any machine configuration. – davefiddes Apr 30 '10 at 14:08
feedback

4 Answers

up vote 1 down vote accepted

You can use udev for this. Create a file /etc/udev/rules.d/90-rename-serial-ports.rule containing

ACTION=="add" KERNEL=="ttyS2" NAME="ttyS1"

should do it (not tested). Note the difference between "==" and "=".

link|improve this answer
This seems to work like a dream. Thanks! – davefiddes May 2 '10 at 17:47
feedback

How about a plain mv /dev/ttyS2 /dev/ttyS1? After all most devices are just a file located under /dev.

LE: You need to do the renaming every time you boot.

link|improve this answer
feedback

You shouldn't be fiddling with the names like this. Use setserial to unmap ttyS2 and to map ttyS1 to its resources. And then you should find whoever wrote that code and introduce them to the back of your hand. They really ought to know better by now.

link|improve this answer
Can't seem to see how to do this with setserial. Even if I could get it to work it wouldn't work with other serial devices like USB serial dongles which limits its utility. Also, bad software is worryingly common, getting angry about it doesn't help. I just try to stop it happening on my watch. – davefiddes May 2 '10 at 17:49
feedback

try this:

sudo ln -s /dev/ttys2 /dev/ttys1

It should link ttys1 to ttys2 and survive reboots.

link|improve this answer
Actually, /dev is dynamically created on boot, so that won't survive a reboot. – fahadsadah Apr 30 '10 at 15:12
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.