Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97010
| Date | 2015-09-23 09:20 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: Successfully send sms with python |
| References | <05ab0edd-7285-4aca-b603-76e94dd8f0aa@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.83.1442965855.28679.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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