def ResetIOT_HW(cls, bMode):
"""Set Raspberry pi GPIO pins and reset RF Explorer device
Parameters:
bMode -- True if the baudrate is set to 500000bps, False to 2400bps
"""
try:
import RPi.GPIO as GPIO
#print("RPi info: " + str(GPIO.RPI_INFO)) #information about your RPi:
#print("RPi.GPio version: " + GPIO.VERSION) #version of RPi.GPIO:
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD) #refer to the pin numbers on the P1 header of the Raspberry Pi board
GPIO.setup(12, GPIO.OUT) #set /reset (pin 12) to output
GPIO.output(12, False) #set /reset (pin 12) to LOW
GPIO.setup(21, GPIO.OUT) #set GPIO2 (pin 21) to output
GPIO.output(21, bMode) #set GPIO2 (pin 21) to HIGH (for 500Kbps)
time.sleep(0.1) #wait 100ms
GPIO.output(12, True) #set /reset to HIGH
time.sleep(2.5) #wait 2.5sec
GPIO.setup(21, GPIO.IN) #set GPIO2 to input
GPIO.cleanup() #clean up GPIO channels
except RuntimeError:
print("Error importing RPi.GPIO! This is probably because you need superuser privileges. You can achieve this by using 'sudo' to run your script")
评论列表
文章目录