02-21-2017, 04:00 AM
I use Pine64 A64-DB-Rev B board and Debian Jessie.
I need read some GPIO pins (69 and 233 on RPI connector) using sysfs. I use pullup resistors (10k) to 3.3v. Measure voltage on these pins. I get 3 v.
Set direction to 'in'.
But, reading /sys/class/gpio/gpioXX/value i always got 0 !
If switch direction to out, then back to in, reading get 1 !
Simple script to test:
PS: Sorry for my bad english, my native language is Russian
I need read some GPIO pins (69 and 233 on RPI connector) using sysfs. I use pullup resistors (10k) to 3.3v. Measure voltage on these pins. I get 3 v.
Set direction to 'in'.
But, reading /sys/class/gpio/gpioXX/value i always got 0 !
If switch direction to out, then back to in, reading get 1 !
Simple script to test:
Code:
#!/bin/sh
SYSFSDIR=/sys/class/gpio
DOOR_PIN=69
UPLVLPIN=233
setup(){
if [ ! -d $SYSFSDIR/gpio$1 ] ; then
echo $1 > $SYSFSDIR/export
fi
# If comment out these 2 lines - always read 0 !
echo 'out' > $SYSFSDIR/gpio$1/direction
echo 'in' > $SYSFSDIR/gpio$1/direction
}
gpio_read(){
cat $SYSFSDIR/gpio$1/value
}
setup $DOOR_PIN
setup $UPLVLPIN
case "$1" in
door)
gpio_read $DOOR_PIN
;;
uplevel)
gpio_read $UPLVLPIN
;;
*)
usage
;;
esac
PS: Sorry for my bad english, my native language is Russian