Raspberry Pi 3과 함께 a-gsm shield를 사용하여 텍스트를 보내려고합니다. GSM과 함께 제공된 샘플 Python 코드를 사용하여 텍스트를 보내려고하고 다음 오류가 발생했습니다.GSM 전송 텍스트가 실패합니다
^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)
이 문제는 /usr/lib/python2.7/dist-packages/serial/serialposix.py의 444 줄에있는 "read = bytearray()"와 관련이 있다고 생각합니다. 어떤 이유로, "read"는 bytearray()를 호출 한 후에 인쇄 할 때 값을 반환하지 않습니다.
다음은 텍스트 메시지를 보내는 데 사용하는 python 코드의 복사본입니다.
############################################################################################################################################
#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 are legaly entitled to use this SOFTWARE ONLY IN CONJUNCTION WITH a-gsm DEVICES USAGE. Modifications, derivates and redistribution
#of this software must include unmodified this COPYRIGHT NOTICE. You can redistribute this SOFTWARE and/or modify it under the terms
#of this COPYRIGHT NOTICE. Any other usage may be permited only after written notice of Dragos Iosub/R&D Software Solutions srl.
#
#This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
#warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
#Dragos Iosub, Bucharest 2016.
#http://itbrainpower.net
############################################################################################################################################
#HEALTH AND SAFETY WARNING!!!!!!!!!!!!!!!!!!!!
#High power audio (around 700mW RMS)! You can damage your years! Use it with care when headset is connected.
#We recomend to use AT+CLVL=20 (as maximum value), audio setup command in order to limit the output power.
#
# WARNING: WIRING the a-gsm-gsm board with u-controllers/boards(RPi) must be made with boards UNPOWERED!!
#
# LEGAL DISCLAIMER:
# Incorrect or faulty wiring and/or connection can damage your RPi and/or your a-gsm board!
# Following directives are provided "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY!
# Do the wiring on your 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
############################################################################################################################################
# this utility must be runned as root (just use: sudo python yourPythonFileName.py)
message="Hi!\r\nThis message has been sent from the a-gsm v2.064 shield connected with my RPi board."
destinationNumber="1234567890" #usually phone number with International prefix eg. +40 for Romania - in some networks you must use domestic numbers
usePoweringControl = 1 #change it to 0 if you do not want to control powerUP/powerDown the a-gsm board. In this case, please be sure the a-gsm board is powered UP(..see a-gsm_kickstart_v_x-yz.pdf) before run this utility
#Do not change under following line! Insteed make one copy of the file and play with!
#Hint: if you make changes of the code, before you run it run clear utility (erase the Python compiled *.pyc files)...
###erase .pyc files by `find . -name '*.pyc' -delete`
############################################################################################################################################
import os
import serial
from time import sleep, time
from string import replace
from globalParVar import *
from agsm2_064_hw_control import *
from agsm_Serial_Lib import *
from agsm_Basic_Lib import *
from agsm_SMS_Lib import *
print "Light example - just send a SMS to a 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 for your SMS!")
print("Edit the file and set the 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 to other port as /dev/ttyUSB1, just edit the moduleName_Serial_lib.py...
serialCommunicationVia = SERIALCON # OVERRIDE the default value loaded from globalParVar.py. here I use via SERIAL communication
setSerialCom(serialCommunicationVia) # set the current communication option
startSerialCom() # open serial communication bw. RPi and a-gsm shield
# set SERIAL/USB communication section end
# set HARDWARE CONTROL setup & POWER ON section start
if usePoweringControl==1:
hwControlSetup() # setup the 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 to send a SMS...."
#check AT command pdf for 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 with 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 all folks!\r\n")
왜 bytearray()가 빈 문자열을 반환하는지 이해하도록 도와주세요.