"kds_s2000w_client.c"
"kds_s2000w_image_converter.c"
"kds_s2000w_debug.c"
- "kds_s2000w_config.c")
+ "kds_s2000w_config.c"
+ "kds_s2000w_heartbeat.c")
SET_TARGET_PROPERTIES("sane-kds_s2000w_net" PROPERTIES VERSION 1)
TARGET_INCLUDE_DIRECTORIES("sane-kds_s2000w_net" PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
TARGET_LINK_LIBRARIES("sane-kds_s2000w_net"
${CONFUSE}
${CURL_LIBRARY}
${ImageMagick_LIBRARIES}
- json-c)
+ json-c
+ pthread)
INSTALL(TARGETS "sane-kds_s2000w_net"
DESTINATION ${CMAKE_LIBRARY_PATH}/sane)
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
#include <math.h>
#include "kds_s2000w_handler.h"
#include "kds_s2000w_handler_opts.h"
#include "kds_s2000w_client.h"
#include "kds_s2000w_image_converter.h"
#include "kds_s2000w_debug.h"
+#include "kds_s2000w_heartbeat.h"
void _get_current_metadata(handler* h)
{
metadata = NULL;
kds_s2000w_client_response_free(resp);
resp = NULL;
- sleep(1);
}
void _delete_current_image(handler* h)
h->sessionid = 0;
h->state = NOTCONNECTED;
+ h->wait = 0;
h->current_scan_status->current_image_number = 1;
h->current_scan_status->available_images = 0;
h->current_scan_status->downloaded_images = 0;
void free_handler(handler* h)
{
debug_printf(ALL, "free handler");
+ while(h->wait);
json_object_put(h->current_scanner_config);
h->current_scanner_config = NULL;
free(h->current_scan_status);
h->jpg_image->data = NULL;
h->state = NOTCONNECTED;
+ h->wait = 0;
h->current_scan_status->current_image_number = 1;
h->current_scan_status->available_images = 0;
h->current_scan_status->downloaded_images = 0;
if (resp->code == 408) {
kds_s2000w_client_response_free(resp);
resp = NULL;
- sleep(1);
resp = kds_s2000w_client_response_init();
result = kds_s2000w_client_open_session(resp);
if (resp->error_size > 0)
void kds_s2000w_handler_get_parameters(handler* h)
{
debug_printf(ALL, "kds_s2000w_handler_get_parameters");
+ while(h->wait);
+ wait_a_second(&h->wait);
+
if (h->current_scan_status->complete_scanned
&& h->current_scan_status->available_images <= 0) {
h->current_metadata->valid = 1;
--- /dev/null
+#include <unistd.h>
+#include <pthread.h>
+#include "kds_s2000w_heartbeat.h"
+
+void* _wait_thread(void* wait)
+{
+ int* wait_bool = (int*) wait;
+ sleep(1);
+ *wait_bool = 0;
+ return NULL;
+}
+
+void wait_a_second(int* wait)
+{
+ *wait = 1;
+ pthread_t pwait;
+ pthread_create(&pwait, NULL, _wait_thread, wait);
+}
\ No newline at end of file