Skip to content

Commit 8e64f67

Browse files
committed
convert fprintf() to syslog() for #178
1 parent 0740f75 commit 8e64f67

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

source/common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ int uboot_overlay_enabled(void) {
554554
file = popen(cmd, "r");
555555
if (file == NULL) {
556556
fprintf(stderr, "error: uboot_overlay_enabled() failed to run cmd=%s\n", cmd);
557+
syslog(LOG_ERR, "libadafruit-bbio: error: uboot_overlay_enabled() failed to run cmd=%s\n", cmd);
557558
return -1;
558559
}
559560
uboot_overlay = fgetc(file);
@@ -577,6 +578,7 @@ int pocketbeagle(void) {
577578
file = popen(cmd, "r");
578579
if (file == NULL) {
579580
fprintf(stderr, "error: pocketbeagle() failed to run cmd=%s\n", cmd);
581+
syslog(LOG_ERR, "libadafruit-bbio: error: pocketbeagle() failed to run cmd=%s\n", cmd);
580582
return -1;
581583
}
582584
pocketbeagle = fgetc(file);
@@ -604,6 +606,7 @@ int beaglebone_blue(void) {
604606
file = popen(cmd, "r");
605607
if (file == NULL) {
606608
fprintf(stderr, "error: beaglebone_blue() failed to run cmd=%s\n", cmd);
609+
syslog(LOG_ERR, "libadafruit-bbio: error: beaglebone_blue() failed to run cmd=%s\n", cmd);
607610
return -1;
608611
}
609612
blue = fgetc(file);

source/event_gpio.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ int open_value_file(unsigned int gpio)
196196
if ((gpio >= USR_LED_GPIO_MIN) && (gpio <= USR_LED_GPIO_MAX)) {
197197
snprintf(filename, sizeof(filename), "/sys/class/leds/beaglebone:green:usr%d/brightness", gpio - USR_LED_GPIO_MIN);
198198
} else if (beaglebone_blue()) {
199-
fprintf(stderr, "gpio open_value_file: beaglebone_blue() is true\n");
199+
syslog(LOG_DEBUG, "libadafruit-bbio: gpio open_value_file: beaglebone_blue() is true\n");
200200
switch(gpio) {
201201
case USR_LED_RED:
202202
snprintf(filename, sizeof(filename), "/sys/class/leds/red/brightness");
@@ -224,10 +224,10 @@ int open_value_file(unsigned int gpio)
224224
break;
225225
}
226226
} else {
227-
fprintf(stderr, "gpio open_value_file: default gpio path\n");
227+
syslog(LOG_DEBUG, "libadafruit-bbio: gpio open_value_file: default gpio path\n");
228228
snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/value", gpio);
229229
}
230-
fprintf(stderr, "gpio open_value_file: filename=%s\n", filename);
230+
syslog(LOG_DEBUG, "libadafruit-bbio: gpio open_value_file: filename=%s\n", filename);
231231

232232
// if(gpio == USR_LED_RED) { // red LED
233233
// snprintf(filename, sizeof(filename), "/sys/class/leds/red/brightness");
@@ -302,7 +302,6 @@ BBIO_err gpio_set_direction(unsigned int gpio, unsigned int in_flag)
302302
)
303303
)
304304
{
305-
fprintf(stderr, "gpio_set_direction: %u not applicable to the USR LED\n", gpio);
306305
syslog(LOG_DEBUG, "gpio_set_direction: %u not applicable to the USR LED", gpio);
307306
return BBIO_OK; // direction is not applicable to the USR LED pins
308307
}
@@ -370,25 +369,6 @@ BBIO_err gpio_set_value(unsigned int gpio, unsigned int value)
370369
char filename[MAX_FILENAME];
371370
char vstr[10];
372371

373-
if(uboot_overlay_enabled()) {
374-
//syslog(LOG_DEBUG, "libadafruit-bbio: uboot_overlay_enabled() is true");
375-
fprintf(stderr, "gpio_set_value: uboot_overlay_enabled() is true\n");
376-
} else {
377-
fprintf(stderr, "gpio_set_value: uboot_overlay_enabled() is FASLE\n");
378-
}
379-
380-
if(pocketbeagle()) {
381-
fprintf(stderr, "gpio_set_value: pocketbeagle() is true\n");
382-
} else {
383-
fprintf(stderr, "gpio_set_value: pocketbeagle() is FASLE\n");
384-
}
385-
386-
if(beaglebone_blue()) {
387-
fprintf(stderr, "gpio_set_value: beaglebone_blue() is true\n");
388-
} else {
389-
fprintf(stderr, "gpio_set_value: beaglebone_blue() is FALSE\n");
390-
}
391-
392372
if ((gpio >= USR_LED_GPIO_MIN) && (gpio <= USR_LED_GPIO_MAX)) {
393373

394374
char *usr_led_trigger[] = { "heartbeat", "mmc0", "cpu0", "mmc1" };

0 commit comments

Comments
 (0)