Writing to a USB Device

Karl Larsen k5di at zianet.com
Sat Jun 14 23:41:41 UTC 2008


John wrote:
> Karl Larsen wrote:
>   
>> John wrote:
>>     
>>> Hi,
>>>
>>> I'm gathering the courage to write a program which controls an 
>>> external device via a USB port. The development and target operating 
>>> systems are Ubuntu 8.
>>>
>>> Are there any good books or web sites which would give me an idea of 
>>> what is involved?
>>>
>>> TIA
>>>
>>> J
>>>
>>> (Although couched as a general question, the external device is a 
>>> Lenz LVZ100 Model Railway controller!)
>>>
>>>
>>>   
>>>       
>>    Well it should be a short book. To see what device your USB device 
>> is plugged into use $dmesg | tail and you see this:
>>
>> [ 1356.357939] usb 1-2: new full speed USB device using ohci_hcd and 
>> address 2
>> [ 1356.570089] usb 1-2: configuration #1 chosen from 1 choice
>> [ 1356.783916] Linux video capture interface: v2.00
>> [ 1356.815570] 
>> /build/buildd/linux-ubuntu-modules-2.6.24-2.6.24/debian/build/build-generic/media/gspcav1/gspca_core.c: 
>> USB GSPCA camera found.(SPCA561A)
>> [ 1356.828914] usbcore: registered new interface driver gspca
>> [ 1356.829686] 
>> /build/buildd/linux-ubuntu-modules-2.6.24-2.6.24/debian/build/build-generic/media/gspcav1/gspca_core.c: 
>> gspca driver 01.00.20 registered
>> [  864.631564] process `skype' is using obsolete setsockopt SO_BSDCOMPAT
>>
>> This tells you all about it.
>>
>> Not sure what other things you can learn :-)
>>
>> Karl
>>
>>
>>     
> Thanks, Karl, but I feel you've missed the point, or maybe I have.
>
> I want to write an application (gcc or g++) which reads and writes 
> packets of information to the USB device.
>
> I'm guessing that I need to locate the device in a list of connected USB 
> devices so that I can get an identifier for it (possibly something like 
> /dev/usb1 or /dev/usb2 ... do you get the drift - is my target usb1 or 
> 2?). I then need to open a communication channel to and from the device 
> and exchange data packets somehow.
>
> Am I on the right or wrong lines here and where can I find some good 
> information / learning material?
>
> J
>
>   
    Hi John, I know it depends on what the USB device is. I have an 
older hard drive in a cheap ($15) plastic holder that has a cable with a 
USB plug. When I plug that in I use df to tell me what the proper 
address is to reach it. The one I have gives this to df:

/dev/sdf1             29565268  10706048  17357352  39% /media/disk
which is a help. In Hardy it also opens a device that shows me what is 
in the hard drive :-)

So I think this is enough to do what I need....


Karl


-- 

	Karl F. Larsen, AKA K5DI
	Linux User
	#450462   http://counter.li.org.
   PGP 4208 4D6E 595F 22B9 FF1C  ECB6 4A3C 2C54 FE23 53A7





More information about the ubuntu-users mailing list