gnunet-svn
[Top][All Lists]
Advanced

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

[cash2ecash] branch master updated: added some lines for testing cashacc


From: gnunet
Subject: [cash2ecash] branch master updated: added some lines for testing cashacceptor in main
Date: Fri, 20 Dec 2024 17:02:26 +0100

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

manuel-geissbuehler pushed a commit to branch master
in repository cash2ecash.

The following commit(s) were added to refs/heads/master by this push:
     new 7068fc8  added some lines for testing cashacceptor in main
7068fc8 is described below

commit 7068fc81328e6647091d37b19e2648debb4f2196
Author: Manuel Geissbühler <manuel@debian>
AuthorDate: Fri Dec 20 16:58:22 2024 +0100

    added some lines for testing cashacceptor in main
---
 build/CMakeCache.txt              |   5 ++-
 build/Makefile                    |  14 +++++++
 build/cash2ecash                  | Bin 0 -> 237264 bytes
 build/compile_commands.json       |   5 +++
 build/{ => utils}/Makefile        |  85 ++++++++++++++++----------------------
 src/CMakeLists.txt                |   5 +++
 src/cash2ecash.cpp                |  65 ++++++++++++++++++++---------
 src/cashacceptor/CMakeLists.txt   |   6 +++
 src/cashacceptor/cashacceptor.hpp |   8 +++-
 src/cashacceptor/dg600f.cpp       |   2 +-
 src/cashacceptor/dg600f.hpp       |   9 ++--
 src/include/utils.hpp             |   1 +
 src/utils/CMakeLists.txt          |   1 +
 src/utils/timer.cpp               |   1 +
 src/utils/timer.hpp               |  22 ++++++++++
 15 files changed, 152 insertions(+), 77 deletions(-)

diff --git a/build/CMakeCache.txt b/build/CMakeCache.txt
index 013e734..00b8b40 100644
--- a/build/CMakeCache.txt
+++ b/build/CMakeCache.txt
@@ -221,6 +221,9 @@ cash2ecash_IS_TOP_LEVEL:STATIC=ON
 //Value Computed by CMake
 
cash2ecash_SOURCE_DIR:STATIC=/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/src
 
+//Dependencies for the target
+cashacceptor_LIB_DEPENDS:STATIC=general;gnunetutil;general;talerutil;
+
 
 ########################
 # INTERNAL cache entries
@@ -326,7 +329,7 @@ CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
 //ADVANCED property for variable: CMAKE_NM
 CMAKE_NM-ADVANCED:INTERNAL=1
 //number of local generators
-CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=6
+CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=7
 //ADVANCED property for variable: CMAKE_OBJCOPY
 CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
 //ADVANCED property for variable: CMAKE_OBJDUMP
diff --git a/build/Makefile b/build/Makefile
index 350f19e..03ec8d0 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -142,6 +142,19 @@ cashacceptor/fast:
        $(MAKE) $(MAKESILENT) -f 
cashacceptor/CMakeFiles/cashacceptor.dir/build.make 
cashacceptor/CMakeFiles/cashacceptor.dir/build
 .PHONY : cashacceptor/fast
 
+#=============================================================================
+# Target rules for targets named utils
+
+# Build rule for target.
+utils: cmake_check_build_system
+       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 utils
+.PHONY : utils
+
+# fast build rule for target.
+utils/fast:
+       $(MAKE) $(MAKESILENT) -f utils/CMakeFiles/utils.dir/build.make 
utils/CMakeFiles/utils.dir/build
+.PHONY : utils/fast
+
 cash2ecash.o: cash2ecash.cpp.o
 .PHONY : cash2ecash.o
 
@@ -176,6 +189,7 @@ help:
        @echo "... rebuild_cache"
        @echo "... cash2ecash"
        @echo "... cashacceptor"
+       @echo "... utils"
        @echo "... cash2ecash.o"
        @echo "... cash2ecash.i"
        @echo "... cash2ecash.s"
diff --git a/build/cash2ecash b/build/cash2ecash
new file mode 100755
index 0000000..63c8338
Binary files /dev/null and b/build/cash2ecash differ
diff --git a/build/compile_commands.json b/build/compile_commands.json
index 13ba920..d393dd2 100644
--- a/build/compile_commands.json
+++ b/build/compile_commands.json
@@ -13,5 +13,10 @@
   "directory": 
"/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build/cashacceptor",
   "command": "/usr/bin/c++  
-I/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/src/include 
-g -o CMakeFiles/cashacceptor.dir/dg600f.cpp.o -c 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/src/cashacceptor/dg600f.cpp",
   "file": 
