import os CSb = 6 UDb = 16 PGOOD = 13 class sysfsGpio: def __init__ (self,pin,dir): print "init called" self.dir = dir self.pin = pin self.gpio_root = "/sys/class/gpio/" self.gpio_pin = self.gpio_root + "gpio" + str(self.pin) + "/" print "finished init" return def __del__(self): print "destroying " + self.gpio_pin if os.path.exists(self.gpio_pin) : print "exists" # # railVarRes and batleveltopct need to be defined to cause exception # renamining railVarRes to arailVarRes changes the behavior def batleveltopct(batLevel): return def railVarRes(): return def initPorts(): global udb global csb global pgood # # define constants # INPUT = 0 OUTPUT = 1 # # pgood=sysfsGpio(PGOOD,INPUT) csb=sysfsGpio(CSb,OUTPUT) udb=sysfsGpio(UDb,OUTPUT) # # cs* -> 1 to deselect; USb is don't care # print "initPorts done" return initPorts() print "alldone"