-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add cubieboard support #14
base: master
Are you sure you want to change the base?
Conversation
@@ -74,6 +76,13 @@ | |||
EDGES = (RISING, FALLING, BOTH) | |||
ACTIVE_LOW_MODES = (ACTIVE_LOW_ON, ACTIVE_LOW_OFF) | |||
|
|||
def GetGpioDirFromPin(number): |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
@@ -198,7 +207,7 @@ def _sysfs_gpio_value_path(self): | |||
@rtype: str | |||
@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 |
There was a problem hiding this comment.
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.
@@ -74,6 +76,13 @@ | |||
EDGES = (RISING, FALLING, BOTH) | |||
ACTIVE_LOW_MODES = (ACTIVE_LOW_ON, ACTIVE_LOW_OFF) | |||
|
|||
def GetGpioDirFromPin(number): | |||
ds = listdir(SYSFS_BASE_PATH) | |||
nd = filter(lambda a: a.startswith("gpio" + str(number)),ds) |
There was a problem hiding this comment.
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?
i modify some place to add support for cubieboard