Exemple #1
0
def write_registers(start_reg, *data):
    SER2.send('writing: %02x %r\r\n' % (start_reg, data))

    MDM.send(
        'AT#I2CWR=%d,%d,%02x,%02x,%d\r' %
        (GPIO_SDA, GPIO_SCL, CODEC_ADDR, start_reg, len(data)), 0)
    MDM.send(''.join(hex(x)[2:].zfill(2) for x in data), 0)
    MDM.sendbyte(0x1a, 0)

    return wait_for_response()
Exemple #2
0
def sendSMS(theSmsMsg,theDestination,theTerminator,retry,timeOut):
#This function sends an SMS Message

  # Input Parameter Definitions
  #   theSmsMsg: The text SMS Message
  #   theTerminator: string or character at the end of AT Command
  #   retry:  How many times the command will attempt to retry if not successfully send 
  #   timeOut: number of [1/10 seconds] command could take to respond

    try:

        rtnList = [-1,-1]    #[return status,return data]
        # return status:
        #   -2:    Timeout
        #   -1:    Exception occurred
        #    0:    No errors occurred, no return data
        #    1:    No errors occurred, return data        

      #Note that the 145 being sent in with the destination address is the "type" of destination address, with 145 including a "+" for international
        while (retry != -1):

            rtnList[1] = MDM.send('AT+CMGS="' + str(theDestination) + '",145', 0)
            rtnList[1] = MDM.sendbyte(0x0d, 0)
            rtnList = ATC.mdmResponse('\r\n>', timeOut)

            rtnList[1] = MDM.send(theSmsMsg, 0)
            rtnList[1] = MDM.sendbyte(0x1a, 0)

            #Wait for AT command response
            rtnList = ATC.mdmResponse(theTerminator, timeOut)
              
            #Did AT command respond without error?
            pos1 = rtnList[1].rfind(theTerminator,0,len(rtnList[1]))
            if (pos1 != -1):
              retry = -1
              rtnList = ATC.parseResponse(rtnList[1])
            else:
              retry = retry - 1
     
        rtnList[0] = 0  #no error, no data  

  #If the function fails to find the proper response to the SMS send ('OK<cr><lf>') then we receive a timeout string: 'timeOut'  
    except:
        print sys.exc_info()
        rtnList[0] = -1


    return rtnList
Exemple #3
0
def sendSMS(NUMBER, SMSText):
	TIMEOUT_CMD = 50
	Helper.writeLog('Starting sendSMS\r\n')
	
	res = Helper.sendCmd('AT+CMGF', '1', TIMEOUT_CMD) # select text format type
	Helper.writeLog('Finished AT+CMGF\r\n')
	
	res = Helper.sendCmd('AT+CNMI', '2,1', TIMEOUT_CMD) # alarm indicators
	Helper.writeLog('Finished AT+CNMI\r\n')
	
	res = Helper.sendCmd('AT+CMGS', NUMBER, TIMEOUT_CMD) # send the message without storing it
	Helper.writeLog('Finished AT+CMGS\r\n')
	
	if (res.find('>') == -1):
		return -1
	else:
		res = MDM.send(SMSText, 0)
		Helper.writeLog('Finished sending SMSText\r\n')
		
		res = MDM.sendbyte(0x1a, 0)
		Helper.writeLog('Finished CTRL+Z\r\n')
		
		for i in range(6):
			res=MDM.read()
			if(res.find("OK")!=-1):
				Helper.writeLog('Found and returning\r\n')
				return 1
			else:
				MOD.sleep(300)
		
		Helper.writeLog('REturning -1\r\n')
		return -1
