Python Pyserial Windows找不到端口 [英] Python Pyserial Windows No Port Found

查看:391
本文介绍了Python Pyserial Windows找不到端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚尝试使用AT命令连接到USB移动设备以通过它发送短信.但是,当我在Windows操作系统中使用pyserial连接到它时,出现错误无法打开端口,找不到指定的文件.

I have just tried to connect to usb mobile to send sms through it using AT commands. But when i use pyserial to connect to it in a windows os, i get error could not open port, the file specified cannot be found.

>>> import serial
>>> ser = serial.Serial(0)  # open first serial port
>>> print ser.name          # check which port was really used
>>> ser.write("hello")      # write a string
>>> ser.close()  

即使我将0替换为其他任何值(例如0 -10或'com0','com1'等),我仍然会得到未找到指定的错误文件,无法打开端口.

even if i replace the 0 with any other value, like 0 -10 or 'com0','com1' etc, i still get error file specified not found, port cannot be open.

pyserial文档中列出了一个命令,该命令列出了端口或允许您打开端口

There is a command listed in pyserial documentation which lists ports or allows you to open a port

python -m serial.tools.miniterm

python -m serial.tools.miniterm

该命令应该列出所有串行端口.但它什么也没显示.

This command is supposed to list all serial ports. But it shows none.

我的系统上有3个USB端口.是什么导致此问题.

I have 3 usb ports on my system. What is causing this issue.

推荐答案

我自己找到了解决方案.它非常简单,并且在问题中使用相同的代码..我被阻止了错误,因为我的设备管理器中没有调制解调器(诺基亚电话).尽管我已将手机插入USB,但没有安装诺基亚PC套件.安装诺基亚PC套件并连接诺基亚电话后,在设备管理器->调制解调器中,您的电话将出现.只需检查其属性->调制解调器,您会发现com5或任何数字.然后使用该ID进行连接.如果您不知道这一点,请进行迭代,直到找到合适的对象为止.

I found the solution myself. Its pretty simple and uses the same code in the question.. I was getting blocked error because there was no modem(nokia phone) in my device manager. although i had plugged in my phone into the usb, there was no nokia pc suite installed. Once you install nokia pc suite and connect your nokia phone, in device manager -> modems your phone will appear. Just check its properties->modem and you will find the com5 or whichever number. Then use that id to connect. If you dont know this, just iterate till you find the right one.

感谢所有尝试提供帮助的人

Thanks everyone who tried to help

这篇关于Python Pyserial Windows找不到端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