Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97027

Re: Successfully send sms with python

From Laura Creighton <lac@openend.se>
Subject Re: Successfully send sms with python
References <05ab0edd-7285-4aca-b603-76e94dd8f0aa@googlegroups.com> <560229BB.7030501@gmail.com>
Date 2015-09-23 11:30 +0200
Newsgroups comp.lang.python
Message-ID <mailman.95.1443000641.28679.python-list@python.org> (permalink)

Show all headers | View raw


In a message of Tue, 22 Sep 2015 22:25:31 -0600, Michael Torrie writes:
<snip>
>Consider something like this with no error checking when using the
>serial port, no context managers for the serial device:
>file sms.py:
>----------------------
>import serial
>import time
>
>serial_port = 'COM13'
>timeout = 5
>baud = 460800
>
>def send_message(recipient, message):
>    ser = serial.Serial(serial_port, baud, timeout=timeout)
>    time.sleep(1)
>    self.ser.write('ATZ\r')
>    time.sleep(1)
>    self.ser.write('AT+CMGF=1\r')
>    time.sleep(1)
>    self.ser.write('''AT+CMGS="''' + self.recipient + '''"\r\n''')
>    time.sleep(1)
>    self.ser.write(self.content + "\r\n")
>    time.sleep(1)
>    self.ser.write(chr(26))
>    time.sleep(1)
>    print "message sent!"
>
>    ser.close()

2 questions.
Why all the sleep(1)s?
and don't you need to flush the thing after each write?

Laura

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Successfully send sms with python Timon Rhynix <timgeek951@gmail.com> - 2015-09-22 04:19 -0700
  Re: Successfully send sms with python Pavel S <pavel@schon.cz> - 2015-09-22 05:16 -0700
  Re: Successfully send sms with python mm0fmf <none@mailinator.com> - 2015-09-22 17:27 +0100
  Re: Successfully send sms with python Cameron Simpson <cs@zip.com.au> - 2015-09-23 09:20 +1000
  Re: Successfully send sms with python Michael Torrie <torriem@gmail.com> - 2015-09-22 22:25 -0600
  Re: Successfully send sms with python Pavel S <pavel@schon.cz> - 2015-09-23 01:46 -0700
    Re: Successfully send sms with python Cameron Simpson <cs@zip.com.au> - 2015-09-23 19:30 +1000
  Re: Successfully send sms with python Laura Creighton <lac@openend.se> - 2015-09-23 11:30 +0200

csiph-web