owfs: add startup scripts, make features configurable and fix w1 adapter bugslilik-openwrt-22.03
@ -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 |
@ -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' |
@ -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 | |||
} |
@ -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' |
@ -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 | |||
} |
@ -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' |
@ -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 | |||
} |
@ -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' |
@ -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 | |||
} |
@ -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 ; | |||
} |
@ -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! |