From 783d95962ff31d0e243b4df5ba4aa1c766c063b7 Mon Sep 17 00:00:00 2001 From: mstroh76 Date: Fri, 3 May 2024 15:15:20 +0200 Subject: [PATCH] #224 --- gpio/gpio.c | 3 +-- wiringPi/pseudoPins.c | 22 +++++++++++----------- wiringPi/wiringSerial.c | 4 ++-- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gpio/gpio.c b/gpio/gpio.c index 35a4e62..86b1a42 100644 --- a/gpio/gpio.c +++ b/gpio/gpio.c @@ -610,7 +610,6 @@ void printgpioflush(const char* text) { void printgpio(const char* text) { if (gpioDebug) { printf("%s", text); - fflush(stdout); } } @@ -660,7 +659,7 @@ void doWfi (int argc, char *argv []) exit (1) ; } - printgpio("wait for interrupt function call \n"); + printgpio("wait for interrupt function call\n"); for (int Sec=0; Secdata0; - int myPin = pin - node->pinBase; + int *ptr = (int *)(intptr_t)node->data0; + int myPin = pin - node->pinBase; - *(ptr + myPin) = value; + *(ptr + myPin) = value; } @@ -79,25 +79,25 @@ int pseudoPinsSetup(const int pinBase) node = wiringPiNewNode(pinBase, PSEUDO_PINS); if (node == NULL) { - perror("Error creating new wiringPi node"); - return FALSE; + fprintf(stderr, "Error creating new wiringPi node"); + return FALSE; } node->fd = shm_open(SHARED_NAME, O_CREAT | O_RDWR, 0666); if (node->fd < 0) { - perror("Error opening shared memory"); - return FALSE; + perror("Error opening shared memory"); + return FALSE; } if (ftruncate(node->fd, PSEUDO_PINS * sizeof(int)) < 0) { - perror("Error resizing shared memory"); - return FALSE; + perror("Error resizing shared memory"); + return FALSE; } ptr = mmap(NULL, PSEUDO_PINS * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED, node->fd, 0); if (ptr == MAP_FAILED) { - perror("Error mapping shared memory"); - return FALSE; + perror("Error mapping shared memory"); + return FALSE; } node->data0 = (unsigned int)(uintptr_t)ptr; diff --git a/wiringPi/wiringSerial.c b/wiringPi/wiringSerial.c index c57acb7..40fbad8 100644 --- a/wiringPi/wiringSerial.c +++ b/wiringPi/wiringSerial.c @@ -157,7 +157,7 @@ void serialPutchar(const int fd, const unsigned char c) { ssize_t bytes_written = write(fd, &c, 1); if (bytes_written != 1) { - perror("Error writing to file descriptor"); + perror("Error writing to file descriptor"); } } @@ -173,7 +173,7 @@ void serialPuts(const int fd, const char *s) size_t len = strlen(s); ssize_t bytes_written = write(fd, s, len); if (bytes_written != (ssize_t)len) { - perror("Error writing to file descriptor"); + perror("Error writing to file descriptor"); } }