当前位置: 首页>>代码示例>>Python>>正文


Python GPIO.setIOdir方法代码示例

本文整理汇总了Python中GPIO.setIOdir方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.setIOdir方法的具体用法?Python GPIO.setIOdir怎么用?Python GPIO.setIOdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GPIO的用法示例。


在下文中一共展示了GPIO.setIOdir方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: checkCon

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
def checkCon(pin):
    a = SER.send('DEBUG: Now in checkCon...\r\n')
    #print '\r\ncheckCon PIN:',pin
    res = MDM2.send('AT+CREG?\r',0)
    res = MDM2.receive(30)
    b = SER.send('DEBUG: following is result from AT+CREG?\r\n')
    c = SER.send(res);
    if ( (res.find('0,1') > -1)  or (res.find('0,5')  > -1 ) ):
        return 1

    ret = ''
    ret = setPin(pin)
    if ( ret != 1 ):
        GPIO.setIOdir(19,1,1)
        return -1 

    timer = MOD.secCounter() + 120
    while ( (res.find('0,1') == -1)  and  (res.find('0,5')  == -1 ) ):
        res = MDM2.send('AT+CREG?\r',0)
        res = MDM2.receive(20)
        b = SER.send('DEBUG: following is result from AT+CREG?\r\n')
        c = SER.send(res);
        if ( MOD.secCounter() > timer ):
            return -1
        MOD.sleep(50)
    MOD.sleep(20)
    return 1 
开发者ID:ehwest,项目名称:unapy,代码行数:29,代码来源:telittest.py

示例2: toggleGPIO

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
def toggleGPIO(id,z_on,z_off,anz):
    ra = ''
    while anz > 0:
        ra = GPIO.setIOdir(id,1,1)
        MOD.sleep(z_on)
        ra = GPIO.setIOdir(id,0,1)
        MOD.sleep(z_off)
        # flash continusly
        if ( anz != 99 ):
            anz = anz - 1
    return ra
开发者ID:ehwest,项目名称:unapy,代码行数:13,代码来源:telittest.py

示例3: init

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
def init():
    # This function initializes the IO
    #   Arguments:
    #   None
    #
    
    
    #GPIO Connections:
    #    1 - Cellular LED
    #    2 - GPS LED (User LED)

    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
        
        #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(1, 0, 2)  #Output, Alternate Function
        b = GPIO.setIOdir(2, 0, 1)  #Output, LOW (LED OFF)

        if (    a == -1
            or b == -1
            ):
            return rtnList    #Errored out
            

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

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


    return rtnList
开发者ID:JanusRC,项目名称:Python,代码行数:43,代码来源:IO_HE910.py

示例4: initGPS

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
def initGPS (speed,format):
    
    try:

        #GPS RESET, GPIO 18 configured as Output, value is Cleared to '0'
        #GPS held in RESET
        GPIO.setIOdir(18,1,1)
        
        #GPS RESET, GPIO 18 configured as Output, value is Cleared to '0'
        #GPS is running
        GPIO.setIOvalue(18, 0)
        
        #Init Serial Port Settings
        res = GSM864QP_SER.init_parameters(speed,format)
        MOD.sleep(10)
        
        res = GSM864QP_SER.send_50PIN('\r\n')

        #Disable all NMEA output sentences
        #NMEA GPS sentences will only transmit when polled by CW20.update() method
        res = GSM864QP_SER.send_50PIN('$PNMRX103,ALL,0\r\n')
        
        ## Start timeout timer            
        CW20_timerA = timers.timer(0)
        CW20_timerA.start(2)  

        # Empty Serial Port Buffer
        res = "junk"
        while(res != ""):
            res = GSM864QP_SER.read_50PIN()
            if (CW20_timerA.isexpired()):
                break

    except:
        print 'Script encountered an exception.'
        print 'Exception Type: ' + str(sys.exc_type)
        print 'MODULE -> CW20'
        print 'METHOD -> initGPS(' + speed + ',' + format + ')'

    return
