How to emulate USB devices?

匆匆过客 提交于 2019-11-27 11:20:48

Edit: Proof of concept here

I strongly recommend this project, USB IP. It is a way of connecting USB devices over the network. There is a Windows client.

What this means is, you install the client on your Windows computer. This device then expects to talk to a USB device connected to a Linux computer, the server:

What you now do, is either create a fake device driver for Linux, that looks like is connected to a physical USB device, but in reality is just logic pretending to be your USB device. There are tutorials for writing USB drivers for Linux. Or you create your own stub driver for the Device Control Manager (see picture above). This stub driver could run on Windows or Linux, it wouldn't matter. It could even run on the same Windows machine which is the USB client.

The DSF USB Loopback Device mentioned in the question itself, would be the same kind of solution as a stub driver for the Device Control Manager, but taking Linux out of the picture altogether.

You can write virtual USB device using QEMU. You can duplicate already existing device, like the dev-serial.c found in this QEMU repository and change it for your needs.
After you write and compile your USB device you can simply attach it to your VM using the QEMU command line interface.

If you want to emulate keyboard or mouse you don't need to proof of concept or virtual usb device
You can just install pyautogui to python
For python 2:

pip install pyautogui

For python 3:

pip3 install pyautogui

And use it like this:

import pyautogui
pyautogui.typewrite("hello from pyautogui")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!