From 0308efe6ce8232e05bcdad06d499df304ad1cad1 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 16 Feb 2025 18:29:45 +0100 Subject: [PATCH] add option document feeder timeout --- src/kds_s2000w_handler_opts.c | 10 +++++++++- tests/kds_s2000w_net_get_opt_tests.c | 17 ++++++++++++++++- tests/kds_s2000w_net_get_opt_tests.h | 1 + tests/kds_s2000w_net_get_opt_tests_run.c | 3 ++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/kds_s2000w_handler_opts.c b/src/kds_s2000w_handler_opts.c index 7af8c73..beeb8d2 100644 --- a/src/kds_s2000w_handler_opts.c +++ b/src/kds_s2000w_handler_opts.c @@ -6,7 +6,7 @@ #include "kds_s2000w_debug.h" #define AUTOSTART_ON 1 -#define OPTION_COUNT 37 +#define OPTION_COUNT 38 void _kds_s2000w_handler_opts_write_string_value(json_object* value_object, void* value) { @@ -274,6 +274,10 @@ void kds_s2000w_handler_opts_get_option(handler* h, uint32_t option, void* value value_object = json_object_object_get(config, "MaxDocumentLength"); _kds_s2000w_handler_opts_write_int_value(value_object, value); break; + case 36: + value_object = json_object_object_get(config, "DocumentFeederTimeout"); + _kds_s2000w_handler_opts_write_int_value(value_object, value); + break; default: break; } @@ -445,6 +449,10 @@ void kds_s2000w_handler_opts_set_option(handler* h, uint32_t option, void* value _kds_s2000w_handler_opts_write_int_value_to_json(value_object, value); break; case 36: + value_object = json_object_object_get(config, "DocumentFeederTimeout"); + _kds_s2000w_handler_opts_write_int_value_to_json(value_object, value); + break; + case 37: _kds_s2000w_handler_opts_set_option_to_default(h); _kds_s2000w_handler_opts_set_autostart_on(h); diff --git a/tests/kds_s2000w_net_get_opt_tests.c b/tests/kds_s2000w_net_get_opt_tests.c index 15462a9..c97544e 100644 --- a/tests/kds_s2000w_net_get_opt_tests.c +++ b/tests/kds_s2000w_net_get_opt_tests.c @@ -21,7 +21,7 @@ void sane_kds_s2000w_net_control_get_option_zero_test(void** state) sane_kds_s2000w_net_control_option(h, 0, SANE_ACTION_GET_VALUE, &value, NULL); - assert_int_equal(value, 37); + assert_int_equal(value, 38); kds_s2000w_handler_free(h); h = NULL; @@ -519,6 +519,21 @@ void sane_kds_s2000w_net_control_get_option_thirdyfive_test(void** state) assert_int_equal(value, 140); + kds_s2000w_handler_free(h); + h = NULL; +} + +void sane_kds_s2000w_net_control_get_option_thirdysix_test(void** state) +{ + handler* h = kds_s2000w_handler_init(); + response* resp = (response*) *state; + h->current_scanner_config = json_tokener_parse(resp->data); + uint32_t value = -1; + + sane_kds_s2000w_net_control_option(h, 36, SANE_ACTION_GET_VALUE, &value, NULL); + + assert_int_equal(value, 2); + kds_s2000w_handler_free(h); h = NULL; } \ No newline at end of file diff --git a/tests/kds_s2000w_net_get_opt_tests.h b/tests/kds_s2000w_net_get_opt_tests.h index 7bdf053..9fb4ee4 100644 --- a/tests/kds_s2000w_net_get_opt_tests.h +++ b/tests/kds_s2000w_net_get_opt_tests.h @@ -40,5 +40,6 @@ void sane_kds_s2000w_net_control_get_option_thirdytwo_test(void** state); void sane_kds_s2000w_net_control_get_option_thirdythree_test(void** state); void sane_kds_s2000w_net_control_get_option_thirdyfour_test(void** state); void sane_kds_s2000w_net_control_get_option_thirdyfive_test(void** state); +void sane_kds_s2000w_net_control_get_option_thirdysix_test(void** state); #endif \ No newline at end of file diff --git a/tests/kds_s2000w_net_get_opt_tests_run.c b/tests/kds_s2000w_net_get_opt_tests_run.c index 44e3c23..59d0599 100644 --- a/tests/kds_s2000w_net_get_opt_tests_run.c +++ b/tests/kds_s2000w_net_get_opt_tests_run.c @@ -109,7 +109,8 @@ int main() cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdytwo_test, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdythree_test, setup_default_get_option, teardown_default_get_option), cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdyfour_test, setup_default_get_option, teardown_default_get_option), - cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdyfive_test, setup_default_get_option, teardown_default_get_option) + cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdyfive_test, setup_default_get_option, teardown_default_get_option), + cmocka_unit_test_setup_teardown(sane_kds_s2000w_net_control_get_option_thirdysix_test, setup_default_get_option, teardown_default_get_option) }; return cmocka_run_group_tests(net_tests, NULL, NULL); -- 2.39.5