开发者ID:jacobhartsoch,项目名称:janus_http_gateway,代码行数:42,代码来源:CW20.py

示例5: init_parameters

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
def init_parameters (speed,format):

    try:

        ## ########################################################################################################      
        ## Take control of UART_SEL input
        ## Warning don't externaly drive the UART_SEL input via 50-PIN header when controlling via this script!!!!
        ## ########################################################################################################

        #MUX SELECT, GPIO 20 configured as Output, value is Set to '1'
        #DB9 connected to SER MODULE
        GPIO.setIOdir(20,1,1)

        #Init Serial Port Settings
        res = SER.set_speed(speed,format)

    except:
        print 'Script encountered an exception.'
        print 'Exception Type: ' + str(sys.exc_type)
        print 'MODULE -> GSM864QP_SER'
        print 'METHOD -> init_parameters(' + speed + ',' + format + ')'

    return (res)
开发者ID:jacobhartsoch,项目名称:janus_http_gateway,代码行数:25,代码来源:GSM864QP_SER.py

示例6: init

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
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
开发者ID:JanusRC,项目名称:Python,代码行数:74,代码来源:JANUS_IO.py

示例7: get_status

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
        count = get_status()
        if count == 3:
            SER.send("Maximum of reboots reached.\r\nIt all worked well... is not it marvelous\r\n")
            posix.unlink("status") 
            sys.exit(0)
    except Exception, value:
        SER.send("Exception error" + str(value) + "\r\n")

    #Init the HW WD
    time.sleep(1)        
    SER.send('Watchdog try : %d\r\n' % (count+1))
    SER.send('Waiting for module to be become fully operational (after boot)\r\n')
    time.sleep(20)          # wait for the module to be fully operational

    SER.send('Enable the Watch Dog\r\n')
    GPIO.setIOdir(8, 1, 1)  # GPIO8 in the HX910 unit is used for HW WD
    time.sleep(2)
    GPIO.setIOvalue(8, 0)
    # Hardware watch should be enabled now.
    SER.send('Hardware watch should be enabled now.\r\n')

    # Start the test loop. Keep the watchdog untouched so it will kick in roughly
    # after 90 seconds.
    SER.send('Entering 2 minute loop.\r\n')
    SER.send('Watchdog should kick in after 90 seconds or so.\r\n')
    for count in range(120):
        time.sleep(1)
        SER.send('Still alive, count is at %s second(s)\r\n' % (count+1))

    SER.send("It didn't work, something is wrong. Adios\r\n")
开发者ID:HansKramer,项目名称:TelitEasyScript,代码行数:32,代码来源:WatchDogTest2.py

示例8: setGPIO

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
def setGPIO(id,d):
    a = GPIO.setIOdir(id,1,d)
    return a
开发者ID:ehwest,项目名称:unapy,代码行数:5,代码来源:telittest.py

示例9: initIO

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
def initIO():
    """Инициализация линий ввода-вывода
    """
    SER2.set_speed('115200')
    # 0 - input, 1 - output, 2 - alt
    GPIO.setIOdir(4, 0, 0) # SK1
    GPIO.setIOdir(3, 0, 0) # SK2
    GPIO.setIOdir(6, 0, 1) # RELE1
    GPIO.setIOdir(1, 0, 1) # RELE2
    GPIO.setIOdir(5, 0, 1) # SIM_SELECT
    GPIO.setIOdir(2, 0, 2) # JDR
开发者ID:teleofis,项目名称:Locker,代码行数:13,代码来源:RX_API.py

示例10: initGPIO

# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import setIOdir [as 别名]
def initGPIO():
    GPIO.setIOdir(5, 0, 1)
开发者ID:teleofis,项目名称:RX608SimSwitcher,代码行数:4,代码来源:switcher.py


注:本文中的GPIO.setIOdir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。