"/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/src/cashacceptor/dg600f.cpp"
+},
+{
+  "directory": 
"/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build/utils",
+  "command": "/usr/bin/c++  
-I/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/src/include 
-g -o CMakeFiles/utils.dir/timer.cpp.o -c 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/src/utils/timer.cpp",
+  "file": 
"/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/src/utils/timer.cpp"
 }
 ]
\ No newline at end of file
diff --git a/build/Makefile b/build/utils/Makefile
similarity index 58%
copy from build/Makefile
copy to build/utils/Makefile
index 350f19e..c0d15c6 100644
--- a/build/Makefile
+++ b/build/utils/Makefile
@@ -87,14 +87,14 @@ rebuild_cache/fast: rebuild_cache
 
 # The main all target
 all: cmake_check_build_system
-       $(CMAKE_COMMAND) -E cmake_progress_start 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build/CMakeFiles
 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build//CMakeFiles/progress.marks
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(CMAKE_COMMAND) -E cmake_progress_start 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build/CMakeFiles
 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build/utils//CMakeFiles/progress.marks
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 utils/all
        $(CMAKE_COMMAND) -E cmake_progress_start 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build/CMakeFiles
 0
 .PHONY : all
 
 # The main clean target
 clean:
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 utils/clean
 .PHONY : clean
 
 # The main clean target
@@ -103,68 +103,56 @@ clean/fast: clean
 
 # Prepare targets for installation.
 preinstall: all
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 utils/preinstall
 .PHONY : preinstall
 
 # Prepare targets for installation.
 preinstall/fast:
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 utils/preinstall
 .PHONY : preinstall/fast
 
 # clear depends
 depend:
-       $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 
--check-build-system CMakeFiles/Makefile.cmake 1
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 
--check-build-system CMakeFiles/Makefile.cmake 1
 .PHONY : depend
 
-#=============================================================================
-# Target rules for targets named cash2ecash
-
-# Build rule for target.
-cash2ecash: cmake_check_build_system
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 cash2ecash
-.PHONY : cash2ecash
-
-# fast build rule for target.
-cash2ecash/fast:
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/cash2ecash.dir/build.make 
CMakeFiles/cash2ecash.dir/build
-.PHONY : cash2ecash/fast
-
-#=============================================================================
-# Target rules for targets named cashacceptor
+# Convenience name for target.
+utils/CMakeFiles/utils.dir/rule:
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 utils/CMakeFiles/utils.dir/rule
+.PHONY : utils/CMakeFiles/utils.dir/rule
 
-# Build rule for target.
-cashacceptor: cmake_check_build_system
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 cashacceptor
-.PHONY : cashacceptor
+# Convenience name for target.
+utils: utils/CMakeFiles/utils.dir/rule
+.PHONY : utils
 
 # fast build rule for target.
-cashacceptor/fast:
-       $(MAKE) $(MAKESILENT) -f 
cashacceptor/CMakeFiles/cashacceptor.dir/build.make 
cashacceptor/CMakeFiles/cashacceptor.dir/build
-.PHONY : cashacceptor/fast
+utils/fast:
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(MAKE) $(MAKESILENT) -f utils/CMakeFiles/utils.dir/build.make 
utils/CMakeFiles/utils.dir/build
+.PHONY : utils/fast
 
-cash2ecash.o: cash2ecash.cpp.o
-.PHONY : cash2ecash.o
+timer.o: timer.cpp.o
+.PHONY : timer.o
 
 # target to build an object file
-cash2ecash.cpp.o:
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/cash2ecash.dir/build.make 
CMakeFiles/cash2ecash.dir/cash2ecash.cpp.o
-.PHONY : cash2ecash.cpp.o
+timer.cpp.o:
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(MAKE) $(MAKESILENT) -f utils/CMakeFiles/utils.dir/build.make 
utils/CMakeFiles/utils.dir/timer.cpp.o
+.PHONY : timer.cpp.o
 
-cash2ecash.i: cash2ecash.cpp.i
-.PHONY : cash2ecash.i
+timer.i: timer.cpp.i
+.PHONY : timer.i
 
 # target to preprocess a source file
-cash2ecash.cpp.i:
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/cash2ecash.dir/build.make 
CMakeFiles/cash2ecash.dir/cash2ecash.cpp.i
-.PHONY : cash2ecash.cpp.i
+timer.cpp.i:
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(MAKE) $(MAKESILENT) -f utils/CMakeFiles/utils.dir/build.make 
utils/CMakeFiles/utils.dir/timer.cpp.i
+.PHONY : timer.cpp.i
 
