PySerial 可以读但不能写 [英] PySerial can read but not write

查看:65
本文介绍了PySerial 可以读但不能写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PySerial 连接到 FTDI FT232R 芯片.我已验证与 RealTerm 的通信,并且使用 RealTerm 可以发送和接收数据.但是,我在 Python 中的实现只能接收数据.

I'm trying to use PySerial to connect to an FTDI FT232R chip. I have verified communication with my RealTerm and, using RealTerm, can both send and receive data. However, my implementation in Python can only receive data.

我正在尝试使用此行进行编写:

I am trying to write using this line:

for i in range(0,100):
    print "Loop "+str(i)
    print "Sending byte"
    ser.flush()
    print ser.write("B".encode('ascii'))
    time.sleep(1)

推荐答案

通信取决于芯片的配置、连接线和PySerial的参数.

Comunication depends on the configuration of the chip, the connecting cable and the parameters of PySerial.

这看起来像是电缆连接或通信协议(握手)的问题.

This looks like a problem of the connections of the cable or the communications protocol (handshaking).

最后一个是最容易检查的.它可以是 Xon/Xoff、硬件或无,但两边必须相同.

This last one is the simplest to check. It can be Xon/Xoff, hardware, or none, but it has to be the same at both sides.

如果握手是通过硬件进行的,则它依赖于除 trx 和 rcv 之外的电缆的其他线路.

If the handshaking is by hardware it depends on other lines of the cable besides trx and rcv.

这篇关于PySerial 可以读但不能写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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