Exemple #4
0
def send_CM(inSTR,connId,timeOut):
    # This function sends a string while in Command Mode
    #   Arguments:
    #   inSTR: String to send
    #   connId: Connection #
    #   timeOut: Amount of time alotted to send
    #
    #   Returns:
    #    0: Pass
    #    1: String argument empty
    #   -1: Exception
    #   -2: Timeout
    
    if (len(inSTR)==0):
        return 1

    try:

        res = MDM.send('AT#SSEND=' + str(connId) + '\r\n', 0)   

        #Start timeout counter        
        timerA = timers.timer(0)
        timerA.start(timeOut)

        prompt = '\r\n> '

        #Start looking for '\r\n>'
        while(1):

            properties.CMD_BUFFER = properties.CMD_BUFFER + MDM.receive(1)      
            pos1 = properties.CMD_BUFFER.find(prompt)   #look for prompt characters
            if (pos1>=0):
                properties.CMD_BUFFER = properties.CMD_BUFFER[0:pos1] + properties.CMD_BUFFER[pos1+len(prompt):len(properties.CMD_BUFFER)]
                res = MDM.send(inSTR, 0)
                res = MDM.sendbyte(0x1a, 0)       
                
                tempread = ''
                res = ''
                while(1):
                    tempread = MDM.read()
                    if (tempread != ''):
                        res = res + tempread

                    if (res.find('OK')>=0):
                        return (0)    #Pass
                    
                    if timerA.isexpired():
                        return (-2)    #Expired, can't find OK response

            if timerA.isexpired():
                return (-2)    #Expired, no prompt found

    except:
        printException("send_CM(" + inSTR + "," + connId + "," + timeOut + ")")
        JANUS_SER.sendUART("Send CM Exception. \r\n")  

    #Would return with something else before this if it passes without exception
    return (-1) 
Exemple #5
0
 def sendSMS(self, number, smstext):
     # Send command for sending message
     a = MDM.send('AT+CMGS="' + number + '"\r', 2)
     # clear receive buffer
     res = MDM.receive(10)
     a = MDM.send(smstext, 2)  # Send body of message
     # this terminates the message and sends it
     a = MDM.sendbyte(0x1A, 2)  # terminating the message require ctrl-z
     return ()
def sendSMS(theSmsMsg,theDestination,theTerminator,retry,timeOut):
#This function sends an SMS Message

  # Input Parameter Definitions
  #   theSmsMsg: The text SMS Message
  #   theTerminator: string or character at the end of AT Command
  #   retry:  How many times the command will attempt to retry if not successfully send 
  #   timeOut: number of [1/10 seconds] command could take to respond

    try:

        while (retry != -1):
            print 'AT+CMGS="' + str(theDestination) + '",145'
          
            res = MDM.send('AT+CMGS=' + str(theDestination) + ',145', 0)
            res = MDM.sendbyte(0x0d, 0)
            res = mdmResponse('\r\n>', timeOut)
            print res 

            res = MDM.send(theSmsMsg, 0)
            res = MDM.sendbyte(0x1a, 0)

            #Wait for AT command response
            res = mdmResponse(theTerminator, timeOut)

            #Did AT command respond without error?    
            pos1 = res.rfind(theTerminator,0,len(res))
            if (pos1 != -1):
              retry = -1
              res = parseResponse(res)
            else:
              retry = retry - 1

    except:
        print 'Script encountered an exception.'
        print 'Exception Type: ' + str(sys.exc_type)
        print 'MODULE -> ATC'
        print 'METHOD -> sendSMS(' + theSmsMsg + ',' + theDestination + ',' +theTerminator + ',' + retry + ',' + timeOut + ')'

    print res
  
    return res
Exemple #7
0
def sendEMAIL(theEmailSubject,theEmailBody,theTerminator,retry,timeOut):
#This function sends email

  # Input Parameter Definitions
  #   theEmailSubject: The text Email Subject
  #   theEmailBody: The text Email Body
  #   theTerminator: string or character at the end of AT Command
  #   retry:  How many times the command will attempt to retry if not successfully send 
  #   timeOut: number of [1/10 seconds] command could take to respond

    try:

        while (retry != -1):
            print 'AT#SEMAIL="' + EMAIL_ADDRESS + '","' + theEmailSubject + '",0'

            res = MDM.send('AT#SEMAIL="' + EMAIL_ADDRESS + '","' + theEmailSubject + '",0', 0)
            res = MDM.sendbyte(0x0d, 0)
            res = mdmResponse('\r\n>', timeOut)
            print res 

            res = MDM.send(theEmailBody, 0)
            res = MDM.sendbyte(0x1a, 0)

            #Wait for AT command response
            while (1):
                res = mdmResponse(theTerminator, timeOut)
              
                #Did AT command respond without error?    
                pos1 = res.rfind(theTerminator,0,len(res))
                if (pos1 != -1):
                    retry = -1
                    res = parseResponse(res)
                else:
                    retry = retry - 1

    except:
        printException("sendEMAIL()")

    print res
  
    return res
