gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-mdb] 11/23: use more named constants


From: gnunet
Subject: [taler-taler-mdb] 11/23: use more named constants
Date: Wed, 04 Dec 2019 14:15:57 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository taler-mdb.

commit c914ca5b9b67c9e663b2f115ebd6970ff4962350
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Dec 4 12:56:40 2019 +0100

    use more named constants
---
 src/main.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 50 insertions(+), 16 deletions(-)

diff --git a/src/main.c b/src/main.c
index ed13896..d020401 100644
--- a/src/main.c
+++ b/src/main.c
@@ -103,22 +103,46 @@ along with
 
 /* Commands for communication via MDB/ICP */
 /* VMC commands */
+/**
+ * Acknowledgement
+ */
+#define VMC_ACKN 0x00
+
+/**
+ * Request for configuration.
+ */
+#define VMC_CONF 0x11
+
+/**
+ * Vending, with sub-command.
+ */
 #define VMC_VEND 0x13
 #define VMC_VEND_REQUEST 0x00
 #define VMC_VEND_CANCEL 0x01
 #define VMC_VEND_SUCCESS 0x02
 #define VMC_VEND_FAILURE 0x03
 #define VMC_VEND_SESSION_COMPLETE 0x04
+/**
+ * Out of sequence.
+ */
+#define VMC_OOSQ 0xB0
+
+/**
+ * Request to retransmit last command.
+ */
+#define VMC_RETR 0xAA
 
 /* Reader commands */
 #define READER_CONFIG "01"
-#define READER_DISPLAY_REQUEST "02"
 #define READER_BEGIN_SESSION "03"
-#define READER_SESSION_CANCEL_REQUEST "04"
 #define READER_VEND_APPROVE "05"
 #define READER_VEND_DENIED "06"
 #define READER_END_SESSION "07"
+
+/* Unused reader commands */
+#define READER_DISPLAY_REQUEST "02"
 #define READER_SESSION_CANCELLED "08"
+#define READER_SESSION_CANCEL_REQUEST "04"
 #define READER_REVALUE_APPROVED "0D"
 #define READER_REVALUE_DENIED "0E"
 
@@ -1280,7 +1304,7 @@ handle_command (const char *hex,
   }
   switch (cmd)
   {
-  case 0x13:
+  case VMC_VEND:
     {
       unsigned int subcmd;
 
@@ -1298,7 +1322,7 @@ handle_command (const char *hex,
       }
       switch (subcmd)
       {
-      case 0x00:
+      case VMC_VEND_REQUEST:
         {
           unsigned int product;
 
@@ -1327,11 +1351,11 @@ handle_command (const char *hex,
           mdb.cmd = &denyVend;
           break;
         }
-      case 0x02:
+      case VMC_VEND_SUCCESS:
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                     "Vend Success");
         break;
-      case 0x03:
+      case VMC_VEND_FAILURE:
         {
           mdb.cmd = &endSession;
           mdb.session_running = GNUNET_NO;
@@ -1345,7 +1369,7 @@ handle_command (const char *hex,
           }
           break;
         }
-      case 0x04:
+      case VMC_VEND_SESSION_COMPLETE:
         {
           GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                       "Session Complete");
@@ -1364,7 +1388,7 @@ handle_command (const char *hex,
       }
       break;
     }
-  case 0x11:
+  case VMC_CONF:
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Received request for configuration");
     mdb.cmd = &readerConfigData;
@@ -1402,7 +1426,7 @@ handle_command (const char *hex,
       }
       break;
     }
-  case 0x00:
+  case VMC_ACKN:
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Received Acknowledge (for %s)",
                 (NULL != mdb.last_cmd) ? mdb.last_cmd->name : "?");
@@ -1422,7 +1446,7 @@ handle_command (const char *hex,
       return;
     }
     break;
-  case 0xB0:
+  case VMC_OOSQ:
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Received Command out of Sequence (%s)",
                 (NULL != mdb.last_cmd) ? mdb.last_cmd->name : "?");
@@ -1432,7 +1456,7 @@ handle_command (const char *hex,
     else
       mdb.last_cmd = NULL;
     break;
-  case 0xAA:
+  case VMC_RETR:
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Received request to resend previous data (%s)",
                 (NULL != mdb.last_cmd) ? mdb.last_cmd->name : "?");
@@ -1976,11 +2000,21 @@ main (int argc,
                "Failed to set terminal discipline\n");
   }
 
-  readerConfigData = setup_mdb_cmd ("Reader Config", "0101", "19780A02FF0C");
-  beginSession = setup_mdb_cmd ("Begin Session", "03", "FFFF");
-  denyVend = setup_mdb_cmd ("Deny Vend", "06", NULL);
-  approveVend = setup_mdb_cmd ("Approve Vend", "05", "0001");
-  endSession = setup_mdb_cmd ("End Session", "07", NULL);
+  readerConfigData = setup_mdb_cmd ("Reader Config",
+                                    READER_CONFIG,
+                                    "0119780A02FF0C");
+  beginSession = setup_mdb_cmd ("Begin Session",
+                                READER_BEGIN_SESSION,
+                                "FFFF");
+  approveVend = setup_mdb_cmd ("Approve Vend",
+                               READER_VEND_APPROVE,
+                               "0001");
+  denyVend = setup_mdb_cmd ("Deny Vend",
+                            READER_VEND_DENIED,
+                            NULL);
+  endSession = setup_mdb_cmd ("End Session",
+                              READER_END_SESSION,
+                              NULL);
 
   ret = GNUNET_PROGRAM_run (argc,
                             argv,

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]