-cash2ecash.s: cash2ecash.cpp.s
-.PHONY : cash2ecash.s
+timer.s: timer.cpp.s
+.PHONY : timer.s
 
 # target to generate assembly for a file
-cash2ecash.cpp.s:
-       $(MAKE) $(MAKESILENT) -f CMakeFiles/cash2ecash.dir/build.make 
CMakeFiles/cash2ecash.dir/cash2ecash.cpp.s
-.PHONY : cash2ecash.cpp.s
+timer.cpp.s:
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(MAKE) $(MAKESILENT) -f utils/CMakeFiles/utils.dir/build.make 
utils/CMakeFiles/utils.dir/timer.cpp.s
+.PHONY : timer.cpp.s
 
 # Help Target
 help:
@@ -174,11 +162,10 @@ help:
        @echo "... depend"
        @echo "... edit_cache"
        @echo "... rebuild_cache"
-       @echo "... cash2ecash"
-       @echo "... cashacceptor"
-       @echo "... cash2ecash.o"
-       @echo "... cash2ecash.i"
-       @echo "... cash2ecash.s"
+       @echo "... utils"
+       @echo "... timer.o"
+       @echo "... timer.i"
+       @echo "... timer.s"
 .PHONY : help
 
 
@@ -190,6 +177,6 @@ help:
 # No rule that depends on this can have commands that come from listfiles
 # because they might be regenerated.
 cmake_check_build_system:
-       $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 
--check-build-system CMakeFiles/Makefile.cmake 0
+       cd 
/home/manuel/Dokumente/Studium/BTE5512_Projektarbeit/cash2ecash/build && 
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) 
--check-build-system CMakeFiles/Makefile.cmake 0
 .PHONY : cmake_check_build_system
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8e9478a..02261d9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,10 +1,13 @@
 cmake_minimum_required(VERSION 3.2)
 project(cash2ecash)
 add_compile_options(-g)
+
+
 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 
 add_executable(cash2ecash cash2ecash.cpp)
 
+
 include_directories(include)
 
 add_subdirectory(cashacceptor)
@@ -12,6 +15,8 @@ add_subdirectory(bank)
 add_subdirectory(extern)
 add_subdirectory(gui)
 add_subdirectory(identification)
+add_subdirectory(utils)
 
 
 target_link_libraries(cash2ecash PRIVATE cashacceptor)
+target_link_libraries(cash2ecash PRIVATE utils)
diff --git a/src/cash2ecash.cpp b/src/cash2ecash.cpp
index ac33a6d..03cf69b 100644
--- a/src/cash2ecash.cpp
+++ b/src/cash2ecash.cpp
@@ -3,36 +3,61 @@
 #include <iostream>
 #include <ostream>
 
+
+
 #include "cashacceptors.hpp"
+#include "utils.hpp"
 
 
 // Global Definitions
-enum state_e { INIT, SLEEP, IDLE, CONNECTION, ACCEPTCASH, CONFIRMATION, DONE };
+enum state_e { INIT, SLEEP, IDLE, CONNECTION, ACCEPTCASH, DONE };
 enum state_e state = INIT;
 