Exemple #8
0
def sendAtCmd(theCommand, theTerminator, timeOut):
# This function sends an AT command to the MDM interface

    # Input Parameter Definitions
    #   theCommand: The AT command to send to MDM interface
    #   theTerminator: string or character at the end of AT Command 
    #   timeOut: number of seconds command could take to respond

    try:

        rtnList = [-1,-1]    #[return status,return data]
        # return status:
        #   -2:    Timeout
        #   -1:    Exception occurred
        #    0:    No errors occurred, no return data
        #    1:    No errors occurred, return data


        #Clear input buffer
        rtnList[1] = 'junk'
        while(rtnList[1] != ''):
            rtnList[1] = mySER.read()

        print 'Sending AT Command: ' + theCommand + "\r\n"
        rtnList[1] = mySER.send(theCommand,2)
        rtnList[1] = mySER.sendbyte(0x0d,2)

        while True:
            #Wait for AT command response
            rtnList = mdmResponse(theTerminator, timeOut)
            if (rtnList[0] == -1) or (rtnList[0] == -2) : return rtnList
            elif rtnList[0] == 1:
                #what happens if res doesn't return data?
                #Did AT command respond without error?
                pos1 = rtnList[1].rfind('ERROR',0,len(rtnList[1]))    
                pos2 = rtnList[1].rfind(theTerminator,0,len(rtnList[1]))
                if ((pos1 != -1) or (pos2 != -1)) :
                    rtnList = parseResponse(rtnList[1])
                    if rtnList[0] == -1: return rtnList
                    elif rtnList[0] == 1:
                        #what happens if res doesn't return data?
                        rtnList[0] = 1
                        break

    except:
        print sys.exc_info()
        rtnList[0] = -1

    print rtnList[1]

    return rtnList
Exemple #9
0
def sendSMS( number, smstext):#, csca):
    if number=="" or smstext=="" : return 0 # or csca == "" : return 0
    #MDM.send('AT+CSCA='+csca+'r',2)
    #MDM.receive(20)
    MDM.send('AT+CMGF=1\r',2)
    MDM.receive(20)
    a = MDM.send('AT+CMGS="' + number + '"\r', 2)
    res = MDM.receive(10)          
    a = MDM.send(smstext, 2)
    a = MDM.sendbyte(0x1A, 2)
    a=''
    while a=='':
        a = MDM.receive(20)
    return ( a.find('OK')!=-1 )
Exemple #10
0
def send_CM(inSTR, connId, timeOut):

    ## TWH - 09/16/2009
    ## Need to determine to timeout for this command

    if len(inSTR) == 0:
        return 1

    try:

        res = MDM.send("AT#SSEND=" + str(connId) + "\r\n", 0)

        # Start timeout counter
        timerA = timers.timer(0)
        timerA.start(timeOut)

        prompt = "\r\n> "

        # Start looking for '\r\n>'
        while 1:

            properties.CMD_BUFFER = properties.CMD_BUFFER + MDM.receive(1)
            pos1 = properties.CMD_BUFFER.find(prompt)  # look for prompt characters
            if pos1 >= 0:
                properties.CMD_BUFFER = (
                    properties.CMD_BUFFER[0:pos1]
                    + properties.CMD_BUFFER[pos1 + len(prompt) : len(properties.CMD_BUFFER)]
                )
                res = MDM.send(inSTR, 0)
                res = MDM.sendbyte(0x1A, 0)

                res = ""
                tmpByte = -1
                while 1:
                    tmpByte = MDM.readbyte()
                    if tmpByte != -1:
                        res = res + tmpByte

                    if res.find("\r\nOK\r\n") >= 0:
                        return 0
                    if timerA.isexpired():
                        return -2

            if timerA.isexpired():
                return -2

    except:
        printException("send_CM()")

    return -3
Exemple #11
0
def sendSMS(number, smstext):
    if number == "" or smstext == "": return 0
    #text mode setup
    MDM.send('AT+CMGF=1\r', 2)
    MDM.receive(20)
    #Send SMS intialization
    MDM.send('AT+CMGS="' + number + '"\r', 2)
    #"<" waiting
    res = 0
    n = 0
    while n < 10:
        res = MDM.receive(10)
        if res.find(">") > -1:
            break
        else:
            n = n + 1
    #sms text inserting and ctrl+z confirming
    MDM.send(smstext, 2)
    MDM.sendbyte(0x1A, 2)
    #"OK" confirmation waiting
    a = ''
    while a == '':
        a = MDM.receive(20)
    return (a.find('OK') != -1)
