串行通信。以正确的方式发送 DTR?

发布于 2024-08-23 13:05:35 字数 1296 浏览 4 评论 0原文

我正在处理索尼爱立信的gm29

数据表说插入电源是不够的打开调制解调器。上面写着:

  • 激活RS232控制线DTR,高电平为> 0.2秒。

我正在用 python 编写一些测试,但是:

#!/usr/bin/env python                                                                                         

import serial
from time import sleep

socket = serial.Serial('/dev/ttyS0',
                       baudrate=9600,
                       bytesize=serial.EIGHTBITS,
                       parity=serial.PARITY_NONE,
                       stopbits=serial.STOPBITS_ONE,
                       timeout=1,
                       xonxoff=0,
                       rtscts=0
                       )
socket.setDTR(True)
sleep(3)
socket.setDTR(False)
try:
    while True:
        socket.write('AT'+chr(13));
        sleep(1)
        print "Reading"
        print socket.readlines()
except:
    socket.close()

不起作用...我有办法通过其他方式提高 DTR 吗?让我们说迷你电脑或其他东西?或者,很容易,我错过了什么吗?

提前致谢。


好吧,这让我抓狂。线索是电源供应器“坏了”,或者更好的是,它可以用测试仪进行良好的测试,但是插入调制解调器时,一些电线会移动并且不带电压......

无论如何,感谢您的回答,标记为正确的“原因”是:D

I'm dealing with a gm29 by Sony Ericsson.

The datasheet says that plugging the power is not sufficient to switch on the modem. It says:

  • activate the RS232 control line DTR, high for > 0.2s.

I'm writing some tests in python, but:

#!/usr/bin/env python                                                                                         

import serial
from time import sleep

socket = serial.Serial('/dev/ttyS0',
                       baudrate=9600,
                       bytesize=serial.EIGHTBITS,
                       parity=serial.PARITY_NONE,
                       stopbits=serial.STOPBITS_ONE,
                       timeout=1,
                       xonxoff=0,
                       rtscts=0
                       )
socket.setDTR(True)
sleep(3)
socket.setDTR(False)
try:
    while True:
        socket.write('AT'+chr(13));
        sleep(1)
        print "Reading"
        print socket.readlines()
except:
    socket.close()

does not works... I there a way to get DTR high in other ways? Let's say minicom or some other stuff? Or, easily, am I missing something?

Thanks in advance.


Ok, that was driving me mad. The clue is that the power supplier was "broken", or better, it works good testing with a tester, but plugging on the modem some wires moves and does not carry voltage...

Thanks anyway for the answer, marked as correct 'couse it was :D

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梅窗月明清似水 2024-08-30 13:05:35

我在这里想到了几件事。

1) 规范表明 DTR 为低电平有效,因此您可能需要将 truefalse 值交换为 setDTR(),具体取决于谁在这里感到困惑。

2) 唤醒调制解调器后,您将 DTR 设置为 false。这告诉调制解调器离线,并忽略所有输入,直到它再次变为 true。请尝试以下操作:

import serial
from time import sleep

conn = serial.Serial('/dev/ttyS0',
                     baudrate=9600,
                     bytesize=serial.EIGHTBITS,
                     parity=serial.PARITY_NONE,
                     stopbits=serial.STOPBITS_ONE,
                     timeout=1,
                     xonxoff=0,
                     rtscts=0
                     )
# Wake Modem
conn.setDTR(True)
sleep(3)
conn.setDTR(False)

sleep(5)

# Start talking
conn.setDTR(True)
try:
    while True:
        conn.write('AT'+chr(13));
        print conn.readline() # readlines() will probably never return.
finally:
    conn.close()

3) socket 对于串行连接来说可能是一个不好的名称。

There are several things that occur to me here.

1) the spec says that DTR is active low, so you may need to swap the true and false values to setDTR(), depending on who is confused here.

2) You are setting DTR to false after you wake the modem. This tells the modem to go offline, and ignore all input till it goes true again. Try the following:

import serial
from time import sleep

conn = serial.Serial('/dev/ttyS0',
                     baudrate=9600,
                     bytesize=serial.EIGHTBITS,
                     parity=serial.PARITY_NONE,
                     stopbits=serial.STOPBITS_ONE,
                     timeout=1,
                     xonxoff=0,
                     rtscts=0
                     )
# Wake Modem
conn.setDTR(True)
sleep(3)
conn.setDTR(False)

sleep(5)

# Start talking
conn.setDTR(True)
try:
    while True:
        conn.write('AT'+chr(13));
        print conn.readline() # readlines() will probably never return.
finally:
    conn.close()

3) socket is probably a bad name for your serial connection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文