docker - 如何在 VSCode 开发容器内使用 USB/COM 端口?

标签 docker visual-studio-code serial-port

从 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.

对应feature request is tracked on GitHub .

最佳答案

2021 年 7 月:截至目前,WSL 2 不包括串行支持或 USB 设备支持。

2021 年 11 月更新:相同的常见问题解答指出:

Skanda Hazarika报告:

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.

所以如果你有:

然后,您的 VSCode 应该能够通过 WSL 访问已安装的 USB 驱动器。

关于docker - 如何在 VSCode 开发容器内使用 USB/COM 端口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68527888/

相关文章:

google-chrome-devtools - 如何配置 Visual Studio Code 调试器以使用 Chrome Canary?

python - VS Code Python 调试。如何从错误中继续。更改后从行重复

linux -/dev/ttyACM0 Postfix 管道时文件不存在

docker - 卷 - 设备映射如何在 Docker 上工作

docker容器中的python jupyter笔记本连接到selenium/standalone-chrome

docker - 关于Domjudge服务器的Docker-compose设置问题

docker - 无法在Ubuntu 16.04中安装Docker

visual-studio-code - VS Code 中的文件路径自动完成

c# - SerialPort.ReadLine() 返回垃圾

winapi - 通过ReadFile从串口读取非常慢