Exemple #12
0
def sendSMS(theSmsMsg,theDestination,theTerminator,retry,timeOut):
#This function sends an SMS Message

  # Input Parameter Definitions
  #   theSmsMsg: The text SMS Message
  #   theTerminator: string or character at the end of AT Command
  #   retry:  How many times the command will attempt to retry if not successfully send 
  #   timeOut: number of [1/10 seconds] command could take to respond

  #Note that the 145 being sent in with the destination address is the "type" of destination address, with 145 including a "+" for international
  while (retry != -1):
    print 'AT+CMGS="' + str(theDestination) + '",145'

    res = MDM.send('AT+CMGS="' + str(theDestination) + '",145', 0)
    res = MDM.sendbyte(0x0d, 0)
    res = ATC.mdmResponse('\r\n>', timeOut)
    print res 

    res = MDM.send(theSmsMsg, 0)
    res = MDM.sendbyte(0x1a, 0)

    #Wait for AT command response
    res = ATC.mdmResponse(theTerminator, timeOut)
      
    #Did AT command respond without error?
    pos1 = res.rfind(theTerminator,0,len(res))
    if (pos1 != -1):
      retry = -1
      res = ATC.parseResponse(res)
    else:
      retry = retry - 1
     
    print res

  #If the function fails to find the proper response to the SMS send ('OK<cr><lf>') then we receive a timeout string: 'timeOut'  
  return res
Exemple #13
0
def sendSMS(NUMBER, SMSText):
	TIMEOUT_CMD = 50
	res = scmd.sendCmd('AT+CMGF', '1', TIMEOUT_CMD) # select text format type
	res = scmd.sendCmd('AT+CNMI', '2,1', TIMEOUT_CMD) # alarm indicators
	res = scmd.sendCmd('AT+CSMP', '17,167,0,0', TIMEOUT_CMD) # select message parameter
	res = scmd.sendCmd('AT+CMGS', NUMBER, TIMEOUT_CMD) # send the message without storing it
	if (res.find('>') == -1):
		return -1
	else:
		res = MDM.send(SMSText, 0)
		res = MDM.sendbyte(0x1a, 0)
		for i in range(6):
			res=MDM.read()
			if(res.find("OK")!=-1):
				return 1
			else:
				MOD.sleep(300)
		return -1
Exemple #14
0
def send_CM(inSTR,connId,timeOut):

    if (len(inSTR)==0):
        return 1

    try:

        res = MDM.send('AT#SSEND=' + str(connId) + '\r\n', 0)

        #Start timeout counter        
        timerA = timers.timer(0)
        timerA.start(timeOut)

        prompt = '\r\n> '

        #Start looking for '\r\n>'
        while(1):

            properties.CMD_BUFFER = properties.CMD_BUFFER + MDM.receive(1)      
            pos1 = properties.CMD_BUFFER.find(prompt)   #look for prompt characters
            if (pos1>=0):
                properties.CMD_BUFFER = properties.CMD_BUFFER[0:pos1] + properties.CMD_BUFFER[pos1+len(prompt):len(properties.CMD_BUFFER)]
                res = MDM.send(inSTR, 0)
                res = MDM.sendbyte(0x1a, 0)       

                res = ''
                tmpByte = -1
                while(1):
                    tmpByte = MDM.readbyte()
                    if (tmpByte != -1):
                        res = res + tmpByte

                    if (res.find('\r\nOK\r\n')>=0):
                        return 0
                    if timerA.isexpired():
                        return -2

            if timerA.isexpired():
                return -2

    except:
        printException("send_CM(" + inSTR + "," + connId + "," + timeOut + ")")

    return -3
Exemple #15
0
def send_CM(inSTR,connId,timeOut):

    rtnList = [-1,-1]    #[return status,return data]
    # return status:
    #   -2:    Timeout occurred
    #   -1:    Exception occurred
    #    0:    No errors occurred, no return data
    #    1:    No errors occurred, return data

    if (len(inSTR) == 0):
        rtnList[0] = 0
        return rtnList

    try:

        #Define GPRS Settings, MUST change APN String in script for your Carrier Specific setting
        rtnList = ATC.sendAtCmd('AT#SSEND=' + str(connId),'\r\n> ',180)
        if (rtnList[0] == -1) or (rtnList[0] == -2) or rtnList[1] == "ERROR": return rtnList

        res = mySER.send(inSTR,10)
        res = mySER.sendbyte(0x1a,2)

        #Start timeout counter 
        start = time.time()   

        res = ''
        tmpByte = ''
        while True:
            tmpByte = mySER.readbyte()
            if tmpByte > -1:
                res += chr(tmpByte)

            if (res.find('\r\nOK\r\n')>=0):
                rtnList[0] = 0
                break
            if (time.time() - start) > timeOut:
                rtnList[0] = -2
                break

    except:
        print sys.exc_info()
        rtnList[0] = -1

    return rtnList
