Hello friends,
I am having trouble utilizing GPIO pin 22 on the Xavier 40-pin header to read a digital sensor input. Here is the code I am using:
#!/usr/bin/env python3
import time
from std_msgs.msg import Bool
import Jetson.GPIO as GPIO
gpio_pin = 22
def sensorCallback(channel):
if GPIO.input(channel):
response = True
print("true")
else:
response = False
print("false")
def main():
sensorCallback(gpio_pin)
try:
while True:
time.sleep(0.1)
except KeyboardInterrupt:
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
print("Setup GPIO pin as input on pin {0}".format(gpio_pin))
GPIO.setup(gpio_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(gpio_pin, GPIO.BOTH, callback=sensorCallback, bouncetime=200)
if __name__=="__main__":
main()
Here is the output when that code is run:
Setup GPIO pin as input on pin 22
/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.15-py3.6.egg/Jetson/GPIO/gpio.py:370: UserWarning: Jetson.GPIO ignores setup()'s pull_up_down parameter
false
When I toggle the sensor, it should post true, false, true, false, etc.
One of the main things that is really confusing me is that I tried running this on a different Xavier, and it works totally fine. It outputs true and false as I toggle the sensor. However, using an identical configuration on the other Xavier yields no feedback. The Xavier it doesn’t work on is running Jetpack Version R32 Revision 2.0, but it does work on the one running Jetpack Version R32 Revision 4.4.
Any help or guidance would be sincerely appreciated!
Best,
Alex