commit 45e84c1875551b19c0d6839a528c941720769f4f
parent 9e8c5fb992e69c6f9dca0deb1535c93f02752b17
Author: Manuel Geissbühler <manuel@debian>
Date: Mon, 16 Dec 2024 16:40:25 +0100
added draft of serial configuration
Diffstat:
9 files changed, 165 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,6 @@
+*.[oa]
+*~
+.*/
+CMakeFiles/
+*.png
+*.cmake
diff --git a/.gitmodules b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "src/extern/lvgl"]
+ path = src/extern/lvgl
+ url = https://github.com/lvgl/lvgl.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
diff --git a/cash2ecash.cpp b/cash2ecash.cpp
@@ -0,0 +1,37 @@
+// This is the main function for the cash2ecash program
+
+#include <cstdio>
+#include <iostream>
+#include <ostream>
+
+
+// Global Definitions
+enum state_e { INIT, SLEEP, IDLE, CONNECTION, ACCEPTCASH, CONFIRMATION, DONE };
+enum state_e state = INIT;
+
+
+
+int main(int argc, char *argv[]){
+ std::cout << "The Program is running" <<std::endl;
+
+ 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;
+ }
+
+}
diff --git a/src/cashacceptor/cashacceptor.cpp b/src/cashacceptor/cashacceptor.cpp
diff --git a/src/cashacceptor/cashacceptor.hpp b/src/cashacceptor/cashacceptor.hpp
@@ -0,0 +1,40 @@
+#ifndef CASHACCEPTOR_H
+#define CASHACCEPTOR_H
+
+extern "C" {
+#include <taler/taler_util.h>
+}
+
+#include <vector>
+
+
+
+class Cashaccepor
+{
+ private:
+
+
+ protected:
+ TALER_Amount accumulatedAmmount;
+ std::vector<TALER_Amount> amountFIFO;
+
+ public:
+ Cashaccepor(){};
+ virtual int clearAccumulatedAmount();
+ virtual int startMoneyAcceptance();
+ virtual int stopMoneyAcceptance();
+ virtual int readAccumulated(TALER_Amount *retval);
+ virtual int readFIFO(TALER_Amount *retval);
+
+
+};
+
+
+
+
+
+
+
+
+
+#endif //CASHACCEPTOR_H
diff --git a/src/cashacceptor/dg600f.cpp b/src/cashacceptor/dg600f.cpp
@@ -0,0 +1,40 @@
+
+
+#include "dg600f.hpp"
+#include <termios.h>
+
+int DG600F::configSerial(int fd, int baudrate){
+ struct termios t;
+ if (tcgetattr(fd, &t) != 0){
+ std::cerr << "Error from tcgattr: " << strerror(errno) << std::endl;
+ return -1;
+ }
+
+
+ cfsetispeed(&t, baudrate);
+
+ t.c_cflag = (t.c_cflag & ~CSIZE) | CS8; //Configure 8 databits
+ t.c_iflag = t.c_iflag &= ~IGNBRK; //Disable break processing
+ t.c_lflag = 0; //no signaling chars, no echo, no canonical processing
+ t.c_cc[VMIN] = 0; //set minimum character for noncanonical read to 0
+ t.c_cc[VTIME] = 1; //Set read timeout for noncanonical read to 0.1 seconds
+ t.c_iflag = ~(IXON | IXOFF| IXANY); // shut off xon/xoff ctrl
+ t.c_cflag |= (CLOCAL | CREAD); // ignore modem controls enable reading
+ t.c_cflag |= PARENB; //enable parity
+ t.c_cflag &= ~PARODD; //set parity to even
+ t.c_cflag &= ~CSTOPB; //disable two stop bits
+
+ if (tcsetattr(fd, TCSANOW, &t) != 0) {
+ std::cerr << "Error from tcsetattr: " << strerror(errno)
+ << std::endl;
+ return -1;
+ }
+
+
+
+ return 0;
+}
+
+
+
+
diff --git a/src/cashacceptor/dg600f.hpp b/src/cashacceptor/dg600f.hpp
@@ -0,0 +1,38 @@
+#ifndef DG600F_H
+#define DG600F_H
+
+#include <cstdlib>
+#include <cstring>
+#include <errno.h>
+#include <fcntl.h>
+#include <iostream>
+#include <termios.h>
+#include <unistd.h>
+
+extern "C" {
+#include <taler/taler_util.h>
+}
+
+#include "cashacceptor.hpp"
+
+
+class DG600F : public Cashaccepor {
+private:
+ char *portPath;
+
+ int configSerial(int fd, int baudrate);
+
+
+
+protected:
+
+public:
+ DG600F(char * serialPortPath) : Cashaccepor(){};
+
+
+
+
+
+};
+
+#endif //DG600F_H
diff --git a/src/extern/lvgl b/src/extern/lvgl
@@ -0,0 +1 @@
+Subproject commit 6decbb7f7783f6e48d4591fcb9f7810c2fb08e61