diff --git a/utils/owfs/Config.in b/utils/owfs/Config.in new file mode 100644 index 000000000..a6508e85e --- /dev/null +++ b/utils/owfs/Config.in @@ -0,0 +1,49 @@ + menu "Customize libow" + depends on PACKAGE_libow + + menu "Bus master and adapter support" + config LIBOW_MASTER_USB + bool "USB bus master support (requires libusb)" + help + Include support for USB adapters (NOT usb-serial adapters, which use + kernel driver and are supported anyway). + Turning this off will save ~13kB (and ~50kB weighting libusb dependency). + default y + + config LIBOW_MASTER_I2C + bool "I2C bus master (DS2482) support" + default y + help + Include support for I2C adapters. + Turning this feature off will save ~6kB. + + config LIBOW_MASTER_W1 + bool "Kernel W1 bus master support (requires kmod-w1)" + help + Support kernel 1-Wire bus masters (requires KConfig CONFIG_CONNECTOR=y + and CONFIG_W1_CON=y). + Turning this on will increase libow size by about 10kB. + default n + endmenu + + config LIBOW_ZEROCONF + bool "Zeroconf/bonjour support" + default y + help + Enable server process announcement using Zeroconf (Bonjour) protocol. + Turning this feature on will increase owlib size by about 12kB. + + config LIBOW_DEBUG + bool "Enable debug output (100+ kB)" + default y + help + If you don't need to debug your 1-wire network, you can save as much as + 137kB disabling debug output. + + config LIBOW_OWTRAFFIC + bool "Enable bus traffic reports" + default n + help + Enable owfs traffic monitor. It's here purely for debugging purposes. + Turning this on will increase libow size by about 3kB. + endmenu diff --git a/utils/owfs/Makefile b/utils/owfs/Makefile index bec087f89..d4cc4cb24 100644 --- a/utils/owfs/Makefile +++ b/utils/owfs/Makefile @@ -20,6 +20,14 @@ PKG_LICENSE:=GPL-2.0 PKG_FIXUP:=autoreconf PKG_INSTALL:=1 +PKG_CONFIG_DEPENDS:= \ + CONFIG_LIBOW_MASTER_USB \ + CONFIG_LIBOW_MASTER_I2C \ + CONFIG_LIBOW_MASTER_W1 \ + CONFIG_LIBOW_ZEROCONF \ + CONFIG_LIBOW_DEBUG \ + CONFIG_LIBOW_OWTRAFFIC + include $(INCLUDE_DIR)/package.mk # @@ -74,10 +82,17 @@ endef define Package/libow $(call Package/owfs/Library) - DEPENDS:=+libusb-compat +libpthread + DEPENDS:= \ + +libpthread \ + +LIBOW_MASTER_USB:libusb-compat \ + +LIBOW_MASTER_W1:kmod-w1 TITLE:=OWFS - common shared library endef +define Package/libow/config + source "$(SOURCE)/Config.in" +endef + define Package/libow/description $(call Package/$(PKG_NAME)/Default/description) @@ -170,13 +185,18 @@ CONFIGURE_ARGS += \ --with-fuseinclude="$(STAGING_DIR)/usr/include" \ --with-fuselib="$(STAGING_DIR)/usr/lib" \ --enable-shared \ - --enable-zero \ --disable-parport \ --disable-ownet \ --disable-owpython \ --disable-owphp \ --disable-owtcl \ --disable-swig \ + $(if $(CONFIG_LIBOW_MASTER_USB),--enable-usb,--disable-usb) \ + $(if $(CONFIG_LIBOW_MASTER_W1),--enable-w1,--disable-w1) \ + $(if $(CONFIG_LIBOW_MASTER_I2C),--enable-i2c,--disable-i2c) \ + $(if $(CONFIG_LIBOW_ZEROCONF),--enable-zero,--disable-zero) \ + $(if $(CONFIG_LIBOW_DEBUG),--enable-debug,--disable-debug) \ + $(if $(CONFIG_LIBOW_OWTRAFFIC),--enable-owtraffic,--disable-owtraffic) CONFIGURE_VARS += \ LDFLAGS="$(TARGET_LDFLAGS) -Wl,-rpath-link=$(STAGING_DIR)/usr/lib -Wl,-rpath-link=$(TOOLCHAIN_DIR)/usr/lib" \ @@ -198,6 +218,15 @@ endef define Package/owfs/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/owfs $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/owfs.conf $(1)/etc/config/owfs + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/owfs.init $(1)/etc/init.d/owfs + mkdir -p $(1)/mnt/owfs +endef + +define Package/owfs/conffiles +/etc/config/owfs endef define Package/owshell/install @@ -213,18 +242,41 @@ endef define Package/owserver/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/owserver $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/owserver.conf $(1)/etc/config/owserver + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/owserver.init $(1)/etc/init.d/owserver +endef + +define Package/owserver/conffiles +/etc/config/owserver endef define Package/owhttpd/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/owhttpd $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/owhttpd.conf $(1)/etc/config/owhttpd + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/owhttpd.init $(1)/etc/init.d/owhttpd +endef + +define Package/owhttpd/conffiles +/etc/config/owhttpd endef define Package/owftpd/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/owftpd $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/owftpd.conf $(1)/etc/config/owftpd + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/owftpd.init $(1)/etc/init.d/owftpd endef +define Package/owftpd/conffiles +/etc/config/owftpd +endef define Package/libow/install $(INSTALL_DIR) $(1)/usr/lib diff --git a/utils/owfs/files/owfs.conf b/utils/owfs/files/owfs.conf new file mode 100644 index 000000000..b4859897a --- /dev/null +++ b/utils/owfs/files/owfs.conf @@ -0,0 +1,10 @@ +config owfs 'owfs' + option enabled 0 + option user root + option readonly 0 + option mountpoint '/mnt/owfs' + option fuse_allow_other 0 + option fuse_open_opt '' + option error_level 0 + list devices '-s' + list devices 'localhost:4304' diff --git a/utils/owfs/files/owfs.init b/utils/owfs/files/owfs.init new file mode 100644 index 000000000..83c8913a0 --- /dev/null +++ b/utils/owfs/files/owfs.init @@ -0,0 +1,82 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2009-2015 OpenWrt.org + +START=95 +USE_PROCD=1 + +PROG=/usr/bin/owfs + +append_arg() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get val "$cfg" "$var" + [ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}" +} + +append_bool() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get_bool val "$cfg" "$var" "$def" + [ "$val" = 1 ] && procd_append_param command "$opt" +} + +append_plain() { + procd_append_param command "$1" +} + +append_param() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get val "$cfg" "$var" + [ -n "$val" -o -n "$def" ] && procd_append_param "$opt" "${val:-$def}" +} + +start_instance() { + local cfg="$1" + local enabled + + config_get_bool enabled "$cfg" 'enabled' '0' + [ "$enabled" = 0 ] && return 1 + + procd_open_instance + + procd_set_param command "$PROG" --foreground --error_print=1 + + # common parameters + append_bool "$cfg" readonly "--readonly" + append_arg "$cfg" error_level "--error_level" + config_list_foreach "$cfg" options append_plain + config_list_foreach "$cfg" devices append_plain + append_param "$cfg" user user + + # owfs-specific + append_arg "$cfg" mountpoint "--mountpoint" /mnt/owfs + append_bool "$cfg" fuse_allow_other "--allow_other" + append_arg "$cfg" fuse_open_opt "--fuse_open_opt" + + # don't respawn fuse + + procd_close_instance + +} + +service_triggers() { + procd_add_reload_trigger owfs +} + +start_service() { + config_load owfs + config_foreach start_instance owfs +} diff --git a/utils/owfs/files/owftpd.conf b/utils/owfs/files/owftpd.conf new file mode 100644 index 000000000..100162e2a --- /dev/null +++ b/utils/owfs/files/owftpd.conf @@ -0,0 +1,8 @@ +config owftpd 'owftpd' + option enabled 0 + option user root + option readonly 0 + option port 21 + option error_level 0 + list devices '-s' + list devices 'localhost:4304' diff --git a/utils/owfs/files/owftpd.init b/utils/owfs/files/owftpd.init new file mode 100644 index 000000000..a7e17c938 --- /dev/null +++ b/utils/owfs/files/owftpd.init @@ -0,0 +1,81 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2009-2015 OpenWrt.org + +START=95 +USE_PROCD=1 + +PROG=/usr/bin/owftpd + +append_arg() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get val "$cfg" "$var" + [ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}" +} + +append_bool() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get_bool val "$cfg" "$var" "$def" + [ "$val" = 1 ] && procd_append_param command "$opt" +} + +append_plain() { + procd_append_param command "$1" +} + +append_param() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get val "$cfg" "$var" + [ -n "$val" -o -n "$def" ] && procd_append_param "$opt" "${val:-$def}" +} + +start_instance() { + local cfg="$1" + local enabled + + config_get_bool enabled "$cfg" 'enabled' '0' + [ "$enabled" = 0 ] && return 1 + + procd_open_instance + + procd_set_param command "$PROG" --foreground --error_print=1 + + # common parameters + append_bool "$cfg" readonly "--readonly" + append_arg "$cfg" error_level "--error_level" + config_list_foreach "$cfg" options append_plain + config_list_foreach "$cfg" devices append_plain + append_param "$cfg" user user + + # owftpd-specific + append_arg "$cfg" port "--port" + append_arg "$cfg" max_connections "--max_connections" + + procd_set_param respawn + + procd_close_instance + +} + +service_triggers() { + procd_add_reload_trigger owftpd +} + +start_service() { + config_load owftpd + config_foreach start_instance owftpd +} diff --git a/utils/owfs/files/owhttpd.conf b/utils/owfs/files/owhttpd.conf new file mode 100644 index 000000000..a314cd1ea --- /dev/null +++ b/utils/owfs/files/owhttpd.conf @@ -0,0 +1,8 @@ +config owhttpd 'owhttpd' + option enabled 0 + option user root + option readonly 0 + option port 3001 + option error_level 0 + list devices '-s' + list devices 'localhost:4304' diff --git a/utils/owfs/files/owhttpd.init b/utils/owfs/files/owhttpd.init new file mode 100644 index 000000000..868c9b419 --- /dev/null +++ b/utils/owfs/files/owhttpd.init @@ -0,0 +1,81 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2009-2015 OpenWrt.org + +START=95 +USE_PROCD=1 + +PROG=/usr/bin/owhttpd + +append_arg() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get val "$cfg" "$var" + [ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}" +} + +append_bool() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get_bool val "$cfg" "$var" "$def" + [ "$val" = 1 ] && procd_append_param command "$opt" +} + +append_plain() { + procd_append_param command "$1" +} + +append_param() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get val "$cfg" "$var" + [ -n "$val" -o -n "$def" ] && procd_append_param "$opt" "${val:-$def}" +} + +start_instance() { + local cfg="$1" + local enabled + + config_get_bool enabled "$cfg" 'enabled' '0' + [ "$enabled" = 0 ] && return 1 + + procd_open_instance + + procd_set_param command "$PROG" --foreground --error_print=1 + + # common parameters + append_bool "$cfg" readonly "--readonly" + append_arg "$cfg" error_level "--error_level" + config_list_foreach "$cfg" options append_plain + config_list_foreach "$cfg" devices append_plain + append_param "$cfg" user user + + # owhttpd-specific + append_arg "$cfg" port "--port" + append_arg "$cfg" max_connections "--max_connections" + + procd_set_param respawn + + procd_close_instance + +} + +service_triggers() { + procd_add_reload_trigger owhttpd +} + +start_service() { + config_load owhttpd + config_foreach start_instance owhttpd +} diff --git a/utils/owfs/files/owserver.conf b/utils/owfs/files/owserver.conf new file mode 100644 index 000000000..ceb8a61e6 --- /dev/null +++ b/utils/owfs/files/owserver.conf @@ -0,0 +1,8 @@ +config owserver 'owserver' + option enabled 0 + option user root + option readonly 0 + option port 4304 + option error_level 0 + list devices '-d' + list devices '/dev/ttyUSB0' diff --git a/utils/owfs/files/owserver.init b/utils/owfs/files/owserver.init new file mode 100644 index 000000000..7f91aeec0 --- /dev/null +++ b/utils/owfs/files/owserver.init @@ -0,0 +1,81 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2009-2015 OpenWrt.org + +START=90 +USE_PROCD=1 + +PROG=/usr/bin/owserver + +append_arg() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get val "$cfg" "$var" + [ -n "$val" -o -n "$def" ] && procd_append_param command $opt "${val:-$def}" +} + +append_bool() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get_bool val "$cfg" "$var" "$def" + [ "$val" = 1 ] && procd_append_param command "$opt" +} + +append_plain() { + procd_append_param command "$1" +} + +append_param() { + local cfg="$1" + local var="$2" + local opt="$3" + local def="$4" + local val + + config_get val "$cfg" "$var" + [ -n "$val" -o -n "$def" ] && procd_append_param "$opt" "${val:-$def}" +} + +start_instance() { + local cfg="$1" + local enabled + + config_get_bool enabled "$cfg" 'enabled' '0' + [ "$enabled" = 0 ] && return 1 + + procd_open_instance + + procd_set_param command "$PROG" --foreground --error_print=1 + + # common parameters + append_bool "$cfg" readonly "--readonly" + append_arg "$cfg" error_level "--error_level" + config_list_foreach "$cfg" options append_plain + config_list_foreach "$cfg" devices append_plain + append_param "$cfg" user user + + # owserver-specific + append_arg "$cfg" port "--port" + append_arg "$cfg" max_connections "--max_connections" + + procd_set_param respawn + + procd_close_instance + +} + +service_triggers() { + procd_add_reload_trigger owserver +} + +start_service() { + config_load owserver + config_foreach start_instance owserver +} diff --git a/utils/owfs/patches/100-fix-netlink-w1-status-message-detection.patch b/utils/owfs/patches/100-fix-netlink-w1-status-message-detection.patch new file mode 100644 index 000000000..251065fa2 --- /dev/null +++ b/utils/owfs/patches/100-fix-netlink-w1-status-message-detection.patch @@ -0,0 +1,30 @@ +AaAA +--- a/module/owlib/src/c/ow_w1_parse.c ++++ b/module/owlib/src/c/ow_w1_parse.c +@@ -237,7 +237,7 @@ enum Netlink_Read_Status W1_Process_Resp + owfree(nlp.nlm) ; + return nrs_nodev ; + } +- if ( nrs_callback == NULL ) { // status message ++ if ( nrs_callback == NULL ) { // bus reset + owfree(nlp.nlm) ; + return nrs_complete ; + } +@@ -246,7 +246,7 @@ enum Netlink_Read_Status W1_Process_Resp + nrs_callback( &nlp, v, pn ) ; + LEVEL_DEBUG("Called nrs_callback"); + owfree(nlp.nlm) ; +- if ( nlp.cn->ack != 0 ) { ++ if ( nlp.cn->seq != nlp.cn->ack ) { + if ( nlp.w1m->type == W1_LIST_MASTERS ) { + continue ; // look for more data + } +@@ -254,7 +254,7 @@ enum Netlink_Read_Status W1_Process_Resp + continue ; // look for more data + } + } +- nrs_callback = NULL ; // now look for status message ++ return nrs_complete ; // status message + } + return nrs_timeout ; + } diff --git a/utils/owfs/patches/101-fix-no-reset-routine-segfault.patch b/utils/owfs/patches/101-fix-no-reset-routine-segfault.patch new file mode 100644 index 000000000..731c4a04e --- /dev/null +++ b/utils/owfs/patches/101-fix-no-reset-routine-segfault.patch @@ -0,0 +1,13 @@ +--- a/module/owlib/src/c/ow_reset.c ++++ b/module/owlib/src/c/ow_reset.c +@@ -21,6 +21,10 @@ RESET_TYPE BUS_reset(const struct parsed + struct connection_in * in = pn->selected_connection ; + STAT_ADD1_BUS(e_bus_resets, in); + ++ if ( in->iroutines.reset == NO_RESET_ROUTINE ) { ++ return BUS_RESET_OK; ++ } ++ + switch ( (in->iroutines.reset) (pn) ) { + case BUS_RESET_OK: + in->reconnect_state = reconnect_ok; // Flag as good!