commit fafab488ffee01f6f50a18c44c50150b1b4a762b
parent 3ebcc8746bdb623269b05a62676b438cbf5dcd0d
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 4 Dec 2019 12:44:12 +0100
parse filenames from config
Diffstat:
2 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -385,9 +385,12 @@ static struct MdbCommand endSession;
/**
* @brief FRAMEBUFFER_DEVICE framebuffer device to diplay qr code
*/
-static const char *FRAMEBUFFER_DEVICE = "/dev/fb1";
+static char *framebuffer_device_filename;
-static char *UART_DEVICE;
+/**
+ * Name of the UART device with the MDB (i.e. /dev/ttyAMA0).
+ */
+static char *uart_device_filename;
/**
* Taler wallet application identifier
@@ -1188,7 +1191,7 @@ write_mdb_command (void *cls)
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"write",
- UART_DEVICE);
+ uart_device_filename);
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -1463,7 +1466,7 @@ read_mdb_command (void *cls)
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"read",
- UART_DEVICE);
+ uart_device_filename);
GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -1625,12 +1628,12 @@ mdb_init ()
struct termios uart_opts_raw;
/* open uart connection */
- if (0 > (mdb.uartfd = open (UART_DEVICE,
+ if (0 > (mdb.uartfd = open (uart_device_filename,
O_RDWR | O_NOCTTY | O_NDELAY)))
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"open",
- UART_DEVICE);
+ uart_device_filename);
return GNUNET_SYSERR;
}
@@ -1712,12 +1715,23 @@ run (void *cls,
GNUNET_CONFIGURATION_get_value_filename (cfg,
"taler-mdb",
"UART_DEVICE",
- &UART_DEVICE))
+ &uart_device_filename))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"taler-mdb",
"UART_DEVICE");
- UART_DEVICE = GNUNET_strdup ("/dev/ttyAMA0");
+ uart_device_filename = GNUNET_strdup ("/dev/ttyAMA0");
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "taler-mdb",
+ "FRAMEBUFFER_DEVICE",
+ &framebuffer_device_filename))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "taler-mdb",
+ "FRAMEBUFFER_DEVICE");
+ uart_device_filename = GNUNET_strdup ("/dev/fb1");
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -1815,7 +1829,7 @@ run (void *cls,
#if HAVE_QRENCODE_H
/* open the framebuffer device */
- qrDisplay.devicefd = open (FRAMEBUFFER_DEVICE,
+ qrDisplay.devicefd = open (framebuffer_device_filename,
O_RDWR);
if (0 < qrDisplay.devicefd)
{
@@ -1889,7 +1903,7 @@ run (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"open(), could not open framebuffer device %s\n",
- FRAMEBUFFER_DEVICE);
+ framebuffer_device_filename);
}
#endif
start_read_keyboard ();
diff --git a/taler.conf b/taler.conf
@@ -13,6 +13,12 @@ fulfillment-url = taler://fulfillment-success
# must be url - utf8 encoded
fulfillment-msg = /Enjoy+your+
+# Name of the UART where the MDB connector is reachable.
+UART_DEVICE = /dev/ttyAMA0
+
+# Name of the framebuffer to use for the QR code.
+FRAMEBUFFER_DEVICE = /dev/fb1
+
#Products
#end declaration