本文整理汇总了Python中GPIO.getIOvalue方法的典型用法代码示例。如果您正苦于以下问题:Python GPIO.getIOvalue方法的具体用法?Python GPIO.getIOvalue怎么用?Python GPIO.getIOvalue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GPIO
的用法示例。
在下文中一共展示了GPIO.getIOvalue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SW_IGN_Status
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import getIOvalue [as 别名]
def SW_IGN_Status():
# This function reads the status of the event triggers, then toggles GPIO2 in response to signal the MCU that we received the information.
# We are reading the MCU's signaling because it can poll and latch the states more accurately than directly reading in the python flow.
# This allows less errors when reading the states in real time as well as catching a wake up event.
# Arguments:
# none
#
# Returns:
# 0: Pass, Switch is triggered
# 1: Pass, Ignition is triggered
# 2: Pass, BOTH are triggered
# -1: Exception
# -2: Pass, Neither is triggered
tmpReturn = -1
try:
#GPIO.getIOvalue(GPIOnumber)
# 7 - IIC SDA/IGNITION : Utilizing this as Event Ignition Flag, active LOW
# 8 - IIC SCL/SWITCH : Utilizing this as Event N/O Switch Flag, active LOW
#GPIO.setIOvalue(GPIOnumber, value)
# 10 - GPIO2 : Utilizing this as the event received verification, active HIGH
IgnRead = GPIO.getIOvalue(7)
SwitchRead = GPIO.getIOvalue(8)
if (IgnRead == 0 and SwitchRead == 1): #Ignition Active, based on signal from MCU
res = GPIO.setIOvalue(10, 1)
tmpReturn = 1
elif (IgnRead == 1 and SwitchRead == 0): #Switch Active, based on signal from MCU
res = GPIO.setIOvalue(10, 1)
tmpReturn = 0
elif (IgnRead == 0 and SwitchRead == 0): #Both Active, based on signal from MCU
res = GPIO.setIOvalue(10, 1)
tmpReturn = 2
elif (IgnRead == 1 and SwitchRead == 1): #Neither Active, based on signal from MCU
tmpReturn = -2
if (tmpReturn != -1):
res = GPIO.setIOvalue(10, 0) #Reset the GPIO signaling
except:
printException("SW_IGN Exception")
JANUS_SER.sendUART("SW_IGN Exception \r\n")
#Return value of GPIO get
return tmpReturn
示例2: getSIMSELECT
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import getIOvalue [as 别名]
def getSIMSELECT():
"""Чтение состояния выхода SIMSELECT
Returns:
Состояние
"""
state = GPIO.getIOvalue(5)
return state
示例3: getOUT2
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import getIOvalue [as 别名]
def getOUT2():
"""Чтение состояния реле 2
Returns:
Состояние
"""
state = GPIO.getIOvalue(1)
return state
示例4: getOUT1
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import getIOvalue [as 别名]
def getOUT1():
"""Чтение состояния реле 1
Returns:
Состояние
"""
state = GPIO.getIOvalue(6)
return state
示例5: getSK2
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import getIOvalue [as 别名]
def getSK2():
"""Чтение состояния сухого контакта 2
Returns:
Состояние
"""
state = GPIO.getIOvalue(3)
return state
示例6: getJDR
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import getIOvalue [as 别名]
def getJDR():
"""Чтение состояния входа JD
Returns:
Состояние
"""
state = GPIO.getIOvalue(2)
return state
示例7: transmitMessage
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import getIOvalue [as 别名]
SER.send('Mode is: %s\n' % Config.Mode)
if Config.Mode == 'Active':
transmitMessage(message)
elif Config.Mode == 'Passive':
storeMessage(message)
elif Config.Mode == 'Buffered':
SER.send('Buffered mode, todo!\n')
endTime = MOD.secCounter()
timeSpend = endTime - startTime
sleepTime = Config.Interval - timeSpend
SER.send("Spend: %s, Interval: %s, Sleep: %s\n" % (timeSpend, Config.Interval, sleepTime))
SER.send("GPIO: %s, RTS: %s\n" % (GPIO.getIOvalue(2), SER.getRTS()))
# Sleep, but only if the emergency button isn't set.
if sleepTime > 2 and GPIO.getIOvalue(2) == 0:
SER.send('Going into powerSaving.\n')
MOD.powerSaving(sleepTime)
reason = MOD.powerSavingExitCause()
SER.send("Woke up! Reason (0=ext,1=time): %s\n" % reason)
if reason == 0:
MOD.sleep(20)
elif sleepTime > 0:
SER.send('Idle sleep.\n')
MOD.sleep(10 * sleepTime)
else:
示例8: AutoONControl
# 需要导入模块: import GPIO [as 别名]
# 或者: from GPIO import getIOvalue [as 别名]
def AutoONControl(inCommand, inSelection):
# This function sends a signal to MCU to tell it whether or not to handle Auto On,
# waits for response on GPIO1 to verify the MCU is in the proper state.
# Arguments:
# inCommand - Select what to do, enter 'READ' or 'SET'.
# READ - Checks the MCU signal to verify the mode
# SET - Utilizes inSelection to change the mode.
# inSelection - Select to have the MCU run Auto-On or not, enter 'ON' or 'OFF.
# OFF - Auto-On is Disabled
# ON - Auto-On is Enabled
#
# Returns:
# InCommand: READ
# 0: Pass, Auto-on OFF
# 1: Pass, Auto-on ON
# -1: Exception
# -2: Time out
# InCommand: SET
# 0: Pass, Auto-on OFF
# 1: Pass, Auto-on ON
# -1: Exception
# -2: Time out
tmpReturn = -1
try:
#GPIO.getIOvalue(GPIOnumber)
#MOD.sleep(20) #Delay
# 9 - GPIO1 : Used as MCU signal verification
if (inCommand == 'READ'):
res = GPIO.getIOvalue(9)
return res
#GPIO.setIOvalue(GPIOnumber, value)
# 6 - Auto ON Control
# 9 - GPIO1 : Used as MCU signal verification
if (inSelection == 'ON'):
res = GPIO.setIOvalue(6, 1)
#Set a Timer for a quick loop to verify, we do this because it's a "just in case" breakout as opposed to a simple delay and check.
timerA = timers.timer(0)
timerA.start(5) #5 seconds is MORE than enough.
IoVal = GPIO.getIOvalue(9)
#JANUS_SER.sendUART("Value from MCU: " + str(IoVal) + "\r\n")
while (IoVal != 1):
IoVal = GPIO.getIOvalue(9)
if timerA.isexpired():
return (-2) #Time out while finding the signal
res = GPIO.setIOvalue(6, 0) #End the HIGH pulse, MCU only toggles on a high signal
return IoVal #Return the read value
elif (inSelection == 'OFF'):
res = GPIO.setIOvalue(6, 1)
#Set a Timer for a quick loop to verify, we do this because it's a "just in case" breakout as opposed to a simple delay and check.
timerA = timers.timer(0)
timerA.start(5) #5 seconds is MORE than enough.
IoVal = GPIO.getIOvalue(9)
JANUS_SER.sendUART("Value from MCU: " + str(IoVal) + "\r\n")
while (IoVal != 0):
IoVal = GPIO.getIOvalue(9)
if timerA.isexpired():
return (-2) #Time out while finding the signal
res = GPIO.setIOvalue(6, 0) #End the HIGH pulse, MCU only toggles on a high signal
return IoVal #Return the read value
except:
printException("SW_IGN Exception")
JANUS_SER.sendUART("SW_IGN Exception \r\n")
#Return Error value
return tmpReturn