diff options
| author | kutayboz <kutayboz@gmail.com> | 2023-08-01 04:59:34 +0300 |
|---|---|---|
| committer | kutayboz <kutayboz@gmail.com> | 2023-08-01 04:59:34 +0300 |
| commit | ac5fcc1e3a873e61dba138e5b632479141433614 (patch) | |
| tree | 7dde6438be4ad95ba924d14b82c63b874221f82c /src/gpio.c | |
| parent | a29985e3dc53f832511ef7eadb0bcb64afd8520d (diff) | |
| download | celnetmon-ac5fcc1e3a873e61dba138e5b632479141433614.tar.gz | |
Primitive config file implementation
Diffstat (limited to 'src/gpio.c')
| -rw-r--r-- | src/gpio.c | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/src/gpio.c b/src/gpio.c deleted file mode 100644 index fd46fc7..0000000 --- a/src/gpio.c +++ /dev/null @@ -1,79 +0,0 @@ -#include <gpiod.h> -#include <stdio.h> -#include <unistd.h> - -int modemPowerToggle(char *pathToChip, int pinNum) { - struct gpiod_chip *chip; - struct gpiod_line *line; - - chip = gpiod_chip_open(pathToChip); - if (!chip) { - perror("Error opening GPIO chip"); - return 1; - } - - line = gpiod_chip_get_line(chip, pinNum); - if (!line) { - perror("Error getting GPIO line"); - gpiod_chip_close(chip); - return 1; - } - - if (gpiod_line_request_output(line, "cellular modem power toggle", 0) < 0) { - perror("Error setting GPIO line as output"); - gpiod_chip_close(chip); - return 1; - } - - if (gpiod_line_set_value(line, 1) < 0) { - perror("Error setting GPIO line high"); - gpiod_chip_close(chip); - return 1; - } - - sleep(1); - - if (gpiod_line_set_value(line, 0) < 0) { - perror("Error setting GPIO line low"); - gpiod_chip_close(chip); - return 1; - } - - gpiod_chip_close(chip); - return 0; -} - -int checkPinVal(char *pathToChip, int pinNum) { - int pinVal = -1; - struct gpiod_chip *chip; - struct gpiod_line *line; - - chip = gpiod_chip_open(pathToChip); - if (!chip) { - perror("Error opening GPIO chip"); - return -1; - } - - line = gpiod_chip_get_line(chip, pinNum); - if (!line) { - perror("Error getting GPIO line"); - gpiod_chip_close(chip); - return -1; - } - - if (gpiod_line_request_input(line, "cellular modem power status") < 0) { - perror("Error setting GPIO line as input"); - gpiod_chip_close(chip); - return -1; - } - - pinVal = gpiod_line_get_value(line); - if (pinVal < 0) { - perror("Error getting GPIO line value"); - gpiod_chip_close(chip); - return -1; - } - - gpiod_chip_close(chip); - return pinVal; -} |
