Skip to content

Commit

Permalink
updated demo.py
Browse files Browse the repository at this point in the history
  • Loading branch information
adammck committed Nov 12, 2009
1 parent f4a7486 commit 5f8ab6b
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions demo.py
@@ -1,9 +1,10 @@
#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4
# see LICENSE file (it's BSD)


from pygsm import GsmModem
import time
from pygsm import GsmModem


class CountLettersApp(object):
Expand All @@ -15,36 +16,27 @@ def incoming(self, msg):
len(msg.text))

def serve_forever(self):
"""Block forever, polling the modem for new messages every
two seconds. When a message is received, pass it on to
the _incoming_ message for handling."""

while True:

# poll the modem
print "Checking for message..."
msg = self.modem.next_message()

if msg is not None:
print "Got Message: %r" % (msg)
self.incoming(msg)

# no messages? wait a couple of seconds
# (let's not blow up the modem), and retry
time.sleep(2)


# connect to my multitech MTCBA-G-U-F4 modem,
# which requires more configuration than most
# all arguments to GsmModem.__init__ are optional, and passed straight
# along to pySerial. for many devices, this will be enough:
gsm = GsmModem(
port="/dev/ttyUSB0",
baudrate=115200,
xonxoff=0,
rtscts=1)

# all arguments to GsmModem.__init__ are optional,
# and passed straight on to pySerial. for many
# devices, this will be enough:
#gsm = GsmModem(port="/dev/ttyUSB0")
logger=GsmModem.debug_logger).boot()


print "Waiting for network..."
s = gsm.wait_for_network()


# start the demo app
app = CountLettersApp(gsm)
Expand Down

0 comments on commit 5f8ab6b

Please sign in to comment.