* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <unistd.h>
if (exported)
return 0; /* Already exported. */
+ status = sr_gpio_set_direction(gpio, GPIO_DIR_OUT);
+ if (status < 0)
+ return status;
+
buf = g_string_sized_new(16);
g_string_printf(buf, "%u\n", gpio);
status = open_and_write("/sys/class/gpio/export", buf->str);
status = fscanf(fd, "%d", &ret);
fclose(fd);
if (status != 1) {
- sr_err("Error reading from %s: %s", path, g_strerror(errno));
+ sr_err("Error reading from %s: %s", path->str, g_strerror(errno));
g_string_free(path, TRUE);
return -1;
}
if (status < 0)
return status;
- status = sr_gpio_set_direction(gpio, GPIO_DIR_OUT);
- if (status < 0)
- return status;
-
status = sr_gpio_set_value(gpio, value);
if (status < 0)
return status;
if (status < 0)
return status;
- status = sr_gpio_set_direction(gpio, GPIO_DIR_IN);
- if (status < 0)
- return status;
-
return sr_gpio_get_value(gpio);
}