-
+char test;
+char *string;
 
 int main(int argc, char *argv[]){
+  char serialpath[] = "/dev/ttyAMA3";
   std::cout << "The Program is running" <<std::endl;
+  DG600F cashacceptor(serialpath);
+  Timer timer1;
+  timer1.setTimeMillis(10000);
+  TALER_Amount testamount;
 
-  switch (state) {
-  case INIT:
-    break;
-  case SLEEP:
-    break;
-  case IDLE:
-    break;
-  case CONNECTION:
-    break;
-  case ACCEPTCASH:
-    break;
-  case CONFIRMATION:
-    break;
-  case DONE:
-    break;
-  default:
-    std::cout << "ERROR: unhandeled state" << std::endl;
-    break;
+  while (true) {
+    switch (state) {
+    case INIT:
+      state = ACCEPTCASH;
+      timer1.start();
+      break;
+    case SLEEP:
+      break;
+    case IDLE:
+      break;
+    case CONNECTION:
+      break;
+    case ACCEPTCASH:
+      cashacceptor.startMoneyAcceptance();
+      if (timer1.over()) {
+       cashacceptor.stopMoneyAcceptance();
+       cashacceptor.readAccumulated(&testamount);
+       string = TALER_amount_to_string(&testamount);
+       printf("%s\n",string);
+       free(string);
+       cashacceptor.readFIFO(&testamount);
+       string = TALER_amount_to_string(&testamount);
+       printf("%s", string);
+       
+      }
+      
+      break;
+    case DONE:
+      break;
+    default:
+      std::cout << "ERROR: unhandeled state" << std::endl;
+      break;
+    }
   }
   
+  
 }
diff --git a/src/cashacceptor/CMakeLists.txt b/src/cashacceptor/CMakeLists.txt
index 7c21362..cae12b4 100644
--- a/src/cashacceptor/CMakeLists.txt
+++ b/src/cashacceptor/CMakeLists.txt
@@ -1,3 +1,9 @@
+set(CMAKE_CXX_EXTENSIONS ON)
+
+
 add_library(cashacceptor cashacceptor.cpp
                         dg600f.cpp)
 
+target_link_libraries(cashacceptor PRIVATE
+                                  gnunetutil
+                                  talerutil)
diff --git a/src/cashacceptor/cashacceptor.hpp 
b/src/cashacceptor/cashacceptor.hpp
index 2f72072..334f197 100644
--- a/src/cashacceptor/cashacceptor.hpp
+++ b/src/cashacceptor/cashacceptor.hpp
@@ -1,8 +1,14 @@
 #ifndef CASHACCEPTOR_H
 #define CASHACCEPTOR_H
 
+// Exclude some headers to avoid errors compiling in cpp
+//#define GNUNET_STRINGS_LIB_H
+//#define TALER_CRYPTO_LIB_H
+
+//Allow to directly include amount lib, might lead to other bugs..
+#define __TALER_UTIL_LIB_H_INSIDE__
 extern "C" {
-#include <taler/taler_util.h>
+#include <taler/taler_amount_lib.h>
 }
 
 #include <vector>
diff --git a/src/cashacceptor/dg600f.cpp b/src/cashacceptor/dg600f.cpp
index b52bf7d..3e5ddd3 100644
--- a/src/cashacceptor/dg600f.cpp
+++ b/src/cashacceptor/dg600f.cpp
@@ -94,7 +94,7 @@ int DG600F::startMoneyAcceptance(){
   //TODO stop Inhibiting
   //Start thread which waits for chars...
   flagSerialListenRun = true;
-  std::thread tr(&DG600F::serialListenThread, fd);
+  std::thread tr(&DG600F::serialListenThread, this, fd);
   return 0;
   }
 
diff --git a/src/cashacceptor/dg600f.hpp b/src/cashacceptor/dg600f.hpp
index 6e535cd..d78389d 100644
--- a/src/cashacceptor/dg600f.hpp
+++ b/src/cashacceptor/dg600f.hpp
@@ -21,9 +21,7 @@
 
 
 
-extern "C" {
-#include <taler/taler_util.h>
-}
+
 
 #include "cashacceptor.hpp"
 
@@ -38,6 +36,8 @@ private:
   
 
   int configSerial(int fd, int baudrate);
+  void serialListenThread(int fd);
+  TALER_Amount convertAmount(char amount);
 
 protected:
 
@@ -57,8 +57,7 @@ public:
   int stopMoneyAcceptance();
   int readAccumulated(TALER_Amount *retval);
   int readFIFO(TALER_Amount *retval);
-  void serialListenThread(int fd);
-  TALER_Amount convertAmount(char amount);
+  
   
 
 
diff --git a/src/include/utils.hpp b/src/include/utils.hpp
new file mode 100644
index 0000000..8370373
--- /dev/null
+++ b/src/include/utils.hpp
@@ -0,0 +1 @@
+#include "../utils/timer.hpp"
diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt
new file mode 100644
index 0000000..f6fd0ff
--- /dev/null
+++ b/src/utils/CMakeLists.txt
@@ -0,0 +1 @@
+add_library(utils timer.cpp)
diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp
new file mode 100644
index 0000000..d3ea8fd
--- /dev/null
+++ b/src/utils/timer.cpp
@@ -0,0 +1 @@
+#include "timer.hpp"
diff --git a/src/utils/timer.hpp b/src/utils/timer.hpp
new file mode 100644
index 0000000..45ab4f4
--- /dev/null
+++ b/src/utils/timer.hpp
@@ -0,0 +1,22 @@
+#include <chrono>
+#include <ratio>
+
+
+class Timer{
+  private:
+  std::chrono::duration<int, std::ratio<1,1000>> duration_ms;
+  std::chrono::time_point<std::chrono::steady_clock> timepoint;
+  protected:
+  public:
+  void setTimeMillis(int time){
+    duration_ms = std::chrono::milliseconds(time);
+  }
+  
+  void start(){
+    timepoint = std::chrono::steady_clock::now();
+  }
+
+  bool over(){
+    return duration_ms >= (std::chrono::steady_clock::now() - timepoint);
+  }
+};

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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