cash2ecash

cash2ecash: cash acceptor that issues digital cash (experimental)
Log | Files | Refs | README | LICENSE

commit 6c7008fd00bfe5c15cdf80dfb4251dc6bbaa85aa
parent 080a4145759f219b682cb7a352e2b791ee206212
Author: Tellenbach Reto <tellr1@bfh.ch>
Date:   Mon,  8 Jun 2026 23:18:28 +0200

[dbg] Display: use commands

Diffstat:
Msrc/taler-digitizer.c | 104+++++++++++--------------------------------------------------------------------
1 file changed, 14 insertions(+), 90 deletions(-)

diff --git a/src/taler-digitizer.c b/src/taler-digitizer.c @@ -26,7 +26,6 @@ #include <stdio.h> #include <stdlib.h> #include <signal.h> -#include <qrencode.h> #include <gnunet/gnunet_util_lib.h> #include "taler_digitizer_util.h" #include "taler/taler_digitizer_service.h" @@ -49,6 +48,8 @@ #define PATH_QR_SHOW "/ext/QRshow" #define SCAN_QR_TIMEOUT_SECONDS 60 +#define DISPLAY_BLOCK_SIZE 1024 +#define DISPLAY_COUNT 750 /** * Global return value @@ -196,11 +197,6 @@ static struct TALER_BANK_GetWithdrawalHandle *get_withdrawal_handle; static struct TALER_BANK_PostCreateWithdrawalHandle *post_accounts_withdrawal_handle; /** - * framebuffer for qr-show - */ -static FILE *fp; - -/** * used to init gpio */ static struct gpiod_line_settings *gpio_settings; @@ -210,10 +206,6 @@ static struct gpiod_line_settings *gpio_settings; */ static struct gpiod_line_request *rl_ca_enable; -/** - * show-qr process - */ -static struct GNUNET_Process *qr_child; enum @@ -331,73 +323,10 @@ struct DIGITIZER_DisplayContext *display_ctx; static void state_controller_task(void *cls); -/** - * Start process using the @a command command-line. - * - * @param command command to run - * @param ... extra arguments to pass - * @return process handle, NULL on failure - */ -static struct GNUNET_Process * -start_command (const char *command, - ...) -{ - char **argv = NULL; - unsigned int argc = 0; - char *cpy = GNUNET_strdup (command); - struct GNUNET_Process *ret; - va_list ap; - const char *arg; - - for (const char *tok = strtok (cpy, " "); - NULL != tok; - tok = strtok (NULL, " ")) - { - GNUNET_array_append (argv, - argc, - GNUNET_strdup (tok)); - } - va_start (ap, - command); - while (NULL != (arg = va_arg (ap, - const char *))) - { - GNUNET_array_append (argv, - argc, - GNUNET_strdup (arg)); - } - va_end (ap); - GNUNET_array_append (argv, - argc, - NULL); - ret = GNUNET_process_create (GNUNET_OS_INHERIT_STD_ERR); - if (GNUNET_OK != - GNUNET_process_run_command_argv (ret, - argv[0], - (const char **) argv)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to launch %s\n", - argv[0]); - GNUNET_process_destroy (ret); - ret = NULL; - } - for (unsigned int i = 0; i<argc; i++) - GNUNET_free (argv[i]); - GNUNET_array_grow (argv, - argc, - 0); - GNUNET_free (cpy); - return ret; -} void -stop_qr_show(void); - -enum GNUNET_GenericReturnValue start_qr_show(int showtime) { - stop_qr_show (); //char buffer[FRAMEBUFFER_SIZE]; char *command; char *url; @@ -420,29 +349,23 @@ start_qr_show(int showtime) url); GNUNET_free(url); TALER_LOG_DEBUG("Command for QRshow: %s\n",command); - qr_child = start_command (command, - NULL); + system(command); GNUNET_free(command); GNUNET_free(path); - return GNUNET_OK; } void -stop_qr_show(void) +clear_screen(void) { - if(qr_child == NULL) - return; - GNUNET_break (GNUNET_OK == - GNUNET_process_kill (qr_child, - SIGTERM)); - GNUNET_break (GNUNET_OK == - GNUNET_process_wait (qr_child, - true, - NULL, - NULL)); - GNUNET_process_destroy (qr_child); - qr_child = NULL; + char *command; + system(command); + GNUNET_asprintf(&command, + "dd if=/dev/zero of=%s bs=%d count=%d\n", + cfg_ca_device, + DISPLAY_BLOCK_SIZE, + DISPLAY_COUNT); + GNUNET_free(command); } /** @@ -610,7 +533,7 @@ on_get_withdrawal_status_done(void *cls, if(0 == strcasecmp("selected", vr->details.ok.acc.status)) { GNUNET_SCHEDULER_cancel(timeout_handle); - stop_qr_show(); + clear_screen(); state = DIGITIZER_STATE_COUNT_MONEY; // give context for non terminal errors! GNUNET_SCHEDULER_add_now(state_controller_task,NULL); @@ -1143,6 +1066,7 @@ static void TerminalError_state_task(void *cls) static void Idle_state_task(void *cls) { TALER_LOG_DEBUG("Idle state\n"); + clear_screen(); (void)cls; TALER_amount_set_zero(cfg_currency,&state_ctx->digitizer_user_balance); get_accounts_handle = TALER_BANK_get_accounts (curl_ctx,