diff options
-rw-r--r-- | io-module/mtr2d2.c | 1 | ||||
-rw-r--r-- | io-module/mts_io.c | 43 | ||||
-rwxr-xr-x | io-tool/mts-io-sysfs | 2 |
3 files changed, 43 insertions, 3 deletions
diff --git a/io-module/mtr2d2.c b/io-module/mtr2d2.c index 7e44881..4876c90 100644 --- a/io-module/mtr2d2.c +++ b/io-module/mtr2d2.c @@ -274,6 +274,7 @@ static struct attribute *mtr2d2_platform_attributes[] = { &dev_attr_eth_mac.attr, &dev_attr_reset.attr, &dev_attr_reset_monitor.attr, + &dev_attr_reset_monitor_intervals.attr, &dev_attr_radio_power.attr, &dev_attr_radio_reset.attr, diff --git a/io-module/mts_io.c b/io-module/mts_io.c index 12650b1..8a2de67 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -110,6 +110,8 @@ bool sent_extra_long = false; static int reset_short_signal = SIGUSR1; static int reset_long_signal = SIGUSR2; static int reset_extra_long_signal = SIGHUP; +static int reset_short_interval = RESET_HOLD_COUNT; +static int reset_long_interval = RESET_LONG_HOLD_COUNT; static void reset_callback(struct work_struct *ignored); @@ -137,16 +139,16 @@ static void reset_callback(struct work_struct *ignored) reset_count++; } else { //Reset button has not been pressed - if (reset_count > 0 && reset_count < RESET_HOLD_COUNT) { + if (reset_count > 0 && reset_count < reset_short_interval) { kill_pid(vpid, reset_short_signal, 1); - } else if (reset_count >= RESET_HOLD_COUNT && reset_count < RESET_LONG_HOLD_COUNT) { + } else if (reset_count >= reset_short_interval && reset_count < reset_long_interval) { kill_pid(vpid, reset_long_signal, 1); } reset_count = 0; sent_extra_long = false; } - if (reset_count >= RESET_LONG_HOLD_COUNT && ! sent_extra_long) { + if (reset_count >= reset_long_interval && ! sent_extra_long) { kill_pid(vpid, reset_extra_long_signal, 1); sent_extra_long = true; } @@ -159,6 +161,41 @@ static void reset_callback(struct work_struct *ignored) schedule_delayed_work(&reset_work, RESET_INTERVAL); } +static ssize_t mts_attr_show_reset_monitor_intervals(struct device *dev, struct device_attribute *attr, char *buf) +{ + int ret; + + mutex_lock(&mts_io_mutex); + + ret = sprintf(buf, "%d %d\n", reset_short_interval / RESET_CHECK_PER_SEC, reset_long_interval / RESET_CHECK_PER_SEC); + + mutex_unlock(&mts_io_mutex); + + return ret; +} + +static ssize_t mts_attr_store_reset_monitor_intervals(struct device *dev, struct device_attribute *attr, char *buf, size_t count) +{ + int short_int; + int long_int; + + if (sscanf(buf, "%i %i", &short_int, &long_int) != 2) { + return -EINVAL; + } + + mutex_lock(&mts_io_mutex); + + reset_short_interval = short_int * RESET_CHECK_PER_SEC; + reset_long_interval = long_int * RESET_CHECK_PER_SEC; + + mutex_unlock(&mts_io_mutex); + + return count; +} + +static DEVICE_ATTR_MTS(dev_attr_reset_monitor_intervals, "reset-monitor-intervals", + mts_attr_show_reset_monitor_intervals, mts_attr_store_reset_monitor_intervals); + static ssize_t mts_attr_show_reset_monitor(struct device *dev, struct device_attribute *attr, char *buf) diff --git a/io-tool/mts-io-sysfs b/io-tool/mts-io-sysfs index 3ecb100..7ec8da0 100755 --- a/io-tool/mts-io-sysfs +++ b/io-tool/mts-io-sysfs @@ -143,6 +143,8 @@ usage() { printf " $FILENAME { 0 }\n" >&${out} ;; reset-monitor ) printf " $FILENAME { pid short-signal long-signal [extra-long-signal] }\n" >&${out} ;; + reset-monitor-intervals ) + printf " $FILENAME { short-interval long-interval }\n" >&${out} ;; *serial-mode ) printf " $FILENAME { loopback | rs232 | rs485-half | rs422-485-full }\n" >&${out} ;; * ) |