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


Groups > comp.lang.python > #97010

Re: Successfully send sms with python

Path csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'suggestions:': 0.09; 'thrown': 0.09; 'def': 0.13; 'subject:python': 0.14; '"message': 0.16; '\\r\\n': 0.16; 'conn': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message):': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subject:send': 0.16; 'suggested,': 0.16; 'wrote:': 0.16; 'runs': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'libraries': 0.22; 'cheers,': 0.22; 'cc:no real name:2**0': 0.22; 'header:In- Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'error': 0.27; 'print': 0.30; 'code': 0.30; 'skip:s 30': 0.31; 'skip:_ 10': 0.32; 'run': 0.33; 'received:com.au': 0.33; 'stream': 0.33; 'skip:d 20': 0.34; 'text': 0.35; 'follows:': 0.35; 'but': 0.36; 'instead': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'charset:us-ascii': 0.37; 'thank': 0.38; 'subject:with': 0.40; 'cameron': 0.66; 'sms': 0.66; 'serial': 0.70; 'film': 0.72; 'training': 0.78; 'honda': 0.84; 'number):': 0.84
Date Wed, 23 Sep 2015 09:20:32 +1000
From Cameron Simpson <cs@zip.com.au>
To Timon Rhynix <timgeek951@gmail.com>
Cc python-list@python.org
Subject Re: Successfully send sms with python
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <05ab0edd-7285-4aca-b603-76e94dd8f0aa@googlegroups.com>
User-Agent Mutt/1.5.23 (2014-03-12)
References <05ab0edd-7285-4aca-b603-76e94dd8f0aa@googlegroups.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=C/8Usl7+ c=1 sm=1 tr=0 a=t6IGaf1l19PsElHJfDn/BA==:117 a=t6IGaf1l19PsElHJfDn/BA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=vrnE16BAAAAA:8 a=kj9zAlcOel0A:10 a=ff-B7xzCdYMA:10 a=pGLkceISAAAA:8 a=IbhHJBFDq3FER1ArXzYA:9 a=x6q1pE-erY5MSgyA:21 a=zZwQOdftLfAFMG9J:21 a=CjuIK1q_8ugA:10
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.83.1442965855.28679.python-list@python.org> (permalink)
Lines 54
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1442965855 news.xs4all.nl 23723 [2001:888:2000:d::a6]:40028
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:97010

Show key headers only | View raw


On 22Sep2015 04:19, Timon Rhynix <timgeek951@gmail.com> wrote:
>Hello, I have used pyserial, sms0.4 and other libraries to send sms via huawei E1750 modem.
>The code runs well and no error is thrown but the text message is not sent/delivered to the number.
>One of my code is as follows:
>
>import serial
>import time
>
>class TextMessage:
>    def __init__(self, recipient="0123456789", message="TextMessage.content not set."):
>        self.recipient = recipient
>        self.content = message
>
>    def setRecipient(self, number):
>        self.recipient = number
>
>    def setContent(self, message):
>        self.content = message
>
>    def connectPhone(self):
>        conn = 'COM13'
>        self.ser = serial.Serial(conn, 460800, timeout=5)
>        time.sleep(1)
>
>    def sendMessage(self):
>        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''')
>        time.sleep(1)
>        self.ser.write(self.content + "\r")
>        time.sleep(1)
>        self.ser.write(chr(26))
>        time.sleep(1)
>        print "message sent!"
>
>    def disconnectPhone(self):
>        self.ser.close()
>
>When run it, the "message sent!" is printed but no message is sent/delivered.
>Please assist on what I am missing. Thank you

Two suggestions:

  as already suggested, you may need to send \r\n instead of just \r

  do you need to follow every .write() with a .flush()? if the Serial object is 
  a buffered stream that will be necessary

Cheers,
Cameron Simpson <cs@zip.com.au>

Motorcycling is indeed a delightful pastime.    - Honda Rider Training Film

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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