From c73a17eb105a48a1ee5f7d072005ab32b7f97d72 Mon Sep 17 00:00:00 2001 From: atomega Date: Fri, 9 Apr 2021 22:16:03 +0100 Subject: [PATCH] Added the error implmentation in ./communication/i2c/i2c.cpp and started with Doxygen --- developpment/communication/i2c/i2c.cpp | 4 +- developpment/communication/i2c/i2c.hpp | 3 +- developpment/communication/i2c/i2c_linux.hpp | 36 +- developpment/management/errorHandling.cpp | 1 - training/doxygen/$ | 68 + training/doxygen/Makefile | 20 + training/doxygen/device.cpp | 13 + training/doxygen/device.hpp | 68 + training/doxygen/device.o | Bin 0 -> 764 bytes training/doxygen/doxyConf | 2494 +++++++++++++++++ training/doxygen/html/_formulas.tex | 8 + training/doxygen/html/annotated.html | 78 + training/doxygen/html/bc_s.png | Bin 0 -> 676 bytes training/doxygen/html/bdwn.png | Bin 0 -> 147 bytes .../doxygen/html/classDevice-members.html | 79 + training/doxygen/html/classDevice.html | 147 + training/doxygen/html/classes.html | 82 + training/doxygen/html/closed.png | Bin 0 -> 132 bytes training/doxygen/html/device_8hpp_source.html | 75 + training/doxygen/html/doc.png | Bin 0 -> 746 bytes training/doxygen/html/doxygen.css | 1596 +++++++++++ training/doxygen/html/doxygen.png | Bin 0 -> 3779 bytes training/doxygen/html/dynsections.js | 97 + training/doxygen/html/files.html | 78 + training/doxygen/html/folderclosed.png | Bin 0 -> 616 bytes training/doxygen/html/folderopen.png | Bin 0 -> 597 bytes training/doxygen/html/functions.html | 74 + training/doxygen/html/functions_func.html | 74 + training/doxygen/html/graph_legend.dot | 22 + training/doxygen/html/graph_legend.html | 102 + training/doxygen/html/graph_legend.md5 | 1 + training/doxygen/html/index.html | 73 + training/doxygen/html/jquery.js | 87 + training/doxygen/html/menu.js | 26 + training/doxygen/html/menudata.js | 10 + training/doxygen/html/nav_f.png | Bin 0 -> 153 bytes training/doxygen/html/nav_g.png | Bin 0 -> 95 bytes training/doxygen/html/nav_h.png | Bin 0 -> 98 bytes training/doxygen/html/open.png | Bin 0 -> 123 bytes training/doxygen/html/search/all_0.html | 26 + training/doxygen/html/search/all_0.js | 5 + training/doxygen/html/search/classes_0.html | 26 + training/doxygen/html/search/classes_0.js | 4 + training/doxygen/html/search/close.png | Bin 0 -> 273 bytes training/doxygen/html/search/functions_0.html | 26 + training/doxygen/html/search/functions_0.js | 4 + training/doxygen/html/search/mag_sel.png | Bin 0 -> 563 bytes training/doxygen/html/search/nomatches.html | 12 + training/doxygen/html/search/search.css | 271 ++ training/doxygen/html/search/search.js | 791 ++++++ training/doxygen/html/search/search_l.png | Bin 0 -> 604 bytes training/doxygen/html/search/search_m.png | Bin 0 -> 158 bytes training/doxygen/html/search/search_r.png | Bin 0 -> 612 bytes training/doxygen/html/search/searchdata.js | 21 + training/doxygen/html/splitbar.png | Bin 0 -> 314 bytes training/doxygen/html/sync_off.png | Bin 0 -> 853 bytes training/doxygen/html/sync_on.png | Bin 0 -> 845 bytes training/doxygen/html/tab_a.png | Bin 0 -> 142 bytes training/doxygen/html/tab_b.png | Bin 0 -> 169 bytes training/doxygen/html/tab_h.png | Bin 0 -> 177 bytes training/doxygen/html/tab_s.png | Bin 0 -> 184 bytes training/doxygen/html/tabs.css | 1 + training/doxygen/interfacer.cpp | 17 + training/doxygen/interfacer.o | Bin 0 -> 1900 bytes training/doxygen/latex/Makefile | 21 + training/doxygen/latex/annotated.tex | 4 + training/doxygen/latex/classDevice.tex | 101 + training/doxygen/latex/doxygen.sty | 503 ++++ training/doxygen/latex/refman.tex | 155 + training/doxygen/runtest | Bin 0 -> 8480 bytes 70 files changed, 7382 insertions(+), 22 deletions(-) create mode 100644 training/doxygen/$ create mode 100644 training/doxygen/Makefile create mode 100644 training/doxygen/device.cpp create mode 100644 training/doxygen/device.hpp create mode 100644 training/doxygen/device.o create mode 100644 training/doxygen/doxyConf create mode 100644 training/doxygen/html/_formulas.tex create mode 100644 training/doxygen/html/annotated.html create mode 100644 training/doxygen/html/bc_s.png create mode 100644 training/doxygen/html/bdwn.png create mode 100644 training/doxygen/html/classDevice-members.html create mode 100644 training/doxygen/html/classDevice.html create mode 100644 training/doxygen/html/classes.html create mode 100644 training/doxygen/html/closed.png create mode 100644 training/doxygen/html/device_8hpp_source.html create mode 100644 training/doxygen/html/doc.png create mode 100644 training/doxygen/html/doxygen.css create mode 100644 training/doxygen/html/doxygen.png create mode 100644 training/doxygen/html/dynsections.js create mode 100644 training/doxygen/html/files.html create mode 100644 training/doxygen/html/folderclosed.png create mode 100644 training/doxygen/html/folderopen.png create mode 100644 training/doxygen/html/functions.html create mode 100644 training/doxygen/html/functions_func.html create mode 100644 training/doxygen/html/graph_legend.dot create mode 100644 training/doxygen/html/graph_legend.html create mode 100644 training/doxygen/html/graph_legend.md5 create mode 100644 training/doxygen/html/index.html create mode 100644 training/doxygen/html/jquery.js create mode 100644 training/doxygen/html/menu.js create mode 100644 training/doxygen/html/menudata.js create mode 100644 training/doxygen/html/nav_f.png create mode 100644 training/doxygen/html/nav_g.png create mode 100644 training/doxygen/html/nav_h.png create mode 100644 training/doxygen/html/open.png create mode 100644 training/doxygen/html/search/all_0.html create mode 100644 training/doxygen/html/search/all_0.js create mode 100644 training/doxygen/html/search/classes_0.html create mode 100644 training/doxygen/html/search/classes_0.js create mode 100644 training/doxygen/html/search/close.png create mode 100644 training/doxygen/html/search/functions_0.html create mode 100644 training/doxygen/html/search/functions_0.js create mode 100644 training/doxygen/html/search/mag_sel.png create mode 100644 training/doxygen/html/search/nomatches.html create mode 100644 training/doxygen/html/search/search.css create mode 100644 training/doxygen/html/search/search.js create mode 100644 training/doxygen/html/search/search_l.png create mode 100644 training/doxygen/html/search/search_m.png create mode 100644 training/doxygen/html/search/search_r.png create mode 100644 training/doxygen/html/search/searchdata.js create mode 100644 training/doxygen/html/splitbar.png create mode 100644 training/doxygen/html/sync_off.png create mode 100644 training/doxygen/html/sync_on.png create mode 100644 training/doxygen/html/tab_a.png create mode 100644 training/doxygen/html/tab_b.png create mode 100644 training/doxygen/html/tab_h.png create mode 100644 training/doxygen/html/tab_s.png create mode 100644 training/doxygen/html/tabs.css create mode 100644 training/doxygen/interfacer.cpp create mode 100644 training/doxygen/interfacer.o create mode 100644 training/doxygen/latex/Makefile create mode 100644 training/doxygen/latex/annotated.tex create mode 100644 training/doxygen/latex/classDevice.tex create mode 100644 training/doxygen/latex/doxygen.sty create mode 100644 training/doxygen/latex/refman.tex create mode 100755 training/doxygen/runtest diff --git a/developpment/communication/i2c/i2c.cpp b/developpment/communication/i2c/i2c.cpp index 4f0c6e4..2c6d8b0 100644 --- a/developpment/communication/i2c/i2c.cpp +++ b/developpment/communication/i2c/i2c.cpp @@ -46,7 +46,7 @@ uint8_t I2C::readBuffer(const uint8_t& address, const uint8_t& buffer, uint8_t l return i2cPimpl->readBuffer(address,buffer,len); } -int8_t I2C::getError() +void I2C::throwError(I2C::errors errNo) { - return i2cPimpl->getError(); + i2cPimpl->throwError(errNo); } diff --git a/developpment/communication/i2c/i2c.hpp b/developpment/communication/i2c/i2c.hpp index be2c3e1..0eb9d73 100644 --- a/developpment/communication/i2c/i2c.hpp +++ b/developpment/communication/i2c/i2c.hpp @@ -29,12 +29,11 @@ class I2C uint8_t writeWord(const uint8_t& address, const uint8_t& reg, const uint8_t& data); uint8_t writeBuffer(const uint8_t& address, const uint8_t& buffer, uint8_t len); uint8_t readBuffer(const uint8_t& address, const uint8_t& buffer, uint8_t len); - int8_t getError(); private: + void throwError(errors errNo); struct i2cImpl; std::unique_ptr i2cPimpl; - }; #endif // _I2C_H_ #define _I2C_H_ diff --git a/developpment/communication/i2c/i2c_linux.hpp b/developpment/communication/i2c/i2c_linux.hpp index de31a7d..6c7368c 100644 --- a/developpment/communication/i2c/i2c_linux.hpp +++ b/developpment/communication/i2c/i2c_linux.hpp @@ -17,31 +17,30 @@ struct I2C::i2cImpl uint8_t blocks; uint8_t channel; uint8_t mode; - int8_t error; - + uint8_t status; i2cImpl() { char filename[20]; - errors currentError = noError; + snprintf(filename, 19, "/dev/i2c-%d", 1); deviceDescriptor = open(filename, O_RDWR); if (deviceDescriptor < 0) { - error = initFailed; + throwError(initFailed); } } uint8_t readByte(const uint8_t& address, const uint8_t& reg) { if (ioctl(deviceDescriptor, I2C_SLAVE, address) < 0) { - error = falseAddrs; + throwError(falseAddrs); } writeByte(address,reg); //Initiate a write to indicate the desired register to read if (read(deviceDescriptor, recieve_buffer, 1) != 1) // An then initare a read request of 1 byte { - error = readFailed; + throwError(writeFailed); } return recieve_buffer[0] ; } @@ -51,14 +50,14 @@ struct I2C::i2cImpl uint16_t result = 0 ; if (ioctl(deviceDescriptor, I2C_SLAVE, address) < 0) { - error = falseAddrs; + throwError(falseAddrs); } writeByte(address,reg); //Initiate a write to indicate the desired register to read if (read(deviceDescriptor, recieve_buffer, 2) != 2) // An then initare a read request of 2 bytes { - error = readFailed; + throwError(writeFailed); } result = (recieve_buffer[0] << 8) + recieve_buffer[1] ; return result ; @@ -68,14 +67,14 @@ struct I2C::i2cImpl { if (ioctl(deviceDescriptor, I2C_SLAVE, address) < 0) { - error = falseAddrs; + throwError(falseAddrs); } send_buffer[0] = data; if ((write(deviceDescriptor, send_buffer, 1)) != 1) { - error = writeFailed; + throwError(writeFailed); } return 0; } @@ -84,7 +83,7 @@ struct I2C::i2cImpl { if (ioctl(deviceDescriptor, I2C_SLAVE, address) < 0) { - error = falseAddrs; + throwError(falseAddrs); } send_buffer[0] = reg; @@ -92,7 +91,7 @@ struct I2C::i2cImpl if ((write(deviceDescriptor, send_buffer, 2)) != 2) { - error = writeFailed; + throwError(writeFailed); } return 0; } @@ -101,14 +100,14 @@ struct I2C::i2cImpl { if (ioctl(deviceDescriptor, I2C_SLAVE, address) < 0) { - error = falseAddrs; + throwError(falseAddrs); } send_buffer[0] = buffer; if ((write(deviceDescriptor, send_buffer, len)) != len) { - error = writeFailed; + throwError(writeFailed); } return 0; } @@ -118,9 +117,12 @@ struct I2C::i2cImpl return 0; } - int8_t getError() - { - return 0; + void throwError(I2C::errors errNo) + { + #ifdef LINUX + std::cout << "Linux i2c Error" << std::endl; + exit(1); + #endif } }; #endif // _I2C_LINUX_H_ diff --git a/developpment/management/errorHandling.cpp b/developpment/management/errorHandling.cpp index 5adac38..f4636d6 100644 --- a/developpment/management/errorHandling.cpp +++ b/developpment/management/errorHandling.cpp @@ -48,7 +48,6 @@ void ErrorHandler::addNewError(const int& no, const std::string& source, const s // // Privat memeber functions -// int ErrorHandler::getLookUpIndex(int errNo, std::string source) { diff --git a/training/doxygen/$ b/training/doxygen/$ new file mode 100644 index 0000000..0a018b8 --- /dev/null +++ b/training/doxygen/$ @@ -0,0 +1,68 @@ +/** + * \class Device + * + * \ingroup Devices + * + * \brief Device driver + * + * This class is meant as an example. It is not useful by itself + * rather its usefulness is only a function of how much it helps + * the reader. It is in a sense defined by the person who reads it + * and otherwise does not exist in any real form. + * + * \note We are triying somthing + * + * \author (last to touch it) $Kerem : bv $ + * + * \version $Revision: 1.5 $ + * + * \date $Date: 2021/04/09 $ + * + * Contact: yokyok + * + * Created on: Wed Apr 13 18:39:37 2005 + * + * $Id: doxygen-howto.html,v 1.5 2005/04/14 14:16:20 bv Exp $ + * + */ + + + +#ifndef _DEVICE_H_ +#define _DEVICE_H_ + +#include +#include +#include + +/** + * @brief Device Class + * this calss defines a device. + * @author Edwin + * @date 2021 / 04 / 09 + * @version 1.0158 + */ + +class Device{ + + public: + Device(); + ~Device(); + + + /** + * @brief It \f$ \sum_{k=1}^n \f$ dose something \n it adds two thing together + * @author Kerem + * @date 2021 / 04 / 09 + * @version 1.0 + * @param uint8_t thing + * @return uint8_t retunrs thing + foo + */ + uint8_t doSomething(uint8_t thing); + + private: + uint8_t foo; +}; + + +#endif // _DEVICE_H_ diff --git a/training/doxygen/Makefile b/training/doxygen/Makefile new file mode 100644 index 0000000..c516ac5 --- /dev/null +++ b/training/doxygen/Makefile @@ -0,0 +1,20 @@ +cpp_src = $(wildcard *.cpp) + +cpp_obj = $(cpp_src:.cpp=.o) +c_obj = $(c_src:.c=.o) +CC = g++ +CFLAGS = -Wall -pedantic -li2c +LDFLAGS = +EXEC = runtest + + +all : $(EXEC) + +$(EXEC): $(cpp_obj) $(c_obj) + $(CC) -o $@ $^ $(LDFLAGS) + +clean: + rm -rf $(c_obj) $(cpp_obj) $(EXEC) + +cleanall: + rm -rf $(c_obj) $(cpp_obj) $(EXEC) diff --git a/training/doxygen/device.cpp b/training/doxygen/device.cpp new file mode 100644 index 0000000..e744688 --- /dev/null +++ b/training/doxygen/device.cpp @@ -0,0 +1,13 @@ +#include "device.hpp" + +Device::Device(): + foo(1) +{ + std::cout << "Init ok" << std::endl; +} + +uint8_t Device::doSomething(uint8_t thing) +{ + std::cout << "Addition complete" << std::endl; + return foo + thing; +} diff --git a/training/doxygen/device.hpp b/training/doxygen/device.hpp new file mode 100644 index 0000000..0642339 --- /dev/null +++ b/training/doxygen/device.hpp @@ -0,0 +1,68 @@ +/** + * \class Device + * + * \ingroup Devices + * + * \brief Device driver + * + * This class is meant as an example. It is not useful by itself + * rather its usefulness is only a function of how much it helps + * the reader. It is in a sense defined by the person who reads it + * and otherwise does not exist in any real form. + * + * \note We are triying somthing + * + * \author (last to touch it) $Kerem : bv $ + * + * \version $Revision: 1.5 $ + * + * \date $Date: 2021/04/09 $ + * + * Contact: yokyok + * + * Created on: Wed Apr 13 18:39:37 2005 + * + * $Id: doxygen-howto.html,v 1.5 2005/04/14 14:16:20 bv Exp $ + * + */ + + + +#ifndef _DEVICE_H_ +#define _DEVICE_H_ + +#include +#include +#include + +/** + * @brief Device Class + * this calss defines a device. + * @author Edwin + * @date 2021 / 04 / 09 + * @version 1.0158 + */ + +class Device{ + + public: + Device(); + ~Device(); + + + /** + * @brief It \f[ \sum_{k=1}^n \f] dose something \n it adds two thing together + * @author Kerem + * @date 2021 / 04 / 09 + * @version 1.0 + * @param uint8_t thing + * @return uint8_t retunrs thing + foo + */ + uint8_t doSomething(uint8_t thing); + + private: + uint8_t foo; +}; + + +#endif // _DEVICE_H_ diff --git a/training/doxygen/device.o b/training/doxygen/device.o new file mode 100644 index 0000000000000000000000000000000000000000..44cb5a5d93d56b55ea643555a4159ca0deec6f8d GIT binary patch literal 764 zcmah{-%A2P5T5n)Q0bw<=qF(jWTcx>N%SUSzElr_(Cgm0&{67fw?#eGWB+b{LCv^3 zbqe9Y+&ACOw>vYt_ujp^7D51TTkl{|cX z+g1DZW;z7$AeT)e_vUzEj_2pN4=~g(QK)4Y#{e>Y8yOWKn#AG*M@GLIkV9n@$RJHY zhLh1qk8y20F