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


Groups > comp.lang.python > #97027

Re: Successfully send sms with python

Path csiph.com!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <lac@openend.se>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'context': 0.05; 'cc:addr :python-list': 0.09; 'flush': 0.09; 'port,': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'subject:python': 0.14; '"message': 0.16; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message):': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'ser.close()': 0.16; 'skip:> 20': 0.16; 'subject:send': 0.16; 'laura': 0.18; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'sep': 0.22; 'error': 0.27; 'checking': 0.27; 'received:se': 0.29; 'cc:no real name:2**1': 0.29; 'print': 0.30; 'skip:s 30': 0.31; 'michael': 0.33; 'tue,': 0.34; 'something': 0.35; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'why': 0.39; 'subject:with': 0.40; 'header:Message-Id:1': 0.61; 'managers': 0.63; 'serial': 0.70; '>def': 0.84; 'header:In-reply-to:1': 0.84
To Michael Torrie <torriem@gmail.com>
cc python-list@python.org, lac@openend.se
From Laura Creighton <lac@openend.se>
Subject Re: Successfully send sms with python
In-reply-to <560229BB.7030501@gmail.com>
References <05ab0edd-7285-4aca-b603-76e94dd8f0aa@googlegroups.com> <560229BB.7030501@gmail.com>
Comments In-reply-to Michael Torrie <torriem@gmail.com> message dated "Tue, 22 Sep 2015 22:25:31 -0600."
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-ID <32236.1443000629.1@fido>
Date Wed, 23 Sep 2015 11:30:29 +0200
X-Greylist Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Wed, 23 Sep 2015 11:30:33 +0200 (CEST)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.95.1443000641.28679.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1443000641 news.xs4all.nl 23788 [2001:888:2000:d::a6]:42479
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:97027

Show key headers only | 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