crelay: backport patch for use gpio >255 14094/head
authorPawel Dembicki <paweldembicki@gmail.com>
Tue, 3 Nov 2020 12:46:46 +0000 (13:46 +0100)
committerPawel Dembicki <paweldembicki@gmail.com>
Tue, 1 Dec 2020 11:59:19 +0000 (12:59 +0100)
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
utils/crelay/Makefile
utils/crelay/patches/011-support-gpio-with-number-bigger-than-255.patch [new file with mode: 0644]

index 6683f291dc23971d44f4ad94f69f3dc49cbd3db4..283181bbfe873e3da9fcb37de37e52e3aedbb4df 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=crelay
 PKG_VERSION:=0.14
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/ondrej1024/crelay/tar.gz/V$(PKG_VERSION)?
diff --git a/utils/crelay/patches/011-support-gpio-with-number-bigger-than-255.patch b/utils/crelay/patches/011-support-gpio-with-number-bigger-than-255.patch
new file mode 100644 (file)
index 0000000..dbc4433
--- /dev/null
@@ -0,0 +1,92 @@
+From 30a2323bc0a95cda4eca818fe1d523a2e5c031f3 Mon Sep 17 00:00:00 2001
+From: Pawel Dembicki <paweldembicki@gmail.com>
+Date: Mon, 2 Nov 2020 14:50:34 +0100
+Subject: [PATCH] support gpio with number bigger than 255
+
+Change 8-bit gpio value to 16-bit, which allow to use gpio >255.
+
+Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
+---
+ src/data_types.h     | 16 ++++++++--------
+ src/relay_drv_gpio.c | 10 +++++-----
+ 2 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/src/data_types.h b/src/data_types.h
+index f13baeb..d4dc7b1 100644
+--- a/src/data_types.h
++++ b/src/data_types.h
+@@ -56,14 +56,14 @@ typedef struct
+     /* [GPIO drv] */
+     uint8_t gpio_num_relays;
+     uint8_t gpio_active_value;
+-    uint8_t relay1_gpio_pin;
+-    uint8_t relay2_gpio_pin;
+-    uint8_t relay3_gpio_pin;
+-    uint8_t relay4_gpio_pin;
+-    uint8_t relay5_gpio_pin;
+-    uint8_t relay6_gpio_pin;
+-    uint8_t relay7_gpio_pin;
+-    uint8_t relay8_gpio_pin;
++    uint16_t relay1_gpio_pin;
++    uint16_t relay2_gpio_pin;
++    uint16_t relay3_gpio_pin;
++    uint16_t relay4_gpio_pin;
++    uint16_t relay5_gpio_pin;
++    uint16_t relay6_gpio_pin;
++    uint16_t relay7_gpio_pin;
++    uint16_t relay8_gpio_pin;
+     
+     /* [Sainsmart drv] */
+     uint8_t sainsmart_num_relays;
+diff --git a/src/relay_drv_gpio.c b/src/relay_drv_gpio.c
+index 705c157..28464be 100644
+--- a/src/relay_drv_gpio.c
++++ b/src/relay_drv_gpio.c
+@@ -53,7 +53,7 @@
+ #define GPIO_BASE_FILE GPIO_BASE_DIR"gpio"
+-static uint8_t pins[] =
++static uint16_t pins[] =
+ {
+   0, // dummy
+   0, // pin 1
+@@ -85,7 +85,7 @@ int set_relay_generic_gpio(char* portname, uint8_t relay, relay_state_t relay_st
+  *         -1 - fail
+  *         -2 - already exported
+  *********************************************************/
+-static int do_export(uint8_t pin)
++static int do_export(uint16_t pin)
+ {
+    int fd;
+    char b[64];
+@@ -151,7 +151,7 @@ static int do_export(uint8_t pin)
+  * Return:  0 - success
+  *         -1 - fail
+  *********************************************************/
+-static int do_unexport(uint8_t pin)
++static int do_unexport(uint16_t pin)
+ {
+    int fd;
+    char b[64];
+@@ -261,7 +261,7 @@ int get_relay_generic_gpio(char* portname, uint8_t relay, relay_state_t* relay_s
+    int fd;
+    char b[64];
+    char d[1];
+-   uint8_t pin;
++   uint16_t pin;
+    if (relay<FIRST_RELAY || relay>(FIRST_RELAY+g_num_relays-1))
+    {
+@@ -324,7 +324,7 @@ int set_relay_generic_gpio(char* portname, uint8_t relay, relay_state_t relay_st
+    int fd;
+    char b[64];
+    char d[1];
+-   uint8_t pin;
++   uint16_t pin;
+    
+    if (relay<FIRST_RELAY || relay>(FIRST_RELAY+g_num_relays-1))
+    {
+-- 
+2.17.1
+