Skip to content

Conversation

@yanzixiang
Copy link

i modify some place to add support for cubieboard

@yanzixiang yanzixiang mentioned this pull request Nov 30, 2016
EDGES = (RISING, FALLING, BOTH)
ACTIVE_LOW_MODES = (ACTIVE_LOW_ON, ACTIVE_LOW_OFF)

def GetGpioDirFromPin(number):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project is following snake case. Rename the function to _sysfs_gpio_pin_path (see more below).

if len(nd) > 0:
return nd[0]
else:
return "DONOT"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd not return a bogus string. Raising an exception would work much better.

@return: the path to sysfs value file
"""
return SYSFS_GPIO_VALUE_PATH % self.number
return SYSFS_BASE_PATH + "/" + GetGpioDirFromPin(self.number) + SYSFS_GPIO_VALUE_PATH
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a function _sysfs_gpio_pin_path that returns the absolute GPIO path, which would avoid repeating SYSFS_BASE_PATH everywhere.


def GetGpioDirFromPin(number):
ds = listdir(SYSFS_BASE_PATH)
nd = filter(lambda a: a.startswith("gpio" + str(number)),ds)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does ds and nd mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants