连接时如何通过 pySerial 与 3G 调制解调器通信? [英] How can I communicate with a 3G modem via pySerial while it is connected?

查看:71
本文介绍了连接时如何通过 pySerial 与 3G 调制解调器通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Ubuntu 11.04 和中兴通讯 3G 调制解调器.

I'm running Ubuntu 11.04 and a ZTE 3G modem.

调制解调器使用WvDial

The modem is dialed with WvDial

WvDial未使用调制解调器时,我可以向调制解调器发送AT命令,并获取信号强度等信息:

When the modem is not in use by WvDial I can send AT commands to the modem, and get information like signal strength:

AT+ZCSQ
+ZCSQ: 1,  -87 

OK

但是当WvDial 使用调制解调器时,/dev/ttyUSB0 被锁定,我无法查询.我错过了一些明显的东西吗?有什么方法可以配置调制解调器、WvDial 或 pyserial所以我可以在调制解调器连接时向调制解调器发送 AT 命令?

But when WvDial is using the modem, /dev/ttyUSB0 is locked and I can't query it. Am I missing something obvious? Is there any way I can configure the modem, WvDial, or pyserial so I can send AT commands to the modem while it's connected?

推荐答案

啊.显然,这个调制解调器暴露了几个 ttys 可以使用.当 WvDial 连接在 /dev/ttyUSB0 上时,我能够使用 /dev/ttyUSB1 发送 AT 命令:

Ah. Apparently this modem exposes a couple of ttys to work with. I was able to use /dev/ttyUSB1 to sent AT commands while WvDial was connected on /dev/ttyUSB0:

import serial

ser = serial.Serial('/dev/ttyUSB1', 9600, timeout=2)

at_command = 'AT+ZCSQ\r\n'
ser.write(at_command)
ser.sendBreak()

line = ser.read(ser.inWaiting())
ser.close

print line

这篇关于连接时如何通过 pySerial 与 3G 调制解调器通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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