summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-05-31 11:18:42 +0200
committerChristian Grothoff <christian@grothoff.org>2022-05-31 11:18:42 +0200
commit299df7f0b68015d077e5f4832a01674bd973004a (patch)
treef3a7389d04347b31db7ceba769a396f272ab7951
parentc9fd17578dc48527cab9a842ac75934169bb74f0 (diff)
downloadtaler-mdb-299df7f0b68015d077e5f4832a01674bd973004a.tar.gz
taler-mdb-299df7f0b68015d077e5f4832a01674bd973004a.tar.bz2
taler-mdb-299df7f0b68015d077e5f4832a01674bd973004a.zip
-fix cancel button, more logging
-rw-r--r--src/main.c70
1 files changed, 46 insertions, 24 deletions
diff --git a/src/main.c b/src/main.c
index d8a074c..0f58df4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -993,7 +993,7 @@ static void
cleanup_payment (struct PaymentActivity *pa)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Cleaning up payment\n");
+ "Cleaning up payment\n");
if ( (! pa->paid) &&
(NULL != pa->order_id) )
{
@@ -1018,7 +1018,12 @@ cleanup_payment (struct PaymentActivity *pa)
nfc_close (pa->pnd);
}
if (NULL != cancelbutton_task)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Stopping watching of the cancel button\n");
GNUNET_SCHEDULER_cancel (cancelbutton_task);
+ cancelbutton_task = NULL;
+ }
if (NULL != pa->po)
TALER_MERCHANT_orders_post_cancel (pa->po);
if (NULL != pa->ogh)
@@ -1163,16 +1168,23 @@ shutdown_task (void *cls)
{
GNUNET_break (0 ==
close (cancel_button.cancelbuttonfd));
- cancel_button.cancelbuttonfd = open ("/sys/class/gpio/unexport",
- O_WRONLY);
- if (-1 == cancel_button.cancelbuttonfd)
+ cancel_button.cancelbuttonfd = -1;
+ }
+ {
+ int efd;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Unexporting GPIO pin 23\n");
+ efd = open ("/sys/class/gpio/unexport",
+ O_WRONLY);
+ if (-1 == efd)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Unable to open /gpio/unexport for cancel button\n");
}
else
{
- if (2 != write (cancel_button.cancelbuttonfd,
+ if (2 != write (efd,
"23",
2))
{
@@ -1181,8 +1193,7 @@ shutdown_task (void *cls)
"/sys/class/gpio/unexport");
}
- GNUNET_break (0 == close (cancel_button.cancelbuttonfd));
- cancel_button.cancelbuttonfd = -1;
+ GNUNET_break (0 == close (efd));
}
}
/* free the allocated productes read from config file */
@@ -1648,17 +1659,17 @@ launch_payment (struct Product *product)
products = json_array ();
GNUNET_assert (NULL != products);
GNUNET_assert (
- 0 ==
- json_array_append_new (products,
- GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("description",
- product->description),
- GNUNET_JSON_pack_string ("image",
- product->preview),
- TALER_JSON_pack_amount ("price",
- &product->price),
- GNUNET_JSON_pack_uint64 ("quantity",
- 1))));
+ 0 ==
+ json_array_append_new (products,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("description",
+ product->description),
+ GNUNET_JSON_pack_string ("image",
+ product->preview),
+ TALER_JSON_pack_amount ("price",
+ &product->price),
+ GNUNET_JSON_pack_uint64 ("quantity",
+ 1))));
orderReq = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("summary",
product->description),
@@ -1669,7 +1680,7 @@ launch_payment (struct Product *product)
#endif
GNUNET_JSON_pack_array_steal (
"products",
- products),
+ products),
TALER_JSON_pack_amount ("amount",
&product->price),
GNUNET_JSON_pack_string ("fulfillment_message",
@@ -1742,7 +1753,11 @@ launch_payment (struct Product *product)
}
/* Start to read the button on the VM to cancel this payment */
if (-1 != cancel_button.cancelbuttonfd)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Payment started, watching for cancel button\n");
start_read_cancel_button ();
+ }
return pa;
}
@@ -1751,7 +1766,7 @@ launch_payment (struct Product *product)
* @brief Vending successful, conclude payment activity.
*/
static void
-vend_success ()
+vend_success (void)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"MDB vend success received\n");
@@ -1991,6 +2006,8 @@ cancel_button_pressed (void *cls)
char value;
cancelbutton_task = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Cancel button event detected\n");
if (1 !=
read (cancel_button.cancelbuttonfd,
&value,
@@ -2032,6 +2049,9 @@ cancel_button_pressed (void *cls)
}
else
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Cancel button spurious event (%d), looking for more\n",
+ (int) value);
start_read_cancel_button ();
}
}
@@ -2088,7 +2108,11 @@ start_read_cancel_button (void)
};
if (NULL != cancelbutton_task)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Cancel task still active (!?), not starting another one\n");
return;
+ }
cancelbutton_task = GNUNET_SCHEDULER_add_read_file (
GNUNET_TIME_UNIT_FOREVER_REL,
&fh,
@@ -2901,10 +2925,6 @@ read_products (void *cls,
"data:%s;base64,%s",
mime_type,
base64);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Thumbnail for %s is `%s'\n",
- section,
- tmpProduct.preview);
GNUNET_free (base64);
}
GNUNET_free (thumb);
@@ -3167,6 +3187,8 @@ run (void *cls,
{
int efd;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Exporting GPIO pin 23\n");
efd = open ("/sys/class/gpio/export",
O_WRONLY);
if (-1 == efd)