mirror of
https://github.com/Hamlib/Hamlib
synced 2026-08-13 17:32:05 -04:00
Make sure to unexport the GPIO port during close
https://github.com/Hamlib/Hamlib/issues/1316
This commit is contained in:
parent
97811d2aa7
commit
efb567f667
1 changed files with 22 additions and 1 deletions
23
src/gpio.c
23
src/gpio.c
|
|
@ -99,7 +99,28 @@ int gpio_open(hamlib_port_t *port, int output, int on_value)
|
|||
|
||||
int gpio_close(hamlib_port_t *port)
|
||||
{
|
||||
return close(port->fd);
|
||||
int retval;
|
||||
char pathname[HAMLIB_FILPATHLEN * 2];
|
||||
FILE *fexp;
|
||||
|
||||
retval = close(port->fd);
|
||||
|
||||
SNPRINTF(pathname, HAMLIB_FILPATHLEN, "/sys/class/gpio/unexport");
|
||||
fexp = fopen(pathname, "w");
|
||||
|
||||
if (!fexp)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"Export GPIO%s (using %s): %s\n",
|
||||
port->pathname,
|
||||
pathname,
|
||||
strerror(errno));
|
||||
return -RIG_EIO;
|
||||
}
|
||||
|
||||
fprintf(fexp, "%s\n", port->pathname);
|
||||
fclose(fexp);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue