从 VSCode (Debian Linux) 的开发容器内部,我想使用 COM 端口通过连接到 Windows 主机的 USB 设备(通过 WSL2)进行通信。如何使 COM 端口在容器内可用?
编辑:
对于 WSL2,有 no official support yet .
As of right now WSL 2 does not include serial support, or USB device support.
最佳答案
2021 年 7 月:截至目前,WSL 2 不包括串行支持或 USB 设备支持。
2021 年 11 月更新:相同的常见问题解答指出:
You can now connect USB devices in Windows Subsystem for Linux under Windows 11
If you’re an active user of Windows Subsystem for Linux and want to access USB devices right from the Linux instance running under WSL, then you’ll be happy to know that there has been a significant progress in this front.
Thanks to Microsoft’s contributions to the open-source dorssel/usbipd-win project, you can now enjoy USB passthrough access in WSL.
It means end users can perform tasks like flashing Android devices under Windows Subsystem for Linux, which are otherwise not supported by the Linux subsystem.The usbipd-win project is all about creating a solution for sharing locally connected USB devices to other machines, including Hyper-V guests and WSL2. However, the official WSL2 Linux kernel used to lack support for the USB/IP protocol, requiring users to build the kernel themselves.
Since WSL kernel version 5.10.60.1, the required parameters are configured out of the box, so no manual recompilation is needed.
Microsoft has also contributed a command line interface to the project to both enable a USB device for sharing on Windows and seamlessly attach it from within WSL.
所以如果你有:
- 已迁移/升级至 Windows 11
- 应用了所有 WSL 更新(通过 Windows Store)
然后,您的 VSCode 应该能够通过 WSL 访问已安装的 USB 驱动器。
关于docker - 如何在 VSCode 开发容器内使用 USB/COM 端口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68527888/