evilkitty
Posts: 354
Joined: Tue Apr 15, 2014 11:39 pm

Verify that pin GPIO setup value

Wed Apr 18, 2018 11:14 am

Is there a way via software i can make sure that RCpin was infant successfully setup as a input?

Code: Select all

def RCtest (RCpin,limit):
	reading = 0
	GPIO.setup(RCpin, GPIO.OUT)
	GPIO.output(RCpin, 0)
	sleep(0.1)
	GPIO.setup(RCpin, GPIO.IN) # I want to verify this did work
	while (GPIO.input(RCpin) == 0):
		reading += 1
		sleep(0.005)
		if(reading>limit): # improve performance and since upgrading to 3b+ not having this results in a inf loop on occasion
			break
	return reading <= limit
I want to check and see if my issue is my low grade capacitor or a glitch in the 3b+
viewtopic.php?f=66&t=208944&p=1291546#p1291546
since upgrading if i do not use the limit and break in my loop it can take a infinite time to charge the cap, but with the limit this results in a bad reading but the script corrects it self on the next reading
My Pi Server: http://imgur.com/a/6xIUI | Thermostat: http://imgur.com/a/4LVnT

User avatar
joan
Posts: 13459
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Verify that pin GPIO setup value

Wed Apr 18, 2018 11:17 am

wiringPi's gpio utility should have a mode read function.

pigpio's pigs utility has the mg command.

http://abyz.me.uk/rpi/pigpio/pigs.html#MG/MODEG

(needs the pigpio daemon to be running - sudo pigpiod)

evilkitty
Posts: 354
Joined: Tue Apr 15, 2014 11:39 pm

Re: Verify that pin GPIO setup value

Sat Apr 21, 2018 8:46 pm

Code: Select all

def RCtest (RCpin,limit):
	reading = 0
	piwiring.pinMode(RCpin, 1)
	piwiring.digitalWrite(RCpin, 0)
	sleep(1)
	piwiring.pinMode(RCpin, 0)
	while (piwiring.digitalRead(RCpin) == 0):
		reading += 1
		sleep(0.005)
		if(reading>limit):
			with open('/sys/class/gpio/gpio8/direction') as f:
				first_line = f.readline().strip()
				#print first_line
				if first_line == 'out':
					print "ISSUE FOUND"
			break;
	return reading <= limit
I figured another way to do it
Will it check it via the shell GPIO access method, which required:

Code: Select all

echo "8" > /sys/class/gpio/export
I was able to get a ISSUE FOUND print out
this issue happens in both wiringpi and gpio
would this be a bug in the rpi kernel?

Code: Select all

[email protected]:~ $ uname -r
4.9.80-v7+
My Pi Server: http://imgur.com/a/6xIUI | Thermostat: http://imgur.com/a/4LVnT

Return to “Raspbian”

Who is online

Users browsing this forum: No registered users and 19 guests