Simulate a USB device for automation

I need to simulate a USB device for automation and testing (on Linux). The source driver / application for this device uses "libusb" to communicate with it.

I don't have much experience with Linux and Simulation, after some searching, I realized that I needed to write a kernel level driver and an application in user space to simulate this device. It is right? If so, how can this be done?

Thanks at Advance.

+6
source share
3 answers

Finally, he implemented it by modifying "libusb", modifying it to send and receive usb translations from the message queue instead of usbfs. I programmed my simulator to create libsub types and send and receive them using message queues.

Now Simulator interprets incoming transmissions and sends them to the command parser, which sends a request / message to the automation system using sockets in a specific format. The automation system sends it as an instruction, sending it to the parser of commands using a socket. This socket invokes a method specific to each request in the simulator. Now the simulator forms the appropriate transfer structure and moves to the device plugin (via libusb) through the message queue.

+2
source

I think what you are looking for will be called a virtual USB device. There is currently nothing in the standard Kernel. A virtual machine has a USB emulator. KVM provides USB emulation. There is a gadget framework where you can find a solution. Or find something in the Linux USB project

Thanks Abhijeet

0
source

The usb-vhci project can be useful if you want the device to be presented in the kernel as well as real equipment.

0
source

Source: https://habr.com/ru/post/917310/


All Articles