4

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?

  • 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
4

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 "=".

1

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.

1

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.

  • 1
    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
0

try this:

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

It links ttys1 to the real ttys2.

Tested to work on applications such as minicom with a USB-to-serial adapter (/dev/ttyUSB0) on Ubuntu Lucid.

It does not survive reboots, unless you add it to a script (eg: /etc/rc.local on most Linux distros)

  • 1
    Actually, /dev is dynamically created on boot, so that won't survive a reboot. – Fahad Sadah Apr 30 '10 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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