crelay: update to 0.14.1

Also add a meson.build file to avoid iconv hacks.

Remove upstreamed patch.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2022-07-19 01:26:38 -07:00
parent de563c1ae1
commit 89a8fb1d30
4 changed files with 69 additions and 113 deletions

View File

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=crelay
PKG_VERSION:=0.14
PKG_RELEASE:=2
PKG_VERSION:=0.14.1
PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/ondrej1024/crelay/tar.gz/V$(PKG_VERSION)?
PKG_HASH:=8e406ae8560d8a42b7dd7cf20193e6dce714747f71809e124deadddf78572590
PKG_HASH:=291f51d60c3003ad594ac2c10f75b0c5d0b40e49b298f73caf6a47afe3279fde
PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>
PKG_LICENSE:=GPL-3.0-or-later
@ -21,6 +21,7 @@ PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk
include $(INCLUDE_DIR)/meson.mk
define Package/crelay
SECTION:=utils
@ -44,22 +45,9 @@ define Package/crelay/description
- HID API compatible relay card
endef
TARGET_CFLAGS+= \
-I$(STAGING_DIR)/usr/include/libftdi1 \
-I$(STAGING_DIR)/usr/include/hidapi
TARGET_LDFLAGS+= $(if $(ICONV_FULL),-liconv)
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/src \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)"
endef
define Package/crelay/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/crelay $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/crelay $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/crelay.init $(1)/etc/init.d/crelay
$(INSTALL_CONF) $(PKG_BUILD_DIR)/conf/crelay.conf $(1)/etc

View File

@ -1,11 +0,0 @@
--- a/src/Makefile
+++ b/src/Makefile
@@ -44,7 +44,7 @@ OPTS += -DDRV_CONRAD
endif
ifeq ($(DRV_SAINSMART), y)
SRC += relay_drv_sainsmart.c
-LIBS += -lftdi
+LIBS += -lftdi1
OPTS += -DDRV_SAINSMART
endif
ifeq ($(DRV_SAINSMART16), y)

View File

@ -0,0 +1,64 @@
From 5e122c8adabb3305dd7524a24ec296bb8d1b7cac Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Tue, 19 Jul 2022 01:07:57 -0700
Subject: [PATCH] add meson
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
meson.build | 34 ++++++++++++++++++++++++++++++++++
meson_options.txt | 11 +++++++++++
2 files changed, 45 insertions(+)
create mode 100644 meson.build
create mode 100644 meson_options.txt
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,34 @@
+project('crelay', 'c', version : '0.14.1')
+
+hidapi_dep = dependency('hidapi-libusb', required: get_option('hidapi'))
+ftdi_dep = dependency('libftdi1', required: get_option('sainsmart'))
+libusb_dep = dependency('libusb-1.0', required: get_option('conrad'))
+
+sources = files(
+ 'src/config.c',
+ 'src/crelay.c',
+ 'src/relay_drv.c',
+ 'src/relay_drv_gpio.c',
+)
+
+if hidapi_dep.found()
+ add_project_arguments('-DDRV_HIDAPI', language: 'c')
+ add_project_arguments('-DDRV_SAINSMART16', language: 'c')
+ sources += files('src/relay_drv_hidapi.c', 'src/relay_drv_sainsmart16.c',)
+endif
+
+if ftdi_dep.found()
+ add_project_arguments('-DDRV_SAINSMART', language: 'c')
+ sources += files('src/relay_drv_sainsmart.c')
+endif
+
+if libusb_dep.found()
+ add_project_arguments('-DDRV_CONRAD', language: 'c')
+ sources += files('src/relay_drv_conrad.c')
+endif
+
+executable('crelay',
+ sources,
+ dependencies: [ hidapi_dep, ftdi_dep, libusb_dep ],
+ install: true,
+)
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,11 @@
+option('hidapi', type : 'feature',
+ description: 'Enable HIDAPI driver',
+)
+
+option('sainsmart', type : 'feature',
+ description: 'Enable SAINSMART driver',
+)
+
+option('conrad', type : 'feature',
+ description: 'Enable CONRAD driver',
+)

View File

@ -1,85 +0,0 @@
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(-)
--- 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;
--- 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* portnam
* -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* portnam
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* portnam
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))
{