• <bdo id='5pEom'></bdo><ul id='5pEom'></ul>
  • <tfoot id='5pEom'></tfoot>

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

      <small id='5pEom'></small><noframes id='5pEom'>

        <legend id='5pEom'><style id='5pEom'><dir id='5pEom'><q id='5pEom'></q></dir></style></legend>

        pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取?

        pyserial - possible to write to serial port from thread a, do blocking reads from thread b?(pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取?)
        <i id='Xjsfu'><tr id='Xjsfu'><dt id='Xjsfu'><q id='Xjsfu'><span id='Xjsfu'><b id='Xjsfu'><form id='Xjsfu'><ins id='Xjsfu'></ins><ul id='Xjsfu'></ul><sub id='Xjsfu'></sub></form><legend id='Xjsfu'></legend><bdo id='Xjsfu'><pre id='Xjsfu'><center id='Xjsfu'></center></pre></bdo></b><th id='Xjsfu'></th></span></q></dt></tr></i><div id='Xjsfu'><tfoot id='Xjsfu'></tfoot><dl id='Xjsfu'><fieldset id='Xjsfu'></fieldset></dl></div>

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

                  <tbody id='Xjsfu'></tbody>

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

                  <tfoot id='Xjsfu'></tfoot>
                  本文介绍了pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我尝试用谷歌搜索,找不到答案,在这里搜索,找不到答案.有没有人研究过从线程 a 写入 Serial() 对象(pyserial)并从线程 b 进行阻塞读取是否是线程安全的?

                  I tried googling this, couldn't find an answer, searched here, couldn't find an answer. Has anyone looked into whether it's thread safe to write to a Serial() object (pyserial) from thread a and do blocking reads from thread b?

                  我知道如何使用线程同步原语和线程安全数据结构,事实上我目前的这个程序形式有一个专用于在串行端口上读/写的线程,我使用线程安全数据结构来协调活动在应用程序中.

                  I know how to use thread synchronization primitives and thread-safe data structures, and in fact my current form of this program has a thread dedicated to reading/writing on the serial port and I use thread-safe data structures to coordinate activities in the app.

                  如果我可以从主线程写入串行端口(从不从中读取),并在第二个线程中使用阻塞读取从串行端口读取(并且从不写入),我的应用程序将受益匪浅.如果有人真的想让我解释为什么这会对应用程序有益,我可以添加我的理由.在我看来,只有一个 Serial() 实例,即使线程 B 处于对 Serial 对象的阻塞读取中,线程 A 也可以安全地在 Serial 对象上使用 write 方法.

                  My app would benefit greatly if I could write to the serial port from the main thread (and never read from it), and read from the serial port using blocking reads in the second thread (and never write to it). If someone really wants me to go into why this would benefit the app I can add my reasons. In my mind there would be just one instance of Serial() and even while thread B sits in a blocking read on the Serial object, thread A would be safe to use write methods on the Serial object.

                  有人知道 Serial 类是否可以这样使用吗?

                  Anyone know whether the Serial class can be used this way?

                  在我看来,答案可能取决于平台.如果您对此类平台有任何经验,最好知道您在哪个平台上工作.

                  It occurs to me that the answer may be platform-dependent. If you have any experience with a platform like this, it'd be good to know which platform you were working on.

                  只有一个响应,但如果其他人尝试过这个,请留下您的经验.

                  There's only been one response but if anyone else has tried this, please leave a response with your experience.

                  推荐答案

                  我已经用 pyserial.从一个线程读取并从另一个线程写入通常不会导致问题,因为实际上不存在任何类型的资源仲裁问题.串口是全双工的,所以读和写可以完全独立地同时发生.

                  I have done this with pyserial. Reading from one thread and writing from another should not cause problems in general, since there isn't really any kind of resource arbitration problem. Serial ports are full duplex, so reading and writing can happen completely independently and at the same time.

                  这篇关于pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 画布滚动条?)
                    <tfoot id='PsUnn'></tfoot>

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

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