EmbeddedRelated.com
Forums
Memfault Beyond the Launch

reading the usb

Started by Mary Walker December 12, 2006
On 2006-12-14, karel <adelcoGENE@zeverSKYNET.BE> wrote:

>> 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 > > thank you sir, that's a most useable reply! > (though i had hoped for an example, or a link to one...)
The Posix Serial Programming Guide has tons of examples. -- Grant Edwards grante Yow! The SAME WAVE keeps at coming in and COLLAPSING visi.com like a rayon MUU-MUU...
"Grant Edwards" <grante@visi.com> wrote in message 
news:12o33347t1ual8b@corp.supernews.com...
> On 2006-12-14, karel <adelcoGENE@zeverSKYNET.BE> wrote: > > The Posix Serial Programming Guide has tons of examples.
it has indeed, and a nice website it makes! but the word USB does not once figure in it, or i should have overlooked it it's all about rs-232 as far as i can see. maybe my question should have been: "i might be able to figure this out for rs-232 but are there any differences for USB serial apart from the device to open?"
On 2006-12-14, karel <adelcoGENE@zeverSKYNET.BE> wrote:

>> The Posix Serial Programming Guide has tons of examples. > > it has indeed, and a nice website it makes! but the word USB > does not once figure in it, or i should have overlooked it > it's all about rs-232 as far as i can see.
I thought you were using a USB<->RS-232 serial widget.
> maybe my question should have been: > > "i might be able to figure this out for rs-232
RS-232 is the standard which defines the 25-pin D connectors and electrical signalling levels at those connectors. It's got nothing to do with the UART or how that UART is attached to the CPU.
> but are there any differences for USB serial apart from the > device to open?"
No, there are no differences in the serial port API between ISA-attached serial ports and USB-attached (or Ethernet-attached, for that matter) serial ports. That's what device drivers are for, you know. ;) There are going to be differences in timing. For example: when you make the call to set RTS, that happens immediately for ISA-bus and PCI-bus attached devices (by "immediately" I mean that you know that when the ioctl() system call returns, you know the operation has been completed and the RTS line is in the requested state). It doesn't happen immediately for USB. The ioctl() call may just queue up a request to set RTS. The ioctl() call can return before the USB host controller has sent the request. -- Grant Edwards grante Yow! The Osmonds! You are at all Osmonds!! Throwing up visi.com on a freeway at dawn!!!
On 2006-12-14, Grant Edwards <grante@visi.com> wrote:
> On 2006-12-14, karel <adelcoGENE@zeverSKYNET.BE> wrote: > >>> The Posix Serial Programming Guide has tons of examples. >> >> it has indeed, and a nice website it makes! but the word USB >> does not once figure in it, or i should have overlooked it >> it's all about rs-232 as far as i can see. > > I thought you were using a USB<->RS-232 serial widget. > >> maybe my question should have been: >> >> "i might be able to figure this out for rs-232 > > RS-232 is the standard which defines the 25-pin D connectors > and electrical signalling levels at those connectors. It's got > nothing to do with the UART or how that UART is attached to the > CPU. > >> but are there any differences for USB serial apart from the >> device to open?" > > No, there are no differences in the serial port API between > ISA-attached serial ports and USB-attached (or > Ethernet-attached, for that matter) serial ports. That's what > device drivers are for, you know. ;)
Oh, unless you're a glutton for punishment, I wouldn't actually recommend using C at all for host-side serial apps. I use Python <www.python.org> and the pyserial module <http://pyserial.sourceforge.net/> for 99% of my serial stuff. Apart from taking a fraction of the time to develop when compared to C, the resulting program will work under Linux/Unix, Windows, MacOS, and Java VM. -- Grant Edwards grante Yow! One FISHWICH coming at up!! visi.com
"Grant Edwards" <grante@visi.com> wrote in message 
news:12o0osklfts0h9c@corp.supernews.com...
> 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
yes. also, my linux (suse 8.2) has a utility called lsusb which consults the same information.
"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. 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 am in a similar config and have found that, during the boottime hardware scan, a line is added to /var/log/messages stating the ttyUSB# used. KA
"Grant Edwards" <grante@visi.com> wrote in message 
news:12o385bsq1jmhaf@corp.supernews.com...
> On 2006-12-14, karel <adelcoGENE@zeverSKYNET.BE> wrote: > >>> The Posix Serial Programming Guide has tons of examples. >> >> it has indeed, and a nice website it makes! but the word USB >> does not once figure in it, or i should have overlooked it >> it's all about rs-232 as far as i can see. > > I thought you were using a USB<->RS-232 serial widget.
Well yes, in a way I am, but it seems to me my config is the reverse of what you figured. Actually, I want to read GPS-data from a Hicom receiver that has a 6-pin DIN-connector, like on pre-USB PC keyboards. It sends out a continuous stream of GPS-data at 4800,n,8,1 which I can perfectly receive and decode. But it also has a convertor from the DIN-connector to USB, and is recognized by the Linux box; only I seem unable to read any data from it. NB the reason I should like to read from USB is that serial ports are less and less common on PC's and especially on portables. Thanks for your interest! KA
On 2006-12-15, karel <adelcoGENE@zeverSKYNET.BE> wrote:

>>>> The Posix Serial Programming Guide has tons of examples. >>> >>> it has indeed, and a nice website it makes! but the word USB >>> does not once figure in it, or i should have overlooked it >>> it's all about rs-232 as far as i can see. >> >> I thought you were using a USB<->RS-232 serial widget. > > Well yes, in a way I am, but it seems to me my config is the > reverse of what you figured.
I assumed you have a USB-serial adapter where the USB end plugs into the Linux host and the serial end plugs into some device or other. If that's not what you're talking about, then for pete's sake tell me what you _are_ talking about rather than making us guess.
> Actually, I want to read GPS-data from a Hicom receiver that > has a 6-pin DIN-connector, like on pre-USB PC keyboards. It > sends out a continuous stream of GPS-data at 4800,n,8,1 which > I can perfectly receive and decode. But it also has a > convertor from the DIN-connector to USB, and is recognized by > the Linux box;
That's exactly what I was talking about.
> only I seem unable to read any data from it.
What's it recognized as? I'd be surprised if it's not either a PL2303 or an FTDI USB-serial adapter. From what I've seen 95% of the USB serial converters are one or the other. There are about a 20 other USB-serial adapters supported by Linux, but I've never seen any of them in use.
> NB the reason I should like to read from USB is that serial > ports are less and less common on PC's and especially on > portables.
And I've given you pointers for documentation on exactly how to do it. -- Grant Edwards grante Yow! I know how to get the at hostesses released! Give visi.com them their own television series!

Memfault Beyond the Launch