[TAG] USB test module

Jimmy O'Regan joregan at gmail.com
Wed Jan 14 15:03:54 MSK 2009


2009/1/14 Ben Okopnik <ben at linuxgazette.net>:
> On Tue, Jan 13, 2009 at 11:10:12PM +0100, Ren? Pfeiffer wrote:
>> On Jan 13, 2009 at 1513 -0600, Ben Okopnik appeared and said:
>> > I'm trying to do something rather abstruse and complex with a weird mix
>> > of software, hardware, and crazy hackery (too long to explain and it
>> > would be boring to most people if I did), but - I need a "magic bullet"
>> > and I'm hoping that somebody here can point me in the right direction,
>> > or maybe toss a bit of code at me. Here it goes: I need a module that
>> > would create a serial-USB device (/dev/ttyUSB9 by preference) and let me
>> > pipe data into it without actually plugging in any hardware.
>>
>> Hm, I think I saw something like a USB dummy driver somwhere somewhen.
>> But there is a tutorial for coding USB drivers and even skeleton code.
>>
>> http://tali.admingilde.org/linux-docbook/writing_usb_driver.pdf
>
> [Laugh] Funny thing, I was just exchanging mail with Greg Kroah-Hartman
> yesterday. Nice guy, and very helpful, but I was only able to get just
> so far with his help and no farther. Mostly because the thing that I'm
> trying to do now is something that I figured out based on his help.
>
> Perhaps I should just wait until I can get back home (I'm teaching a
> class in Milwaukee; last night, it was *over a hundred degrees colder*
> here than Florida was when I left!) so I can use my GPS as a data source
> for this, but I'm impatient. Blame the cold weather. :)
>
>> Apart from that I only know about LKML and http://www.linux-usb.org/
>> where most of the developers hang out.
>
> Eeep. I was hoping it wasn't that complicated - some equivalent of
> 'netcat' or whatever... maybe I do need to wait.
>

socat ('netcat++' - http://www.dest-unreach.org/socat/) can redirect
serial ports, but nothing about USB there.

>> > Is this even possible? [...]
>>
>> I think so. Maybe the driver testing tool
>> (http://www.linux-usb.org/usbtest/#devices) has a way of faking devices
>> and creating devices for I/O.
>
> Hmm. I just worked my way through that, and it seems that you have to
> have _some_ hardware at least; none of the modules in
> /lib/modules/2.6.24-16-generic/kernel/drivers/usb/gadget load for me,
> all of them dying with a 'No such device' error.
>

The libusb documentations says: 'Before any communication can occur
with a device, it needs to be found.' (Perl has Device::USB, but it's
a libusb wrapper, so same thing).

>> Does it have to be a serial-USB device?
>
> I'd be willing to try it with a non-serial version, if that's any
> easier.

Well, qemu has some virtual usb devices: it can emulate a USB storage
device using a directory, or a USB mouse or tablet using X's. It tends
to attract a lot of experimental patches, so perhaps there's a virtual
serial device floating on the net somewhere.




More information about the TAG mailing list