def sendAtCmd(theCommand, theTerminator, retry, timeOut):
# This function sends an AT command to the MDM interface

    # Input Parameter Definitions
    #   theCommand: The AT command to send to MDM interface
    #   theTerminator: string or character at the end of AT Command
    #   retry:  How many times the command will attempt to retry if not successfully send 
    #   timeOut: number of [1/10 seconds] command could take to respond

    try:

        #Clear input buffer
        res = "junk"
        while(res != ""):
            res = MDM.receive(1)

        while (retry != -1):
            print 'Sending AT Command: ' + theCommand
            res = MDM.send(theCommand, 0)
            res = MDM.sendbyte(0x0d, 0)

            #Wait for AT command response
            res = mdmResponse(theTerminator, timeOut)

            #Did AT command respond without error?    
            pos1 = res.rfind(theTerminator,0,len(res))
            if (pos1 != -1):
                retry = -1
                res = parseResponse(res)
            else:
                retry = retry - 1

    except:
            print 'Script encountered an exception.'
            print 'Exception Type: ' + str(sys.exc_type)
            print 'MODULE -> ATC' + '\r'
            print 'METHOD -> sendAtCmd(' + theCommand + ',' +theTerminator + ',' + retry + ',' + timeOut + ')' + '\r'

    print res

    return res
Exemple #17
0
def chat(Host,Script,data):

    SER.send('Ready to negotiate with server\r')    
    HTTP_ver = " HTTP/1.0"
    

    res = MDM.send('GET ',0)
    #res = MDM.send(Host,0)
    res = MDM.send(Script,0)
    res = MDM.send(data,0)
    res = MDM.send(HTTP_ver,10)
    res = MDM.sendbyte(0x0d,10)
    res = MDM.sendbyte(0x0a,10)
    res = MDM.send('Host: ',0)
    res = MDM.send(Host,0)
    res = MDM.sendbyte(0x0d,10)
    res = MDM.sendbyte(0x0a,10)
    res = MDM.sendbyte(0x0d,10)
    res = MDM.sendbyte(0x0a,10)

    resc = GetData(180)
    res = MDM.receive(30)
    return resc
Exemple #18
0
import MDM
import MOD
import GPIO

answer = ''
i = 0

# Wait network registration
while answer == -1:
    res = MDM.send('AT+CREG?', 0)
    res = MDM.sendbyte(0x0d, 0)
    answer = (MDM.receive(10)).find('0,1')
    res = MOD.sleep(10)

while answer == -1:
    res = MDM.send('AT+COPS?', 0)
    res = MDM.sendbyte(0x0d, 0)
    answer = (MDM.receive(10)).find('MTS RUS')
    res = MOD.sleep(10)

while i != 40:
    res = GPIO.setIOvalue(7,1)
    res = MOD.sleep(3)
    res = GPIO.setIOvalue(7,0)
    res = MOD.sleep(3)
    i = i + 1

i = 0

