How can I fix “[Error 6] The handle is invalid.” with PySerial

前端 未结 5 2015
一个人的身影
一个人的身影 2020-12-11 04:25

I\'m trying to connect to my phone from my Windows 7 PC using PySerial with the following code:

import wmi
import serial

c = wmi.WMI()
modem = c.query(\"SEL         


        
5条回答
  •  春和景丽
    2020-12-11 05:13

    This happened to me too and it was actually due to the serial port being closed when I tried to access it. This is because I was using a 'with' structure which makes sure to close the port afterwards and a bad code refactoring lead to this issue.

提交回复
热议问题