[Python] Access com port in WSL2 using python possible? [closed]

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to access a physical RS-422 serial port (D-Sub 9) from WSL2 on Windows 11 Pro Version 23H2 (Build 22631.5189) using Python. This is not a USB serial device — it is a real COM port. The industrial PC has four dedicated physical COM ports.

    What I see:

    • The device works fine when connecting from native Windows using COM1.
    • In WSL2, /dev/ttyS0 through /dev/ttyS3 are visible.
    • I tried connecting via all of them, but none of them work.
    • I have checked the Windows registry for the serial device map and it looks fine.
    • I know about usbipd for USB devices

    Ideally, I want to run a Python script in a Docker container (inside WSL2) that connects to the device via serial communication.

    Is it possible to connect to a physical COM port in WSL2 using Python?

    If so, how can I correctly map or access it?

    Continue reading...

Compartilhe esta Página