GSM Send Text Fail - Raspberry Pi Forums


i trying send text using a-gsm shield raspberry pi 3. using sample python code came gsm attempt send text , receiving following error:

code: select all

^ctraceback (most recent call last):   file "./sendsms.py", line 96, in <module>     res = sendsms(destinationnumber, "129", message)#domestic format numbers   file "/home/wvandiver/gsm/rpi_examples/a-gsm-rpi-examples-py-library-based-v1_                                                                                        2/agsm_sms_lib.py", line 36, in sendsms     res = recuartdata(">","error",12)   file "/home/wvandiver/gsm/rpi_examples/a-gsm-rpi-examples-py-library-based-v1_                                                                                        2/agsm_serial_lib.py", line 88, in recuartdata     dt = agsm.read(tm)   file "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 447, in re                                                                                        ad     ready,_,_ = select.select([self.fd],[],[], self._timeout)
think problem has "read = bytearray()" on line 444 in /usr/lib/python2.7/dist-packages/serial/serialposix.py. reason, "read" not return value when printed after calling bytearray().

code: select all

# select based implementation, proved work on many systems def read(self, size=1):     """read size bytes serial port. if timeout set may        return less characters requested. no timeout block        until requested number of bytes read."""     if not self._isopen: raise portnotopenerror     read = bytearray()     print "loosing @ bytearray: ",read  #read empty string     while len(read) < size:         ready,_,_ = select.select([self.fd],[],[], self._timeout)         # if select used timeout, , timeout occurs,         # returns empty lists -> abort read operation.         # timeout == 0 (non-blocking operation) abort when there         # nothing read.         if not ready:             break   # timeout         buf = os.read(self.fd, size-len(read))         # read should return data select reported         # ready read when point.         if not buf:             # disconnected devices, @ least on linux, show             # behavior ready read             # reading returns nothing.             raise serialexception('device reports readiness read returned no data (device disconnected?)')         read.extend(buf)     return bytes(read)
following copy of python code using send text message.

code: select all

############################################################################################################################################ #a-gsm-send-sms.py v1.01/13 june 2016 - a-gsm 2.064 send sms utility / demo #copyright (c) 2016 dragos iosub / r&d software solutions srl # #you legaly entitled use software in conjunction a-gsm devices usage. modifications, derivates , redistribution #of software must include unmodified copyright notice. can redistribute software and/or modify under terms #of copyright notice. other usage may permited after written notice of dragos iosub / r&d software solutions srl. # #this software distributed provide "as is" in hope useful, without warranty; without implied #warranty of merchantability or fitness particular purpose. # #dragos iosub, bucharest 2016. #http://itbrainpower.net ############################################################################################################################################ #health , safety warning!!!!!!!!!!!!!!!!!!!! #high power audio (around 700mw rms)! can damage years! use care when headset connected. #we recomend use at+clvl=20 (as maximum value), audio setup command in order limit output power. # # warning: wiring a-gsm-gsm board u-controllers/boards(rpi) must made boards unpowered!! # # legal disclaimer: # incorrect or faulty wiring and/or connection can damage rpi and/or a-gsm board! # following directives provided "as is" in hope useful, without warranty! # wiring on own risk! # # references: # http://itbrainpower.net/a-gsm/images/raspberypi_a-gsm_shield-wiring.png # http://itbrainpower.net/a-gsm/downloadables/a-gsm_kickstart_v_0-90.pdf # http://itbrainpower.net/a-gsm/gsm-shield-arduino-raspberrypi-features-code-examples.php # http://itbrainpower.net/a-gsm/gsm-shield-arduino-raspberrypi-projects.php ############################################################################################################################################ # utility must runned root (just use: sudo python yourpythonfilename.py)  message="hi!\r\nthis message has been sent a-gsm v2.064 shield connected rpi board." destinationnumber="1234567890"  #usually phone number international prefix eg. +40 romania - in networks must use domestic numbers  usepoweringcontrol = 1  #change 0 if not want control powerup/powerdown a-gsm board. in case, please sure a-gsm board powered up(..see a-gsm_kickstart_v_x-yz.pdf) before run utility  #do not change under following line! insteed make 1 copy of file , play with! #hint: if make changes of code, before run run clear utility (erase python compiled *.pyc files)...         ###erase .pyc files         `find . -name '*.pyc' -delete` ############################################################################################################################################  import os import serial time import sleep, time string import replace  globalparvar import * agsm2_064_hw_control import * agsm_serial_lib import * agsm_basic_lib import * agsm_sms_lib import *  print "light example - send sms destination number" sleep(1)  if not os.getuid() == 0:     print("please use root privileges! try: \"sudo python yourpythonfilename.py\"")     exit(0)  if destinationnumber=="":     print("no destination number has been set sms!")     print("edit file , set destinationnumber in line 35\r\n")     exit(0)  # set serial/usb communication section start # bellow chose value bw [ser] serial /dev/ttyama0 or [usb] /dev/ttyusb0 # if module usb port maps other port /dev/ttyusb1, edit modulename_serial_lib.py... serialcommunicationvia = serialcon      # override default value loaded globalparvar.py. here use via serial communication setserialcom(serialcommunicationvia)    # set current communication option startserialcom()                        # open serial communication bw. rpi , a-gsm shield # set serial/usb communication section end  # set hardware control setup & power on section start if usepoweringcontrol==1:     hwcontrolsetup()                    # setup rpi i/o ports  sleep(2)#some delay...  if usepoweringcontrol==1:     poweron()  sleep(1) # set hardware control setup & power on section end  # set modem startup setup section start setupmodem() # set modem startup setup section end   # main program section start print "try send sms...."  #check @ command pdf proper 129/145 parameter/number format usage res = sendsms(destinationnumber, "129", message)#domestic format numbers #res = sendsms(destinationnumber, "145", message)#international format numbers if res==0:         print "sms has been sent succes" # main program section end  # stop serial communication section start stopserialcom()                             # close modem communication # stop serial communication section end  # hardware control release & power off section start if usepoweringcontrol==1:     poweroff()                              #shutdown modem  if usepoweringcontrol==1:     hwcontrolrelease()                      # free gpio # hardware control release & power off section end   print("\r\n\r\nthat's folks!\r\n")
please me understand why bytearray() returning empty string.

solved

there discrepancy wiring schematic in sample code http://itbrainpower.net/a-gsm/raspberry ... code-a-gsm , wiring schematic manufacturer http://itbrainpower.net/a-gsm/images/ra ... wiring.png.
#name rpi a-gsm shield
#
#power a-gsm 16 d7 - power(up/down)
#reset a-gsm 18 d6 - reset
#a-gsm status 12 d5 - status
#
#serial txd0 08 d4 - tx(rxd)
#serial rxd0 10 d3 - rx(txd)
#
#5v 02/04 5v - on arduino power in connector
#gnd 06/14 gnd - on arduino power in connector

a-gsm d2 goes pin 10 of rpi
a-gsm d3 goes pin 8 of rpi
a-gsm d4 should not used standard setup of rpi

once wires switched , tutorial viewtopic.php?f=28&t=165897&p=1069504#p1069504 followed, able send text.


raspberrypi



Comments