Skip to content

Commit

Permalink
Increase buffer for GPIO pin number (d2r2#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
thkukuk committed Jan 28, 2023
1 parent 4ba9662 commit 52b6d01
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 52b6d01

Please sign in to comment.