Skip to content
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

Increase buffer for GPIO pin number (#29) #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static int sleep_usec(int32_t usec) {

// Start working with specific pin.
static int gpio_export(int port, Pin *pin, Error **err) {
#define BUFFER_MAX 3
#define BUFFER_MAX 6
char buffer[BUFFER_MAX];
ssize_t bytes_written;
int fd;
Expand Down Expand Up @@ -165,7 +165,7 @@ static int gpio_export(int port, Pin *pin, Error **err) {
// Sleep 150 milliseconds
// sleep_usec(150*1000);

#define DIRECTION_MAX 35
#define DIRECTION_MAX 36
char path1[DIRECTION_MAX];
snprintf(path1, DIRECTION_MAX, "/sys/class/gpio/gpio%d/direction", pin->pin);
pin->fd_direction = open(path1, O_WRONLY|O_SYNC|O_RSYNC);
Expand All @@ -174,7 +174,7 @@ static int gpio_export(int port, Pin *pin, Error **err) {
return -1;
}

#define VALUE_MAX 30
#define VALUE_MAX 32
char path2[VALUE_MAX];
snprintf(path2, VALUE_MAX, "/sys/class/gpio/gpio%d/value", pin->pin);
pin->fd_value = open(path2, O_RDWR|O_SYNC|O_RSYNC);
Expand Down