printf(" [prefix] -> a prefix of all tables \n\n");
printf(" -r Search every time for new Devices\n");
printf(" -t [text_file] append comma separadet to text-file\n");
+printf(" -j Use 0xCC 0x44 to send convert temperature to all DS18B20 and DS2438\n");
printf(" -f [hexfile] flash new\n");
printf(" -n [\"id as 64bit Hex\"] change id \n");
printf(" example: -n \"5D02160084D9A220\" \n");
for (owDevice* dev :*devices) {
for(int k=0;k<owi->maxrepeat;k++){
- //std::vector<uint8_t> data;
- //data.push_back(0xCC);
- //data.push_back(0x44);
- //owi->Reset();
- //owi->Communicate(&data, 2, 0);
+ if (owCC_44_Temp>0) {
+ std::vector<uint8_t> data;
+ data.push_back(0xCC);
+ data.push_back(0x44);
+ owi->Reset();
+ owi->Communicate(&data, 2, 0);
+ }
dev->convertAll();
if (owi->log->last()<OWLOG_ERROR) break;
owi->log->clear();
interactive(owi);
} else
if (getArg("c")=="1") {
+ if (getArg("j")=="1") {
+ printf("Use 1-Wire command 0xCC 0x44 to send convert temperature to all DS18B20 and DS2438\n");
+ owCC_44_Temp=1;
+ }
int reload=(getArg("r")=="1");
owi->Find();
printf("\n");
} else {
unsigned long long l=strtoull(s.c_str(),NULL,16);
if ((snum.num&0xFF)!=(l&0xFF)) {
- printf("ERROR: Family of Device 0x%02X->0x%02X can not be changed\n",(int)(snum.num&0xFF),(int)(l&0xFF));
- exit(1);
+ printf("This command change family-fode of Device 0x%02X->0x%02X\n",(int)(snum.num&0xFF),(int)(l&0xFF));
+ int resetid=questionYesNo("Are you sure?");
+ if (resetid==0) {
+ printf("ERROR: Family of Device 0x%02X->0x%02X can not be changed\n",(int)(snum.num&0xFF),(int)(l&0xFF));
+ exit(1);
+ }
}
snum.num=l;
//printf("->%016llX\n",(unsigned long long)l);
-// Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
+// Copyright (c) 2019, Tobias Mueller tm(at)tm3d.de\r
// All rights reserved.\r
//\r
// Redistribution and use in source and binary forms, with or without\r
void owDevice::changeID(snum_t nid) {\r
int i;\r
if (nid.byte[0] != snum.byte[0]) {\r
- owi->log->set(OWLOG_ERROR,"Family ID should not be changed, no correct ID");\r
- return;\r
+ owi->log->set(OWLOG_WARNING,"Family ID should not be changed, no correct ID");\r
+ //return;\r
}\r
std::vector<uint8_t> id;\r
for(i=0;i<7;i++) id.push_back(nid.byte[i]);\r
\r
int owDeviceDS18B20::convertAll() {\r
std::vector<uint8_t> sp;\r
- sp.push_back(0x44);\r
- Communicate(&sp, 1, 0); ///########################################################\r
- usleep(750000);\r
-\r
+ if (owCC_44_Temp==0) {\r
+ sp.push_back(0x44);\r
+ Communicate(&sp, 1, 0); ///########################################################\r
+ usleep(750000);\r
+ }\r
if (readScratchpad(&sp)) {\r
int16_t tsht;\r
tsht = sp[0] | ((int)sp[1] << 8);\r
tsht |= 0xFFFFF0000;\r
raw[0]=tsht;\r
values[0]=config->calculateValue(0, raw);\r
- return 1;\r
+ return 1;\r
} \r
return 0;\r
}\r
int owDeviceDS2438::convertAll() {\r
for(int k=0;k<owi->maxrepeat;k++) {\r
std::vector<uint8_t> sp;\r
- sp.push_back(0x44);\r
- Communicate(&sp, 1, 0);///########################################################\r
- if (owi->log->last()>=OWLOG_ERROR) continue;\r
- usleep(100000);\r
+ if (owCC_44_Temp==0) {\r
+ sp.push_back(0x44);\r
+ Communicate(&sp, 1, 0);///########################################################\r
+ if (owi->log->last()>=OWLOG_ERROR) continue;\r
+ usleep(100000);\r
+ }\r
if (setConfigByte(0x08)<=0) continue;\r
for(int k=0;k<owi->maxrepeat;k++) {\r
sp.clear();\r
return 0;\r
}\r
std::vector<uint8_t> sp;\r
- readMemory(0,&sp);\r
+ readMemory(0,0,8,&sp);\r
if (owi->log->last()>=OWLOG_WARNING) {\r
return 0;\r
}\r
\r
}\r
\r
-void owDeviceDS2450::readMemory(uint8_t addr,std::vector<uint8_t> *sp) {\r
+int owDeviceDS2450::readMemory(int page,int start, int count,std::vector<uint8_t> *data) {\r
+ std::vector<uint8_t> cl;\r
+ cl.push_back(0xAA);\r
+ cl.push_back(page*8+start);\r
+ cl.push_back(0x00);\r
+ Communicate(&cl,3,10-start);\r
+ if (owi->log->last()>=OWLOG_WARNING) {\r
+ return 0;\r
+ }\r
+ if (!owi->testCRC16(cl)) {\r
+ for (uint8_t v :cl) printf("%02X ",v);\r
+ printf("\n");\r
+ owi->log->set(OWLOG_ERROR,"CRC ERROR Reading Memory of DS2450");\r
+ return 0;\r
+ }\r
+ data->clear();\r
+ data->insert(data->begin(),cl.begin()+3,cl.end()-2);\r
+ return count;\r
+}\r
+int owDeviceDS2450::writeMemory(int page,int start, int count,std::vector<uint8_t> *data) {\r
+ std::vector<uint8_t> cl;\r
+ cl.push_back(0x55);\r
+ cl.push_back(page*8+start);\r
+ cl.push_back(0x00);\r
+ owi->MatchRom(snum);\r
+ if (owi->log->last()>=OWLOG_WARNING) {\r
+ return 0;\r
+ }\r
+ int i=0;\r
+ for(uint8_t b: (*data)) {\r
+ cl.push_back(b);\r
+ owi->Communicate(&cl,cl.size(),2);\r
+ if (owi->log->last()>=OWLOG_WARNING) {\r
+ return 0;\r
+ }\r
+ if (i>0) {\r
+ if (!owi->testCRC16(cl,i+page*8+start)) {\r
+ owi->log->set(OWLOG_ERROR,"CRC ERROR Writing Memory of DS2450");\r
+ return 0;\r
+ }\r
+ } else {\r
+ if (!owi->testCRC16(cl)) {\r
+ owi->log->set(OWLOG_ERROR,"CRC ERROR Writing Memory of DS2450");\r
+ return 0;\r
+ }\r
+ }\r
+ cl.clear();\r
+ owi->Communicate(&cl, 0, 1);\r
+ if (owi->log->last()>=OWLOG_WARNING) {\r
+ return 0;\r
+ }\r
+ if (cl[0] != b) {\r
+ owi->log->set(OWLOG_ERROR,"ERROR Writing Memory of DS2450");\r
+ return 0;\r
+ }\r
+ cl.clear();\r
+ i++;\r
+ }\r
+ return count;\r
+}\r
+\r
+\r
+void owDeviceDS2450::readMemory_int(uint8_t addr,std::vector<uint8_t> *sp) {\r
std::vector<uint8_t> cl;\r
cl.push_back(0xAA);\r
cl.push_back(addr);\r
sp->insert(sp->begin(),cl.begin()+3,cl.end()-2);\r
}\r
\r
-void owDeviceDS2450::writeMemory(uint8_t addr,std::vector<uint8_t> *sp) {\r
+void owDeviceDS2450::writeMemory_int(uint8_t addr,std::vector<uint8_t> *sp) {\r
std::vector<uint8_t> cl;\r
cl.push_back(0x55);\r
cl.push_back(addr);\r
#endif
+extern uint8_t owCC_44_Temp;
+
class owLog {
int lcount;
std::string logtext;
uint8_t calcCRC8(std::vector<uint8_t> data);
uint16_t calcCRC16(std::vector<uint8_t> data);
int testCRC16(std::vector<uint8_t> data);
+ int testCRC16(std::vector<uint8_t> data,uint16_t load);
void resetFlasher(uint64_t id);
void resetID(uint64_t id);
virtual void setDefaultConfig();
virtual int convertAll();
- void readMemory(uint8_t addr,std::vector<uint8_t> *sp);
- void writeMemory(uint8_t addr,std::vector<uint8_t> *sp);
+ 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);
+ void readMemory_int(uint8_t addr,std::vector<uint8_t> *sp);
+ void writeMemory_int(uint8_t addr,std::vector<uint8_t> *sp);
void convert(uint8_t mask, uint8_t preset);
virtual int getPageSize() {return 8;}