Hi, I am feeding data from an external modem using a serial-usb convertor dongle (I am a newbie when it comes to reading USB devices by the way). I have written a c program to read the bytes on /dev/ttyUSB0 and this works fine. However, if another usb device was plugged into the computer before my device then presumably I would need to read ttyUSB1 instead. So how do interrogate the operating system to find out which /dev/ttyUSB.. is currently in use and thus communicate to my program which usb device my program should read from? I'm sure this is a pretty basic question so I have done searches and looked at the faqs etc but have not been able to find what I am looking for. So any help appreciated. Regards, Mary
reading the usb
Started by ●December 12, 2006
Reply by ●December 12, 20062006-12-12
Mary Walker wrote:> So how do > interrogate the operating system to find out which /dev/ttyUSB.. is > currently in use and thus communicate to my program which usb device my > program should read from?Depends on the OS -- what OS is it? You probably won't be able to find out whether the device is connected just by looking at /dev/ttyUSB*. You might be able to get stats on what USB devices are connected and figure out what ttys they're bound to, but this is bound to be complicated. You could maybe just send out an are-you-there and see if you get anything back .. --mpa
Reply by ●December 13, 20062006-12-13
"Data" <tvlr909@gmail.com> wrote in message news:1165970300.275071.109310@l12g2000cwl.googlegroups.com...> > Mary Walker wrote: > >> So how do >> interrogate the operating system to find out which /dev/ttyUSB.. is >> currently in use and thus communicate to my program which usb device my >> program should read from? > > Depends on the OS -- what OS is it? > > You probably won't be able to find out whether the device is connected > just by looking at /dev/ttyUSB*. You might be able to get stats on what > USB devices are connected and figure out what ttys they're bound to, > but this is bound to be complicated. > > You could maybe just send out an are-you-there and see if you get > anything back .. >Hi, The operating sytem is Linux.> --mpa >
Reply by ●December 13, 20062006-12-13
I would poke around /proc. That is where linux puts status type information. I don't have my Linux box close, or I could tell you where in /proc to look. eepoke
Reply by ●December 13, 20062006-12-13
On 2006-12-12, Mary Walker <mary@walker.com> wrote:> I am feeding data from an external modem using a serial-usb > convertor dongle (I am a newbie when it comes to reading USB > devices by the way). I have written a c program to read the > bytes on /dev/ttyUSB0 and this works fine. However, if > another usb device was plugged into the computer before my > device then presumably I would need to read ttyUSB1 instead. > So how do interrogate the operating system to find out which > /dev/ttyUSB.. is currently in use and thus communicate to my > program which usb device my program should read from?What I do is set up udev rules to name the USB devices consistently regardless of the order they're plugged in. http://www.reactivated.net/writing_udev_rules.html http://www.debianadmin.com/rename-network-interface-using-udev-in-linux.html http://www.debian-administration.org/articles/126 http://www.linuxjournal.com/article/7316 -- Grant Edwards grante Yow! Dizzy, are we at "REAL PEOPLE" or "AMAZING visi.com ANIMALS"?
Reply by ●December 13, 20062006-12-13
On 2006-12-13, eepoke@gmail.com <eepoke@gmail.com> wrote:> I would poke around /proc. That is where linux puts status type > information. I don't have my Linux box close, or I could tell you > where in /proc to look./proc/bus/usb/devices -- Grant Edwards grante Yow! I just put lots of at the EGG SALAD in the SILK visi.com SOCKS --
Reply by ●December 13, 20062006-12-13
Grant Edwards wrote:> On 2006-12-12, Mary Walker <mary@walker.com> wrote: > > > I am feeding data from an external modem using a serial-usb > > convertor ... > > So how do interrogate the operating system to find out which > > /dev/ttyUSB.. is currently in use and thus communicate to my > > program which usb device my program should read from? > > What I do is set up udev rules to name the USB devices > consistently regardless of the order they're plugged in.Yep, that would seem to be the "right" answer to the OP's problem.> > http://www.reactivated.net/writing_udev_rules.html > http://www.debianadmin.com/rename-network-interface-using-udev-in-linux.html > http://www.debian-administration.org/articles/126 > http://www.linuxjournal.com/article/7316 > > -- > Grant Edwards grante Yow! Dizzy, are we > at "REAL PEOPLE" or "AMAZING > visi.com ANIMALS"?
Reply by ●December 14, 20062006-12-14
"Mary Walker" <mary@walker.com> wrote in message news:457eef95$1_4@mk-nntp-2.news.uk.tiscali.com...> Hi, > > I am feeding data from an external modem using a serial-usb convertor > dongle (I am a newbie when it comes to reading USB devices by the way). I > have written a c program to read the bytes on /dev/ttyUSB0 and this works > fine.mary, you seem to be further than i in this kind of job could you (or anyone else, for that matter) give me some pointers as to the the beginning? does one do an fopen on the right /dev entry, then freadc or the like? I did search google but only got a bewildering multitude of non-useful results. sincere apologies if I'm considered too lazy or off topic... karel
Reply by ●December 14, 20062006-12-14
On 2006-12-14, karel <adelcoGENE@zeverSKYNET.BE> wrote:> > "Mary Walker" <mary@walker.com> wrote in message > news:457eef95$1_4@mk-nntp-2.news.uk.tiscali.com... >> Hi, >> >> I am feeding data from an external modem using a serial-usb convertor >> dongle (I am a newbie when it comes to reading USB devices by the way). I >> have written a c program to read the bytes on /dev/ttyUSB0 and this works >> fine. > > you seem to be further than i in this kind of job could you > (or anyone else, for that matter) give me some pointers as to > the the beginning? does one do an fopen on the right /dev > entry, then freadc or the like?Some pointers: 1) Do not read, look at, use code from, or even think about the "Serial Programming HOWTO" at tldp.org. It's incomplete, incorrect, and unmaintained. 2) Read the Posix Serial Programming Guide at http://www.easysw.com/~mike/serial/ 3) man termios -- Grant Edwards grante Yow! I think I'll make at SCRAMBLED EGGS!! They're visi.com each in LITTLE SHELLS...
Reply by ●December 14, 20062006-12-14
"Grant Edwards" <grante@visi.com> wrote in message news:12o30mc4s4vle16@corp.supernews.com...> On 2006-12-14, karel <adelcoGENE@zeverSKYNET.BE> wrote: >> >> "Mary Walker" <mary@walker.com> wrote in message >> news:457eef95$1_4@mk-nntp-2.news.uk.tiscali.com... >>> Hi, >>> >>> I am feeding data from an external modem using a serial-usb convertor >>> dongle (I am a newbie when it comes to reading USB devices by the way). >>> I >>> have written a c program to read the bytes on /dev/ttyUSB0 and this >>> works >>> fine. >> >> you seem to be further than i in this kind of job could you >> (or anyone else, for that matter) give me some pointers as to >> the the beginning? does one do an fopen on the right /dev >> entry, then freadc or the like? > > Some pointers: > > 1) Do not read, look at, use code from, or even think about > the "Serial Programming HOWTO" at tldp.org. It's > incomplete, incorrect, and unmaintained. > > 2) Read the Posix Serial Programming Guide at > http://www.easysw.com/~mike/serial/ > > 3) man termiosthank you sir, that's a most useable reply! (though i had hoped for an example, or a link to one...) KA