def sendEMAIL(theEmailToAddress,theEmailSubject,theEmailBody,theTerminator,userID,userPassword,retry,timeOut):
#This function sends email

  # Input Parameter Definitions
  #   theEmailSubject: The text Email Subject
  #   theEmailBody: The text Email Body
  #   theTerminator: string or character at the end of AT Command
  #   retry:  How many times the command will attempt to retry if not successfully send 
  #   timeOut: number of [1/10 seconds] command could take to respond

    try:

        tmpReturn = -1
            
        while (retry != -1):

            #Activate PDP if needed  
            res = sendAtCmd('AT#SGACT?',properties.CMD_TERMINATOR,0,20) 
            if (res!="#SGACT: 1,1"):
                delaySec(1)
                res = sendAtCmd('AT#SGACT=1,1,"' + str(userID) + '","' + str(userPassword) + '"' ,properties.CMD_TERMINATOR,0,180)
                DEBUG.sendMsg(res + '\r\n',RUN_MODE) 

            if (res=='ERROR'):
                return tmpReturn  

            print 'AT#EMAILD="' + theEmailToAddress + '","' + theEmailSubject + '",0'

            res = MDM.send('AT#EMAILD="' + theEmailToAddress + '","' + theEmailSubject + '",0', 0)
            res = MDM.sendbyte(0x0d, 0)
            res = mdmResponse('\r\n>', timeOut)
            print res 

            res = MDM.send(theEmailBody, 0)
            res = MDM.sendbyte(0x1a, 0)

            #Start timeout counter        
            timerA = timers.timer(0)
            timerA.start(timeOut)

            #Wait for response
            res = ''
            while ((res.find(theTerminator)<=-1) and (res.find("ERROR")<=-1) and (res != 'timeOut')):
                MOD.watchdogReset()
                res = res + MDM.receive(10)
                pass           
                if timerA.isexpired():
                    res = 'timeOut'
                    
            if((res.find("ERROR") > -1) or (res == 'timeOut')):
                retry = retry - 1
            else:
                retry = -1
                tmpReturn = 0                
                
    except:
        print 'Script encountered an exception.'
        print 'Exception Type: ' + str(sys.exc_type)
        print 'MODULE -> ATC'
        print 'METHOD -> sendEMAIL(' + theEmailToAddress + ',' + theEmailSubject + ',' + theEmailBody + ',' +theTerminator + ',' + retry + ',' + timeOut + ')'

    print res
  
    return tmpReturn
Exemple #20
0
def CheckNewSMS():
# This function checks for a new SMS. If one is found it parses the information.
  
    try:

        rtnList = [-1,-1]    #[return status,return data]
        # return status:
        #   -2:    Timeout
        #   -1:    Exception occurred
        #    0:    No errors occurred, no SMS
        #    1:    No errors occurred, return received SMS

        #Now try to list all newly received SMS.
        #Using this method because the sendatcommand method ends up parsing out info we need due to the multiple \r\n response.
        rtnList[1] = MDM.send('AT+CMGL="REC UNREAD"', 0)
        rtnList[1] = MDM.sendbyte(0x0d, 0)
        #Grab the response of the command
        rtnList = ATC.mdmResponse('OK', 10)

        res  = rtnList[1]        
        
        #Try to list all currently stored SMS's. This is just a check to see if we have old/already read messages.
        rtnList[1] = MDM.send('AT+CMGL="ALL"', 0)
        rtnList[1] = MDM.sendbyte(0x0d, 0)
        #Grab the response of the command
        rtnList = ATC.mdmResponse('OK', 10)

        res2 = rtnList[1]        
        
        #Check for messages, search from 0 to the length of the AT Command response
        pos0 = res.find('+CMGL: 1',0,len(res))        
        GeneralCheck = res2.find('+CMGL:',0,len(res2))
        
        if (pos0 != -1):
            #New message found, let's parse the useful information
            #first, let's split the received information so we can echo a response to the originating phone number
            #Below is the normal response we are parsing
            #+CMGL: <index>,<stat>,<oa/da>,<alpha>,<scts><CR><LF><data><CR><LF>
            #+CMGL: 1,"REC UNREAD","+xxxxxxxxxxx","test","12/06/06,15:59:50-20"
            #Data

            #Separate by \r\n to separate the SMS data
            parts1 = res.split('\r\n')

             
            #Now split by comma to get individual data from the main chunk of information
            parts2 = parts1[1].split(",")

            SMSInfo.index = parts2[0]
            SMSInfo.stat = parts2[1]
            SMSInfo.OriginatingPN = parts2[2]
            SMSInfo.alpha = parts2[3]
            SMSInfo.date = parts2[4]
            SMSInfo.time = parts2[5]
            SMSInfo.SMS = parts1[2]

            #Delete ALL SMS to ensure a clear buffer for the next read
            rtnList = ATC.sendAtCmd('AT+CMGD=1,4' ,ATC.properties.CMD_TERMINATOR,5)            

            rtnList[1] = SMSInfo.SMS
            rtnList[0] = 1 #indicate data received

            return rtnList            
        

        #Enter this AT command to ensure the buffer is empty and ready to receive new SMS messages
        if (GeneralCheck != -1):
            rtnList = ATC.sendAtCmd('AT+CMGD=1,4' ,ATC.properties.CMD_TERMINATOR,5)


        rtnList[0] = 0 #No errors, but no data received
        
    except:
        print sys.exc_info()
        rtnList[0] = -1

    return rtnList