Beispiel #1
0
def Cellular_LED(inSLED):
    # This function sets the cellular LED
    #   Arguments:
    #   inStatus : GPS LED status. Pass in either 'ON' or 'OFF'
    #       OFF - LED always OFF
    #       ON - LED function ON
    #
    #   Returns:
    #    0: Pass
    #   -1: Exception
    
    tmpReturn = -1

    try:
        
        #Set Stat LED to default value, 0 for OFF, 2 for ON
        if (inSLED == 'ON'):
            res = GPIO.setSLED(2, 10, 90)
        else:
            res = GPIO.setSLED(0, 10, 90)

        res = ATC.sendAtCmd('AT#SLEDSAV',ATC.properties.CMD_TERMINATOR,0,20)
        if (res == -1): #Errored out, 1 if no error -1 if error
            return tmpReturn
            

        tmpReturn = 0        

    except:
        printException("Cellular_LED")
        JANUS_SER.sendUART("GPS LED exception. \r\n")  


    return tmpReturn
Beispiel #2
0
def Cellular_LED(inSLED):
    # This function sets the cellular LED
    #   Arguments:
    #   inStatus : GPS LED status. Pass in either 'ON' or 'OFF'
    #       OFF - LED always OFF
    #       ON - LED function ON
    #


    try:

        rtnList = [-1,-1]    #[return status,return data]
        # return status:
        #   -1:    Exception occurred
        #    0:    No errors occurred, no return data
        #    1:    No errors occurred, return data        
        
        #Set Stat LED to default value, 0 for OFF, 2 for ON
        if (inSLED == 'ON'):
            rtnList[1] = GPIO.setSLED(2, 10, 90)
        else:
            rtnList[1] = GPIO.setSLED(0, 10, 90)

        if (rtnList[1] == -1): #Errored out
            return rtnList            

        rtnList = myATC.sendAtCmd('AT#SLEDSAV',myATC.properties.CMD_TERMINATOR,0,20)
        if (rtnList[1] == -1): #Errored out
            return rtnList
            

        rtnList[0] = 0  #no error, no data  

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


    return rtnList
Beispiel #3
0
def init(inSLED):
    # This function initializes the IO
    #   Arguments:
    #   inSLED : Stat LED. Pass in either 'ON' or 'OFF'
    #       OFF - LED always OFF
    #       ON - LED follows registration status
    #   
    #
    #   Returns:
    #    0: Pass
    #   -1: Exception

    #GPIO Connections:
    #    1 - Do not utilize (Required by GPS)
    #    2 - IGNITION, LOW when ignition is active
    #    3 - N/O Switch, HIGH when the switch is closed
    #    4 - Do not utilize (Required by GPS)
    #    5 - GPS LED (User LED)
    #    6 - Auto ON Control, pulse HIGH to toggle the MCU's operative state. use GPIO1 to verify the state
    #    7 - IIC SDA : Utilizing this as Wake up Event Ignition Flag. Pulled high externally
    #    8 - IIC SCL : Utilizing this as Wake up Event N/O Switch Flag. Pulled high externally
    #    9 - GPIO1 : Utilizing this for Auto-On Verification FROM the MCU, 1 for auto-on enabled, 0 for auto-on disabled
    #    10 - GPIO2 : Utilizing this for Wake up Event verification TO the MCU, 1 if Event has been seen/recorded, otherwise 0.

    
    tmpReturn = -1

    try:
        
        #Set Stat LED to default value, 0 for OFF, 2 for ON
        if (inSLED == 'ON'):
            res = GPIO.setSLED(2, 10, 90)
        else:
            res = GPIO.setSLED(0, 10, 90)

        if (res == -1): #Errored out, 1 if no error -1 if error
            return tmpReturn
        
        #Now set all used GPIO to proper states.
        #GPIO.setIOvalue(GPIOnumber, value)
        #We do not need the above command, setIODir works best for this.
        #GPIO.setIOdir(number, value, direction)
        
        a = GPIO.setIOdir(2, 0, 0)  #Input
        b = GPIO.setIOdir(3, 0, 0)  #Input
        c = GPIO.setIOdir(5, 0, 1)  #Output, LOW (LED OFF)
        d = GPIO.setIOdir(6, 1, 0)  #Output, LOW (Auto-on OFF during INIT, taken care of in the command flow)
        e = GPIO.setIOdir(7, 0, 0)  #Input
        f = GPIO.setIOdir(8, 0, 0)  #Input
        g = GPIO.setIOdir(9, 0, 0)  #Input
        h = GPIO.setIOdir(10, 0, 1)  #Output, LOW (Wake up Event verification default sate, event NOT found)

        if (    a == -1
            or b == -1
            or c == -1
            or d == -1
            or e == -1
            or f == -1
            or g == -1
            or h == -1
            ):
            return tmpReturn    #Errored out, 1 if no error -1 if error
            

        tmpReturn = 0        

    except:
        printException("IO_init")
        JANUS_SER.sendUART("IO Init exception. \r\n")  


    return tmpReturn
Beispiel #4
0
## file=blink_led.py, exec=1, start=2

import GPIO

res = GPIO.setSLED(3,50,20)
Beispiel #5
0
 return frase

try:
    MOD.watchdogEnable(1000)
    salir_prog=0
    #activar SMS AT RUN para telefonos que empiecen por +34:
    res=enviarAT('at+cmgf=1',20,'+CMGF: 1')
    res=enviarAT('at#smsmode=1',30,'OK')
    res=enviarAT('at#smsatwl=0,1,0',"+34*",20,'OK')
    res=enviarAT('at#smsatruncfg=3,1,5',20,'OK')
    res=enviarAT('at#smsatrun=1',30,'OK')
    while (salir_prog==0):
     res = SER.set_speed('9600')
     if (debug==1):
      res=SER.send('\rIniciando programa\r')
     GPIO.setSLED(0, 10, 10)
     linea=GetLineaDesdeSerial(60*20)
     GPIO.setSLED(1, 10, 10)
     IniciarModem()
     GPIO.setSLED(3, 5, 5)
     envio_ok=EnviarDatosMET(CodificarParaGET(linea))
     res=enviarAT('at',10,'OK')
     if (envio_ok==1):
      MOD.watchdogReset()
      if (debug==1):
       res=enviarAT('at#gdatavol=1',10,'#GDATAVOL:')
     if (envio_ok!=1):
      salir_prog=1
      if (debug==1):
       res = SER.send('\r\nFin del programa')
     GPIO.setSLED(3, 10, 10)