//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;i<r;i++) printf("%02X ",mem[i]);
printf("\n");
exit(0);
} else
if(s.find("write")!=std::string::npos) {
- int r=dev->writeMemory(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<r;i++) printf("%02X ",mem[i]);
printf("\n");
exit(0);
}
+int owDeviceDS2423::readMemory(int page,int start, int count,std::vector<uint8_t> *data){
+ std::vector<uint8_t> 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<uint8_t> *data) {
+ std::vector<uint8_t> 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;i<count;i++) {
+ cl.push_back((*data)[i]);
+ }
+ Communicate(&cl, 3+count, 0);
+ for (uint8_t v :cl) printf("%02X ",v);printf("\n");
+ cl.clear();
+ cl.push_back(0xAA);
+ Communicate(&cl, 1, 36);
+ //for (uint8_t v :cl) printf("%02X ",v);;printf("\n");
+ cl[0]=0x5A;
+ Communicate(&cl, 4, 1);
+ usleep(100000);
+ if (cl[4]!=0xAA) {
+ for (uint8_t v :cl) printf("%02X ",v);;printf("\n");
+ owi->log->set(OWLOG_ERROR,"DS2423 Copy from Scratchpad to Memmory Error");
+ //return 0;
+ }
+ return count;
+}
+
virtual int convertAll() {return 1;}
virtual int readMemory(int page,int start, int count,std::vector<uint8_t> *data) {return 0;};
virtual int writeMemory(int page,int start, int count,std::vector<uint8_t> *data) {return 0;};
+ virtual int getPageSize() {return 0;}
virtual ~owDevice() {}
};
virtual void setDefaultConfig();
int readScratchpad(std::vector<uint8_t> *sp);
virtual int convertAll();
+ virtual int getPageSize() {return 8;}
} ;
virtual int readMemory(int page,int start, int count,std::vector<uint8_t> *data);
virtual int writeMemory(int page,int start, int count,std::vector<uint8_t> *data);
virtual int convertAll();
+ virtual int getPageSize() {return 8;}
} ;
class owDeviceDS2450:public owDevice {
void readMemory(uint8_t addr,std::vector<uint8_t> *sp);
void writeMemory(uint8_t addr,std::vector<uint8_t> *sp);
void convert(uint8_t mask, uint8_t preset);
+ virtual int getPageSize() {return 8;}
} ;
virtual void setDefaultConfig();
virtual int convertAll();
uint32_t readCounter(uint8_t page);
+ virtual int readMemory(int page,int start, int count,std::vector<uint8_t> *data);
+ virtual int writeMemory(int page,int start, int count,std::vector<uint8_t> *data);
+ virtual int getPageSize() {return 32;}
+
} ;