commit 8c3dd6adc49436abf582d0a5271de5d99dda480f
parent 71b28cbb4f3466f1a2690cf4ea4bf6bb69f1b48c
Author: Dominik Hofer <dominik.hofer@bfh.ch>
Date: Sun, 29 Dec 2019 14:21:21 +0100
Commented Code
Diffstat:
| M | src/main.c | | | 82 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- |
1 file changed, 69 insertions(+), 13 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -23,8 +23,6 @@ along with
* @author Christian Grothoff
* @author Dominik Hofer
*
-* TODO:
-* - comment code mdb incl. doxygen struct members (hofer)
*/
#include "config.h"
#include <stdio.h>
@@ -231,8 +229,14 @@ along with
*/
struct MdbBlock
{
+ /**
+ * Data containing a mdb command or the data of an mdb command
+ */
uint8_t *bin;
-
+
+ /**
+ * Size of the data referenced by *bin
+ */
size_t bin_size;
};
@@ -242,10 +246,19 @@ struct MdbBlock
*/
struct MdbCommand
{
- const char *name;
+ /**
+ * Name of the command for the logging
+ */
+ const char *name;
+ /**
+ * Data block containing the information about the mdb command
+ */
struct MdbBlock cmd;
-
+
+ /**
+ * Data block containing the information about the mdb command data
+ */
struct MdbBlock data;
};
@@ -364,19 +377,40 @@ struct PaymentActivity
*/
struct MdbHandle
{
-
+
+ /**
+ * Buffer to save the received data from UART
+ */
uint8_t rxBuffer[MAX_SIZE_RX_BUFFER];
+ /**
+ * Buffer to save the data to send via UART
+ */
uint8_t txBuffer[MAX_SIZE_TX_BUFFER];
+ /**
+ * Reference to scheduler task to read from UART
+ */
struct GNUNET_SCHEDULER_Task *rtask;
-
+
+ /**
+ * Reference to scheduler task to write to UART
+ */
struct GNUNET_SCHEDULER_Task *wtask;
+ /**
+ * Reference to the mdb cmd which will be sent next
+ */
const struct MdbCommand *cmd;
-
+
+ /**
+ * Reference to the mdb cmd which was sent last
+ */
const struct MdbCommand *last_cmd;
+ /**
+ * Current read offset in @e rxBuffer.
+ */
size_t rx_off;
/**
@@ -390,12 +424,24 @@ struct MdbHandle
*/
size_t tx_len;
+ /**
+ * Time out to wait for an acknoweledge received via the mdb bus
+ */
struct GNUNET_TIME_Absolute ack_timeout;
+ /**
+ * Backup of the config data to restore the configuration of the UART before closing it
+ */
struct termios uart_opts_backup;
+ /**
+ * Indicates if a vend session is running or not
+ */
int session_running;
+ /**
+ * File descriptor to the UART device file
+ */
int uartfd;
};
@@ -438,6 +484,16 @@ struct Display
};
/**
+ * Handle for the Cancel Button
+ */
+struct CancelButton
+{
+ /**
+ * File descriptor to read the state of the cancel button gpio pin
+ */
+ int cancelbuttonfd;
+};
+/**
* DLL of pending refund operations.
*/
struct Refund
@@ -486,10 +542,13 @@ static int global_ret;
static int in_shutdown;
/**
- * Refenence to the keyboard task
+ * Reference to the keyboard task
*/
static struct GNUNET_SCHEDULER_Task *keyboard_task;
+/**
+ * Reference to the cancel button task
+ */
static struct GNUNET_SCHEDULER_Task *cancelbutton_task;
/**
@@ -626,10 +685,7 @@ static char backlight_on = '1';
*/
static char backlight_off = '0';
-struct CancelButton
-{
- int cancelbuttonfd;
-};
+
static struct CancelButton cancelButton;
/**
* Name of the UART device with the MDB (i.e. /dev/ttyAMA0).