static int write_machine_id(const char *path, char id[SOL_STATIC_ARRAY_SIZE(33)]) { SOL_NULL_CHECK(path, -EINVAL); /* add trailing '\n' */ return sol_util_write_file(path, "%s\n", id); }
static int _mux_init(void) { //Try to detect the Arduino Breakout if (sol_util_write_file("/sys/class/gpio/export", "214") >= 0) { ardu_breakout = true; apply_mux_desc(init_board, MODE_GPIO); } return 0; }
static int _set_gpio(int pin, enum sol_gpio_direction dir, int drive, bool val) { int ret = 0; int len; struct stat st; char path[PATH_MAX]; struct sol_gpio *gpio; const char *drive_str; struct sol_gpio_config gpio_config = { 0 }; gpio_config.dir = dir; gpio_config.out.value = val; gpio = sol_gpio_open_raw(pin, &gpio_config); if (!gpio) return -EINVAL; // Drive: // This is not standard interface in upstream Linux, so the // Linux implementation of sol-gpio doesn't handle it, thus the need // to set it here manually // // Not all platforms will have this (this will move in the future) // so its no problem to fail the if bellow len = snprintf(path, sizeof(path), BASE "/gpio%d/drive", pin); if (len < 0 || len > PATH_MAX || stat(path, &st) == -1) goto err; switch (drive) { case GPIO_DRIVE_PULLUP: drive_str = "pullup"; break; case GPIO_DRIVE_PULLDOWN: drive_str = "pulldown"; break; case GPIO_DRIVE_HIZ: drive_str = "hiz"; break; default: drive_str = "strong"; } ret = sol_util_write_file(path, "%s", drive_str); err: sol_gpio_close(gpio); return ret; }