串行通信。以正确的方式发送 DTR?
我正在处理索尼爱立信的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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里想到了几件事。
1) 规范表明 DTR 为低电平有效,因此您可能需要将
true
和false
值交换为setDTR()
,具体取决于谁在这里感到困惑。2) 唤醒调制解调器后,您将
DTR
设置为 false。这告诉调制解调器离线,并忽略所有输入,直到它再次变为true
。请尝试以下操作: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
andfalse
values tosetDTR()
, 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 goestrue
again. Try the following:3)
socket
is probably a bad name for your serial connection.