Gaurav Agrawal
Gaurav Agrawal

Reputation: 101

Simulate a USB Device for Automation

I have to simulate a USB Device for automation and testing purposes (in Linux). Original driver/application for this device uses “libusb” to communicate with it.

I don’t have much experience in Linux and Simulation, after some searching I have understood that I need to write a kernel level driver and an application in user-space to simulate that device. Is this right? If Yes, How can this be done?

Thanks in Advance.

Upvotes: 6

Views: 7142

Answers (3)

Tyler Hall
Tyler Hall

Reputation: 149

The usb-vhci project could be of use if you want the device to be presented to the kernel in the same way as real hardware.

Upvotes: 0

Gaurav Agrawal
Gaurav Agrawal

Reputation: 101

Finally implemented it by modifying "libusb", modified it to send and receive usb transfers from message queue instead of usbfs. Programmed my simulator to create libsub type transfers and send/receive them using message queues as well.

Simulator now interprets the incoming transfers and sends it to a command parser, which sends request/message to automation system using sockets in a specific format. Automation system sends it's instruction by sending to command parser using socket. This socket invokes method specific to each request in simulator, Now simulator forms an appropriate transfer structure and passes to device plugin (via libusb) through message queue.

Upvotes: 3

Abhijeet Kasurde
Abhijeet Kasurde

Reputation: 4127

I think what you're looking for would be called a virtual USB device. Currently there is nothing in standard Kernel.Some virtual machine provides USB emulation.e.g. KVM provides USB emulation. There is framework gadget in which might look for your solution. Or find something in Linux USB project

Thanks, Abhijeet

Upvotes: 0

Related Questions