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

    • <bdo id='rHlua'></bdo><ul id='rHlua'></ul>

    1. <legend id='rHlua'><style id='rHlua'><dir id='rHlua'><q id='rHlua'></q></dir></style></legend>
      1. Python 自动选择串口(适用于 Arduino)

        Python to automatically select serial ports (for Arduino)(Python 自动选择串口(适用于 Arduino))
          <tbody id='lL3Nl'></tbody>

          <legend id='lL3Nl'><style id='lL3Nl'><dir id='lL3Nl'><q id='lL3Nl'></q></dir></style></legend>
          • <bdo id='lL3Nl'></bdo><ul id='lL3Nl'></ul>

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

              1. <tfoot id='lL3Nl'></tfoot>
                • <i id='lL3Nl'><tr id='lL3Nl'><dt id='lL3Nl'><q id='lL3Nl'><span id='lL3Nl'><b id='lL3Nl'><form id='lL3Nl'><ins id='lL3Nl'></ins><ul id='lL3Nl'></ul><sub id='lL3Nl'></sub></form><legend id='lL3Nl'></legend><bdo id='lL3Nl'><pre id='lL3Nl'><center id='lL3Nl'></center></pre></bdo></b><th id='lL3Nl'></th></span></q></dt></tr></i><div id='lL3Nl'><tfoot id='lL3Nl'></tfoot><dl id='lL3Nl'><fieldset id='lL3Nl'></fieldset></dl></div>
                • 本文介绍了Python 自动选择串口(适用于 Arduino)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  目前,python 程序必须知道设备 (Arduino) 在哪个端口上,然后 Python 才能与设备通信.

                  Currently the python program must know which port a device (Arduino) is on before Python can communicate the device.

                  问题:每当设备被拔出和重新插入时,它的 COM 端口都会改变,因此必须再次将正确的串行端口提供给 Python 才能找到设备.

                  Problem: Whenever the device is plugged out and back in, its COM port changes, so the correct serial port must be given to Python again for it to find the device.

                  Python(使用pySerial)如何自动搜索要使用的正确串口?python是否可以正确地将串口上的设备识别为Arduino?

                  How can Python (using pySerial) automatically search for the correct serial port to use? Is it possible for python to correctly identify the device on a serial port as an Arduino?

                  推荐答案

                  使用以下代码查看所有可用的串口:

                  Use the following code to see all the available serial ports:

                  import serial.tools.list_ports
                  ports = list(serial.tools.list_ports.comports())
                  for p in ports:
                      print p
                  

                  这给了我以下信息:

                  ('COM4', 'Arduino Due Programming Port (COM4)', 'USB VID:PID=2341:003D SNR=75330303035351300230')
                  ('COM11', 'RS-232 Port (COM11)', 'FTDIBUS\VID_0856+PID_AC27+BBOPYNPPA\0000')
                  

                  要确定它是否是 Arduino,您可以执行以下操作:

                  To work out if it's an Arduino you could do something like:

                      if "Arduino" in p.description:
                          print "This is an Arduino!"
                  

                  这篇关于Python 自动选择串口(适用于 Arduino)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pythonic and efficient way of finding adjacent cells in grid(在网格中查找相邻单元格的 Pythonic 和有效方法)
                  map a hexagonal grid in matplotlib(在 matplotlib 中映射六边形网格)
                  Execute arbitrary python code remotely - can it be done?(远程执行任意 python 代码 - 可以吗?)
                  Python - Plotting colored grid based on values(Python - 根据值绘制彩色网格)
                  Is there a GUI design app for the Tkinter / grid geometry?(是否有 Tkinter/网格几何图形的 GUI 设计应用程序?)
                  tkinter Canvas Scrollbar with Grid?(带有网格的 tkinter 画布滚动条?)
                    • <bdo id='CZMT3'></bdo><ul id='CZMT3'></ul>
                    • <i id='CZMT3'><tr id='CZMT3'><dt id='CZMT3'><q id='CZMT3'><span id='CZMT3'><b id='CZMT3'><form id='CZMT3'><ins id='CZMT3'></ins><ul id='CZMT3'></ul><sub id='CZMT3'></sub></form><legend id='CZMT3'></legend><bdo id='CZMT3'><pre id='CZMT3'><center id='CZMT3'></center></pre></bdo></b><th id='CZMT3'></th></span></q></dt></tr></i><div id='CZMT3'><tfoot id='CZMT3'></tfoot><dl id='CZMT3'><fieldset id='CZMT3'></fieldset></dl></div>

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

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

                          <tfoot id='CZMT3'></tfoot>

                              <tbody id='CZMT3'></tbody>