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: 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 cc: python-list@python.org, lac@openend.se From: Laura Creighton 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 In a message of Tue, 22 Sep 2015 22:25:31 -0600, Michael Torrie writes: >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