[Tutor] modem

Brad Chandler mbc2@netdoor.com
Fri, 23 Feb 2001 14:52:01 -0600

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Sent: Friday, February 23, 2001 11:12 AM
To: tutor@python.org
Subject: [Tutor] modem

>Can someone tell me if there is a module that allows communication
>(read, write, enable and disable) to your serial port.
>Python 2.0 on windows 9X.
>Thanks, Al

I've never tried it on windows, but the following works on linux. You might
want to try it, with the exception of the "/dev/cua0" as the modem device,
it shouldn't be specific to linux. Also, check the serial how-to and the
modem how-to at http://www.linuxdoc.org

I realize that's a linux site but I think there might still be some usefull
information there for you.

import os

modem = open('/dev/cua0','w+') # replace /dev/cua0 with your modem device
# "AT" is part of an initialization string for your modem, check you modem's
# documentation.

x = os.read(modem.fileno(),200)
print x
# You should get "OK" from this after sending "AT" with os.write. "200" is
# the maximum number of bytes to read, I just used 200 as an example.