<legend id='polr8'><style id='polr8'><dir id='polr8'><q id='polr8'></q></dir></style></legend>

      <i id='polr8'><tr id='polr8'><dt id='polr8'><q id='polr8'><span id='polr8'><b id='polr8'><form id='polr8'><ins id='polr8'></ins><ul id='polr8'></ul><sub id='polr8'></sub></form><legend id='polr8'></legend><bdo id='polr8'><pre id='polr8'><center id='polr8'></center></pre></bdo></b><th id='polr8'></th></span></q></dt></tr></i><div id='polr8'><tfoot id='polr8'></tfoot><dl id='polr8'><fieldset id='polr8'></fieldset></dl></div>
      <tfoot id='polr8'></tfoot>

        <small id='polr8'></small><noframes id='polr8'>

          <bdo id='polr8'></bdo><ul id='polr8'></ul>

        python:如何检测串行 COM 上的设备名称/ID

        时间:2023-07-23

            <small id='8KWPg'></small><noframes id='8KWPg'>

                <legend id='8KWPg'><style id='8KWPg'><dir id='8KWPg'><q id='8KWPg'></q></dir></style></legend>
                  <tbody id='8KWPg'></tbody>

                <tfoot id='8KWPg'></tfoot>
              1. <i id='8KWPg'><tr id='8KWPg'><dt id='8KWPg'><q id='8KWPg'><span id='8KWPg'><b id='8KWPg'><form id='8KWPg'><ins id='8KWPg'></ins><ul id='8KWPg'></ul><sub id='8KWPg'></sub></form><legend id='8KWPg'></legend><bdo id='8KWPg'><pre id='8KWPg'><center id='8KWPg'></center></pre></bdo></b><th id='8KWPg'></th></span></q></dt></tr></i><div id='8KWPg'><tfoot id='8KWPg'></tfoot><dl id='8KWPg'><fieldset id='8KWPg'></fieldset></dl></div>
                  <bdo id='8KWPg'></bdo><ul id='8KWPg'></ul>
                  本文介绍了python:如何检测串行 COM 上的设备名称/ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想了解如何在 python 中执行此操作:

                  I would like some indication on how to do this in python:

                  • 识别串口中指定名称的端口(DeviceVCP0和DeviceVCP1这些是通过在regedit窗口中浏览获得的)

                  • Identify the port named a specific name in the serial com (DeviceVCP0 and DeviceVCP1 these are get by browsing in regedit window)

                  并获取插入设备的id

                  我已经可以使用扫描活动串行端口 COM 的 pySerial 代码识别可用的 COM

                  I can already identify the avalable COM with this pySerial code that scan up the active serial port COM

                  import serial
                  
                  def scan():
                      """scan for available ports. return a list of tuples (num, name)"""
                      available = []
                      for i in range(256):
                          try:
                              s = serial.Serial(i)
                              available.append( (i, s.portstr))
                              s.close()   # explicit close 'cause of delayed GC in java
                          except serial.SerialException:
                              pass
                      return available
                  
                  if __name__=='__main__':
                      print "Found ports:"
                      for n,s in scan():
                          print "(%d) %s" % (n,s)
                  

                  提前致谢

                  推荐答案

                  我不确定你使用的是什么操作系统,但这是在 Win7-x64 中的

                  I am not sure what operating system you are using, but this is in Win7-x64

                  import win32com.client
                  wmi = win32com.client.GetObject("winmgmts:")
                  for serial in wmi.InstancesOf("Win32_SerialPort"):
                         print (serial.Name, serial.Description)
                  

                  使用此信息,您可以解析它并获取 COM 编号.您可以在此处获取 Serial 实例的其他属性:http://msdn.microsoft.com/en-us/library/aa394413(v=vs.85).aspx

                  Using this information, you can parse it and get the COM numbers. You can get other attributes of the Serial instances here: http://msdn.microsoft.com/en-us/library/aa394413(v=vs.85).aspx

                  这篇关于python:如何检测串行 COM 上的设备名称/ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:pySerial write() 在 Python 解释器中工作正常,但不是 Python 脚本 下一篇:从 Raspberry pi 发送串行通信

                  相关文章

                  <tfoot id='j42Kn'></tfoot>

                  • <bdo id='j42Kn'></bdo><ul id='j42Kn'></ul>
                  <i id='j42Kn'><tr id='j42Kn'><dt id='j42Kn'><q id='j42Kn'><span id='j42Kn'><b id='j42Kn'><form id='j42Kn'><ins id='j42Kn'></ins><ul id='j42Kn'></ul><sub id='j42Kn'></sub></form><legend id='j42Kn'></legend><bdo id='j42Kn'><pre id='j42Kn'><center id='j42Kn'></center></pre></bdo></b><th id='j42Kn'></th></span></q></dt></tr></i><div id='j42Kn'><tfoot id='j42Kn'></tfoot><dl id='j42Kn'><fieldset id='j42Kn'></fieldset></dl></div>

                      <legend id='j42Kn'><style id='j42Kn'><dir id='j42Kn'><q id='j42Kn'></q></dir></style></legend>

                      <small id='j42Kn'></small><noframes id='j42Kn'>