From: Tobias Date: Thu, 21 Apr 2022 14:19:58 +0000 (+0200) Subject: insert DS2408 X-Git-Url: https://git.smho.de/?a=commitdiff_plain;ds=inline;p=owTools.git insert DS2408 --- diff --git a/src/owDevice.cpp b/src/owDevice.cpp index 096d6f5..d5683c1 100644 --- a/src/owDevice.cpp +++ b/src/owDevice.cpp @@ -676,5 +676,130 @@ int owDeviceDS2423::writeMemory(int page,int start, int count,std::vectorsetConfig({0,13, 0,13, 0,13, 0,13, 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}); + configstate=OWDCS_DEFAULT; +} +int owDeviceDS2408::convertAll() { + std::vector da; + /*da.push_back(0x11); + da.push_back(0x22); + da.push_back(0x34); + writeMemory(0,0x8b,3,&da); + readMemory(0,0x88,10,&da); + printf("\n____________________________\n"); + readChannelAccess(80,&da); + owi->log->clear(); + da.clear(); + da.push_back(0x11); + da.push_back(0x12); + da.push_back(0x31); + da.push_back(0x14); + da.push_back(0x55); + da.push_back(0x63); + da.push_back(0x70); + owi->log->clear(); + + writeChannelAccess(7,&da);*/ + return 1; +} +int owDeviceDS2408::readMemory(int page,int start, int count,std::vector *data) { + std::vector cl; + cl.push_back(0xF0); + cl.push_back(start&0xFF); + cl.push_back(start>>8); + if (start>=0x90) { + owi->log->set(OWLOG_WARNING,"DS2408 reading Register. Address value to hight"); + return 0; + } + count=0x90-start; + + Communicate(&cl, 3,count+2 ); + for (uint8_t v :cl) printf("%02X ",v);;printf("\n"); + if (!owi->testCRC16(cl)) { + owi->log->set(OWLOG_ERROR,"CRC ERROR Reading Register of DS2408"); + return 0; + } + data->clear(); + data->insert(data->begin(),cl.begin()+3+start,cl.begin()+start+3+count); + return count; + +} + +int owDeviceDS2408::writeMemory(int page,int start, int count,std::vector *data) { + std::vector cl; + cl.push_back(0xCC); + cl.push_back(start&0xFF); + cl.push_back(start>>8); + if ((start<0x8b)&&(start>0x8b)) { + owi->log->set(OWLOG_WARNING,"DS2408 writing Register. Address value not match 0x8B 0x8C 0x8D"); + return 0; + } + if ((142-start) *data) { + std::vector cl; + cl.push_back(0xF5); + Communicate(&cl, 1,34 ); + int read=0; + for (uint8_t v :cl) printf("%02X ",v);;printf("\n"); + if (!owi->testCRC16(cl)) { + owi->log->set(OWLOG_ERROR,"CRC ERROR Reading Register of DS2408"); + return 0; + } + read=32; + data->clear(); + data->insert(data->begin(),cl.begin()+1,cl.begin()+33); + + while (readCommunicate(&cl,0,34); + for (uint8_t v :cl) printf("%02X ",v);;printf("\n"); + if (!owi->testCRC16(cl)) { + owi->log->set(OWLOG_ERROR,"CRC ERROR Reading Register of DS2408"); + return read; + } + data->insert(data->begin()+read,cl.begin(),cl.begin()+32); + read+=32; + + } + + + return read; +} +int owDeviceDS2408::writeChannelAccess(int count, std::vector *data) { + std::vector cl; + cl.push_back(0x5A); + Communicate(&cl, 1,0 ); + for(int i=0;iCommunicate(&cl,2,2); + for (uint8_t v :cl) printf("%02X ",v);;printf("\n"); + } + return count; +} +int owDeviceDS2408::resetActivityLatches() { + return 1; +} + + + +