From: Tobias Date: Wed, 28 Feb 2018 15:36:47 +0000 (+0100) Subject: Memory access for DS2423 X-Git-Url: https://git.smho.de/?a=commitdiff_plain;h=385ca6e4fbf0ecb17fa2eb2a8f5d0a91811a754a;p=owTools.git Memory access for DS2423 --- diff --git a/src/main.cpp b/src/main.cpp index de17078..0a6ccbd 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -663,14 +663,14 @@ int main(int argc, char *argv[]) { //snum_t snum=owi->devices[sel]->getNum(); owDevice* dev=owi->devices[sel]; if(s.find("read")!=std::string::npos) { - int r=dev->readMemory(pnr,0,8,&mem); + int r=dev->readMemory(pnr,0,dev->getPageSize(),&mem); for(int i=0;iwriteMemory(pnr,0,8,&mem); - r=dev->readMemory(pnr,0,8,&mem); + int r=dev->writeMemory(pnr,0,dev->getPageSize(),&mem); + r=dev->readMemory(pnr,0,dev->getPageSize(),&mem); for(int i=0;i *data){ + std::vector cl; + cl.push_back(0xF0); + uint16_t adr=page<<5; + cl.push_back(adr&0xFF); + cl.push_back((adr>>8)&0xFF); + Communicate(&cl, 3, 32); + //No CRC + data->clear(); + data->insert(data->begin(),cl.begin()+3+start,cl.begin()+start+3+count); + return count; + +} +int owDeviceDS2423::writeMemory(int page,int start, int count,std::vector *data) { + std::vector cl; + cl.push_back(0x0F); + uint16_t adr=(page<<5)+start; + cl.push_back(adr&0xFF); + cl.push_back(adr>>8); + for(int i=0;ilog->set(OWLOG_ERROR,"DS2423 Copy from Scratchpad to Memmory Error"); + //return 0; + } + return count; +} + diff --git a/src/owInterface.h b/src/owInterface.h index 664de85..7e1edb0 100755 --- a/src/owInterface.h +++ b/src/owInterface.h @@ -287,6 +287,7 @@ public: 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() {} }; @@ -296,6 +297,7 @@ public: virtual void setDefaultConfig(); int readScratchpad(std::vector *sp); virtual int convertAll(); + virtual int getPageSize() {return 8;} } ; @@ -309,6 +311,7 @@ public: 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 { @@ -320,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;} } ; @@ -331,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;} + } ;