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

        <legend id='HTmJv'><style id='HTmJv'><dir id='HTmJv'><q id='HTmJv'></q></dir></style></legend>
        <i id='HTmJv'><tr id='HTmJv'><dt id='HTmJv'><q id='HTmJv'><span id='HTmJv'><b id='HTmJv'><form id='HTmJv'><ins id='HTmJv'></ins><ul id='HTmJv'></ul><sub id='HTmJv'></sub></form><legend id='HTmJv'></legend><bdo id='HTmJv'><pre id='HTmJv'><center id='HTmJv'></center></pre></bdo></b><th id='HTmJv'></th></span></q></dt></tr></i><div id='HTmJv'><tfoot id='HTmJv'></tfoot><dl id='HTmJv'><fieldset id='HTmJv'></fieldset></dl></div>
      1. <tfoot id='HTmJv'></tfoot>
          <bdo id='HTmJv'></bdo><ul id='HTmJv'></ul>
      2. PySerial App 在 shell 中运行,不是 py 脚本

        时间:2023-07-23

          <tbody id='LVoLa'></tbody>

      3. <small id='LVoLa'></small><noframes id='LVoLa'>

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

                <tfoot id='LVoLa'></tfoot>

                  本文介绍了PySerial App 在 shell 中运行,不是 py 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I have a very simple python script that uses pySerial to send data over the serial port to my Arduino. When I execute this line-by-line in the python shell, it works just fine, but when I put it in a ".py" file, and try to run it, nothing happens. Though the serial lights on my UART do flash. So something is getting through, but it's garbage (I checked).

                  Here is the simple code.

                  import serial
                  
                  ser = serial.Serial('COM3',9600,timeout=.2)
                  ser.write('A')
                  ser.close()
                  

                  I've already tried adding sleeps, but nothing seems to be fixing it. Any ideas?

                  解决方案

                  OK, I've figured it out!

                  It's necessary to use code like this before performing the write:

                  time.sleep(1)
                  ser.setDTR(level=0)
                  time.sleep(1)
                  

                  Otherwise, the arduino automatically resets upon receiving a serial connection for some reason. yay!

                  这篇关于PySerial App 在 shell 中运行,不是 py 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python 自动选择串口(适用于 Arduino) 下一篇:行缓冲串行输入

                  相关文章

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

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