LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 03-02-2008, 09:50 AM   #1
Simmo512
LQ Newbie
 
Registered: Nov 2007
Posts: 19

Rep: Reputation: 0
Question Is it possible to hard code a USB component to a ttyUSB device?


I have two USB devices, one a USB 3g modem and the other a GPS receiver.

On boot more often than not the modem will get ttyUSB0, which allows me to configure my wvdial.conf nicely for it. But every so often the GPS receiver gets ttyUSB0 instead and breaks my startup scripts.

Questions:-
1) Is it possible to hard code a USB device to a ttyUSB device rather than the system deciding?

2) Which process/application of Linux is responsible for deciding which device gets which tty device? From /var/log/messages it looks like its the kernel making the decision, but is it configurable?

Thanks in advance...

Simmo
 
Old 03-02-2008, 10:55 AM   #2
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
I would say it is possible. If your system is using say udev and hal then you can create a udev rule to point that specific ID of device to a patrialar device block. I am not sure on how to exactly but there are post on it and also googling for udev rules may help as well.

Brian
 
Old 03-02-2008, 05:57 PM   #3
Simmo512
LQ Newbie
 
Registered: Nov 2007
Posts: 19

Original Poster
Rep: Reputation: 0
Smile

Thanks Brian, I created a udev rule as suggested that created a simple symlink for the USB device. This gave me a unique tty device to work with in my scripts.

Simmo
 
Old 03-03-2008, 03:37 PM   #4
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
Sounds great. You might post what you add and to what file or created a new one so others can get some good help.

Brian
 
Old 03-04-2008, 03:12 AM   #5
Simmo512
LQ Newbie
 
Registered: Nov 2007
Posts: 19

Original Poster
Rep: Reputation: 0
Smile

Workaround.

My issue was, I had two USB devices that I needed to contact via scripts. The problem was, each time the machine boot'd I wasn't sure which device was given to what ttyUSB device and it changed quite often breaking my scripts.

The solution I used was to get udev to look for the device by its vendor and product id. You can view these with the command lsusb. In the example below, 067b would be the idVendor value and 2303 the idProduct value.

[root@simmo ~]# lsusb
Bus 001 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 004 Device 002: ID 067b:2303

I then created a udev rule in /etc/udev/rules.d/99.anything.rules that contained the line below.

BUS=="usb", SYSFS{idVendor}=="067b", SYSFS{idProduct}=="2303", SYMLINK+="gps"

Check that ownership and permissions are the same as the other rules in this directory after you've saved it.

I had to reboot for this rule to be picked up correctly.

What this does is is create a device called /dev/gps which is actually a symbolic link to whichever /dev/ttyUSB device Linux gave the USB GPS device on boot. This allows me to use /dev/gps in my scripts and means I don't have to worry about working out which ttyUSB device each USB device uses.

This can of course be used for multiple devices by creating more udev rules.

Hope this helps others ....
 
Old 03-08-2008, 08:54 AM   #6
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
Thanks for posting an very informative answer.

Brian
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
USB drive not working properly, read only device? (USB key storage device) Arodef Linux - Hardware 14 01-01-2010 07:32 AM
Need Help Moving Files From Hard Drive to USB Device Nobody404 Linux - Newbie 20 09-17-2007 07:39 PM
How to copy file from usb device to hard drive?????? Overcool Linux - Newbie 1 01-04-2007 07:06 PM
How to force kernel to use a USB 2.0-compatible device (ehci_hcd) as a USB 1.1 device eze Linux - Hardware 0 05-16-2006 05:24 AM
ttyUSB iomari SUSE / openSUSE 3 11-04-2005 02:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 03:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration