pySerial Windows写入问题 [英] pySerial Windows write problem

查看:132
本文介绍了pySerial Windows写入问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一些设备以57600波特RS232进行通信。从PC到USB到菲利普斯USB集线器的路径,然后是TUSB3410 USB /串口转换器。 3410芯片的驱动程序产生正常状态。通讯端口(如

COM3)。有一个C ++程序没有问题与设备交谈,

但两个Python程序有问题。一个是一个大而可怕的控制器

程序,另一个,因为那是我遇到的麻烦,是一个

while()循环。


while循环程序似乎能够全天打开和关闭串口

。它似乎也可以打开,发送blahblahblah,并关闭

端口相同的时间长度。但是快速写任何东西到港口

(并不总是马上......就像通过

循环可能需要5-6次迭代?)导致


win32file.CloseHandle(self.hComPort)


语句在'def close(self)''函数中的
的serialwin32.py文件
将pySerial包挂起几秒钟,然后返回。下一次

open()尝试失败,''无法打开端口:(995,''CreateFile'',''

I / O操作已经由于线程退出或

应用程序请求而中止。'')异常。


大程序的故障模式是成功打开端口

完成一堆来回说话,然后在端口关闭时挂起几秒钟

,然后就不能重新打开端口了。在一堆读写过程中似乎永远不会发生
失败,但只有当

端口关闭时才会失败。它也可以运行一小时的大部分时间没有问题然后突然间......就像我说的那样,C ++程序永远不会失败。


我已经查看了C ++程序中的设置,以及serialwin32.py

文件中的设置并尝试将它们设置为尽可能相同,但没有运气。在win32all中挖掘

让我迷失得很快。我看到了所有的

设置,但不知道该尝试什么。这一切都在WinXP上,Python 2.4.1,

最新的pySerial和win32all。


这对任何人都响铃吗?
< br $> b $ b谢谢!


Bob

We have some equipment that communicates at 57600 baud RS232. The path from
the PC is USB to a Phillips USB hub, then off of that a TUSB3410 USB/Serial
converter. The driver for the 3410 chip creates a "normal" comm port (like
COM3). There is a C++ program that has no problem talking to the equipment,
but two Python programs have trouble. One is a big, scary, controller
program, and the other, since that is the one I''m having trouble with, is a
while() loop.

The while loop program seems to be able to open and close the serial port
all day. It also seems to be able to open, send "blahblahblah", and close
the port for the same length of time. But writing anything to the port
quickly (not always right away...like maybe 5-6 iterations through the
loop?) causes the

win32file.CloseHandle(self.hComPort)

statement in the ''def close(self)'' function of the serialwin32.py file of
the pySerial package to hang for a few seconds, then return. The next
open() attempt fails with the ''could not open port: (995, ''CreateFile'', ''The
I/O operation has been aborted because of either a thread exit or an
application request.'') exception.

The failure mode with the large program is it opens the port successfully
completes a bunch of back and forth talking, then hangs for a few seconds
when the port is closed, and then can''t reopen the port. It never seems to
fail in the middle of a bunch of reads and writes, but only when/after the
port is closed. It can also run for the better part of an hour with no
problems then all of a sudden... Like I said, the C++ program never fails.

I''ve looked at the settings in the C++ program, and in the serialwin32.py
file and tried to set them the same as best I can, but no luck. Digging
into the win32all stuff gets me lost quite quickly. I see all of the
settings, but have no idea what to try. This is all on WinXP, Python 2.4.1,
the latest pySerial and win32all.

Does this ring any bells with anyone?

Thanks!

Bob

推荐答案

我忘了提到一旦Python程序失败,那么C ++

程序也无法对端口进行操作,并且设备必须重新启动才能重新启动工作。


Bob

I forgot to mention that once the Python program(s) fail, THEN the C++
program also fails to opne the port, and the equipment has to be
power-cycled to get things to work again.

Bob


Bob Greschke写道:
Bob Greschke wrote:
但是写任何东西给港口
很快(并不总是马上......好像通过
循环可能会有5-6次迭代?)导致

win32file.CloseHandle(self.hComPort)

声明在'def close(self)'函数的serialwin32.py文件中将pySerial包挂起几秒钟,然后返回。
But writing anything to the port
quickly (not always right away...like maybe 5-6 iterations through the
loop?) causes the

win32file.CloseHandle(self.hComPort)

statement in the ''def close(self)'' function of the serialwin32.py file of
the pySerial package to hang for a few seconds, then return.




你确定这条线是阻塞的,而不是

这是对SetCommTimeouts()的调用吗?你是怎么证明它是哪一行的?
是什么? (我没有问题的答案,只是想确定

的信息...)


-Peter


" Peter Hansen" < PE *** @ engcorp.com>在消息中写道

news:rf ******************** @ powergate.ca ...
"Peter Hansen" <pe***@engcorp.com> wrote in message
news:rf********************@powergate.ca...
Bob Greschke写道:
Bob Greschke wrote:
但是快速写入任何东西
(并不总是马上......就像通过
循环可能有5-6次迭代?)导致

win32file.CloseHandle(self.hComPort)

声明在'def close(self)'函数的serialwin32.py文件中将pySerial包挂起几秒钟,然后返回。
But writing anything to the port
quickly (not always right away...like maybe 5-6 iterations through the
loop?) causes the

win32file.CloseHandle(self.hComPort)

statement in the ''def close(self)'' function of the serialwin32.py file of
the pySerial package to hang for a few seconds, then return.



你确定这条线是阻塞的,而不是之前的
线是调用SetCommTimeouts()吗?你是怎么证明它是哪条线的? (我没有问题的答案,只是想确定信息......)

-Peter



Are you certain it is this line that is blocking, and not the preceding
line which is a call to SetCommTimeouts()? How did you prove which line
it is? (I don''t have an answer to the problem, just wanted to be sure of
the information...)

-Peter



嗨!


我已将SetCommTimeouts行注释掉了。我只是在CloseHandle行之前和之后打印了几张




我没有编写C ++程序,但看起来它从来没有关闭序列号

端口。它在启动时打开,然后保持打开直到它退出。

Tsk tsk tsk。马虎。也许他们这样做是为了掩盖这个问题。 :)


Bob



Hi!

I had the SetCommTimeouts line commented out. I just have a couple of
prints before and after the CloseHandle line.

I didn''t write the C++ program, but it looks like it never closes the serial
port. It opens it when it starts up, then keeps it open until it quits.
Tsk tsk tsk. Sloppy. Maybe they did that to cover up this problem. :)

Bob


这篇关于pySerial Windows写入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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