Access modem (serial port) using python under Linux

Arild Hansen arildh at stud.cs.uit.no
Fri Sep 15 12:54:34 CEST 2000


Hello,

I'm trying to access an external modem using a python script I found.
The script is as follows:

modem = open('/dev/ttyS0', 'r+')
modem.write('AT\r')
f = modem.read()                                        <- script hangs
here
if f[:2] != 'OK':
    raise ValueError, "Modem not okay"


I know other people have been asking the same question, but I haven't
found any answers. Can anybody point me in the right direction or give
me an example of how to properly communicate with the modem using
AT commands in Python? I'm running Python 2.01b under Linux. The modem
is correctly set up (tested using Minicom). All help would be greatly
appreciated,

Arild Hansen




More information about the Python-list mailing list