X-Git-Url: http://git.smho.de/gw/?a=blobdiff_plain;f=src%2FowInterface.h;h=7e1edb09d1a9d453980d3b465553f6bfe1a86d01;hb=8b3ce8126a8bbc16822e939bc46f513e1c52b3d3;hp=952f3dce3778025964cb79c3b6f1677655ea1996;hpb=039b202e5c68834801d23e22eecc7cae2879ea83;p=owTools.git diff --git a/src/owInterface.h b/src/owInterface.h old mode 100755 new mode 100644 index 952f3dc..7e1edb0 --- a/src/owInterface.h +++ b/src/owInterface.h @@ -34,12 +34,28 @@ #ifndef __OWINTERFACES_H_ #define __OWINTERFACES_H_ +#if defined(WIN) || defined(LINUX) +#else +#if defined(_WINDOWS) || defined(__WINDOWS__) || defined(_WIN32) || defined(WIN32) +#define WIN +#else +#define LINUX +#endif +#endif + + #include #include #include +#ifdef LINUX #include +#endif #include +#ifdef WIN +#include + +#endif class owDevice; class owDeviceConfig; @@ -48,7 +64,7 @@ class owDeviceConfig; #if defined(_WINDOWS) || defined(__WINDOWS__) || defined(_WIN32) || defined(WIN32) #define USE_WINDOWS_TIME 1 #include - #include "win32/usb.h" // libusb header + //#include "win32/usb.h" // libusb header #else #define USE_WINDOWS_TIME 0 #include @@ -68,6 +84,29 @@ class owDeviceConfig; #define OWLOG_WARNING 2 #define OWLOG_ERROR 3 +#ifdef LINUX + +#define BLUE_B "\033[1;34m" +#define COLOR_E "\033[0m" +#define C2_B "\033[0;36m" +#define C3_B "\033[3;34m" +#define C4_B "\033[1;33m" +#define C5_B "\033[4;33m" +#define CLE_B "\033[1;31m" +#define CLW_B "\033[1;33m" +#endif +#ifdef WIN +#define BLUE_B "" +#define C2_B "" +#define C3_B "" +#define C4_B "" +#define COLOR_E "" +#define C5_B "" +#define CLE_B "" +#define CLW_B "" + +#endif + class owLog { int lcount; std::string logtext; @@ -84,14 +123,19 @@ public: va_list arg; int done; va_start (arg, format); +#ifdef LINUX done = vsprintf (s, format, arg); +#endif +#ifdef WIN + done = vsprintf_s(s,300, format, arg); +#endif va_end (arg); logtext=s; level=llevel; lcount++; if (level>=loglevel) { - if (loglevel==OWLOG_ERROR) printf("\033[1;31m%s\033[0m\n",s); - else if (loglevel==OWLOG_WARNING) printf("\033[1;33m%s\033[0m\n",s); + if (loglevel==OWLOG_ERROR) printf(CLE_B "%s" COLOR_E "\n",s); + else if (loglevel==OWLOG_WARNING) printf(CLW_B "%s" COLOR_E "\n",s); else printf("%s\n",s); } return done; @@ -188,9 +232,9 @@ public: uint16_t calcCRC16(std::vector data); int testCRC16(std::vector data); - void resetFlasher(); - void resetID(); - int programmPage(int pagenr, std::vector page, int pagesize); + void resetFlasher(uint64_t id); + void resetID(uint64_t id); + int programmPage(uint64_t id,int pagenr, std::vector page, int pagesize); int flashHEXFile(std::string filename,snum_t dev,int resetid,int progress); @@ -241,6 +285,9 @@ public: void changeID(snum_t nid); void runFlasher(); virtual int convertAll() {return 1;} + virtual int readMemory(int page,int start, int count,std::vector *data) {return 0;}; + virtual int writeMemory(int page,int start, int count,std::vector *data) {return 0;}; + virtual int getPageSize() {return 0;} virtual ~owDevice() {} }; @@ -250,6 +297,7 @@ public: virtual void setDefaultConfig(); int readScratchpad(std::vector *sp); virtual int convertAll(); + virtual int getPageSize() {return 8;} } ; @@ -260,8 +308,10 @@ public: int setConfigByte(uint8_t cb); int readScratchpad(std::vector *sp, uint8_t page, int recall); - + virtual int readMemory(int page,int start, int count,std::vector *data); + virtual int writeMemory(int page,int start, int count,std::vector *data); virtual int convertAll(); + virtual int getPageSize() {return 8;} } ; class owDeviceDS2450:public owDevice { @@ -273,6 +323,7 @@ public: void readMemory(uint8_t addr,std::vector *sp); void writeMemory(uint8_t addr,std::vector *sp); void convert(uint8_t mask, uint8_t preset); + virtual int getPageSize() {return 8;} } ; @@ -284,6 +335,10 @@ public: virtual void setDefaultConfig(); virtual int convertAll(); uint32_t readCounter(uint8_t page); + virtual int readMemory(int page,int start, int count,std::vector *data); + virtual int writeMemory(int page,int start, int count,std::vector *data); + virtual int getPageSize() {return 32;} + } ;