int owDeviceDS18B20::convertAll() {
std::vector<uint8_t> sp;
- sp.push_back(0x44);
- Communicate(&sp, 1, 0);
+ //sp.push_back(0x44);
+ //communicate(&sp, 1, 0); ///########################################################
usleep(750000);
if (readScratchpad(&sp)) {
int owDeviceDS2438::convertAll() {
for(int k=0;k<owi->maxrepeat;k++) {
std::vector<uint8_t> sp;
- sp.push_back(0x44);
- Communicate(&sp, 1, 0);
+ //sp.push_back(0x44);
+ //Communicate(&sp, 1, 0);///########################################################
if (owi->log->last()>=OWLOG_ERROR) continue;
usleep(100000);
if (setConfigByte(0x08)<=0) continue;
return;
}
if (!owi->testCRC16(cl)) {
+ for (uint8_t v :cl) printf("%02X ",v);
+ printf("\n");
owi->log->set(OWLOG_ERROR,"CRC ERROR Reading Memory of DS2450");
return;
}
cl.push_back(preset);
Communicate(&cl, 3, 2);
if (!owi->testCRC16(cl)) {
+ for (uint8_t v :cl) printf("%02X ",v);
+ printf("\n");
owi->log->set(OWLOG_ERROR,"CRC ERROR Convert Command of DS2450");
return;
}
return calcCRC16(data)==0xB001;\r
}\r
\r
-void owInterface::resetFlasher() { // go back from Bootloader\r
+void owInterface::resetFlasher(uint64_t id) { // go back from Bootloader\r
std::vector<uint8_t> data;\r
data.push_back(0x89);\r
Wait_Free();\r
snum_t snum;\r
- snum.num=0xfa55aa55aa55aaa3;\r
+ snum.num=id;\r
MatchRom(snum);\r
if (log->last()==OWLOG_ERROR) {Free(); return;}\r
Communicate(&data, 1, 0);\r
usleep(50); \r
}\r
\r
-void owInterface::resetID() {\r
+void owInterface::resetID(uint64_t id) {\r
std::vector<uint8_t> data;\r
data.push_back(0x8B);\r
Wait_Free();\r
snum_t snum;\r
- snum.num=0xfa55aa55aa55aaa3;\r
+ snum.num=id;\r
MatchRom(snum);\r
if (log->last()==OWLOG_ERROR) {Free(); return;}\r
Communicate(&data, 1, 0);\r
Free();\r
}\r
\r
-int owInterface::programmPage(int pagenr, std::vector<uint8_t> page, int pagesize) {\r
+int owInterface::programmPage(uint64_t id,int pagenr, std::vector<uint8_t> page, int pagesize) {\r
snum_t snum;\r
- snum.num=0xfa55aa55aa55aaa3;\r
+ snum.num=id;\r
// printf("programm page %i",pagenr);\r
\r
\r
if (hf->lastError==1) {log->set(OWLOG_ERROR,"CRC Error in HEX-File %s",filename.c_str());return -1;}\r
if (hf->lastError==2) {log->set(OWLOG_ERROR,"Error interpreting HEX-File %s",filename.c_str());return -2;}\r
if (hf->lastError==3) {log->set(OWLOG_ERROR,"File could not be opened: %s",filename.c_str());return -3;}\r
- unsigned int blcount=hf->getBlockCount(64);\r
- if (blcount>118) {\r
- log->set(OWLOG_ERROR,"Code to big, max 7552 Byte allowed (118 Pages). Code has %i pages!",blcount);\r
- return -5;\r
- }\r
+ \r
log->set(OWLOG_INFO,"Try to start Bootloader on device %llX",dev.num);\r
int r=maxrepeat+1;\r
int found;\r
found=1;\r
break;\r
} \r
+ if (dev->getNum().num==0x8A57AA57AA57AAA3) {\r
+ found=2;\r
+ break;\r
+ } \r
}\r
if (found==0) log->set(OWLOG_WARNING,"Bootloader not found");\r
r--;\r
log->set(OWLOG_ERROR,"Can not start Bootloader on this device %llX",dev.num);\r
return -4;\r
}\r
+ \r
+ unsigned int blcount=0;\r
+ \r
+ int blsize=64;\r
+ uint64_t id=0;\r
+ \r
+ if (found==1) {\r
+ log->set(OWLOG_INFO,"Bootloader on ATtiny84A found. Pagesize = 64 bytes");\r
+ blsize=64;\r
+ blcount=hf->getBlockCount(64);\r
+ id=0xfa55aa55aa55aaa3;\r
+ if (blcount>118) {\r
+ log->set(OWLOG_ERROR,"Code to big, max 7552 Byte allowed (118 Pages). Code has %i pages!",blcount);\r
+ return -5;\r
+ }\r
+ }\r
+ if (found==2) {\r
+ log->set(OWLOG_INFO,"Bootloader on ATmega328PB found. Pagesize = 128 bytes");\r
+ blsize=128; \r
+ blcount=hf->getBlockCount(128);\r
+ id=0x8A57AA57AA57AAA3;\r
+ if (blcount>248) {\r
+ log->set(OWLOG_ERROR,"Code to big, max 31744 Byte allowed (248 Pages). Code has %i pages!",blcount);\r
+ return -5;\r
+ }\r
+ \r
+ }\r
log->set(OWLOG_INFO,"Start Programm %i Pages",blcount);\r
int rp=0;\r
int er=0;\r
unsigned int i =0;\r
for ( i= 0; i < blcount; i++) {\r
- std::vector<uint8_t> blk = hf->getBlock(i*64, 64);\r
+ std::vector<uint8_t> blk = hf->getBlock(i*blsize, blsize);\r
int errc = maxrepeat*5;\r
while (errc != 0) {\r
log->clear();\r
- if (programmPage(i, blk, 64) >= 0) {\r
+ if (programmPage(id,i, blk,blsize) >= 0) {\r
if (progress) {printf("#");fflush(stdout);} \r
break;\r
}\r
} else {\r
if (resetid) {\r
log->set(OWLOG_INFO,"Set 1-Wire ID to ID in hexfile...",blcount); \r
- resetID();\r
+ resetID(id);\r
#ifdef LINUX\r
sleep(3);\r
#endif\r
#ifdef WIN\r
Sleep(3000);\r
#endif\r
- resetID(); \r
+ resetID( id); \r
#ifdef LINUX\r
sleep(3);\r
#endif\r
log->set(OWLOG_INFO,"Back from bootloader to normal device...",blcount); \r
\r
\r
- resetFlasher();\r
+ resetFlasher(id);\r
#ifdef LINUX\r
sleep(1); \r
#endif\r
#ifdef WIN\r
Sleep(1000);\r
#endif\r
- resetFlasher();\r
+ resetFlasher(id);\r
#ifdef LINUX\r
sleep(3);\r
#endif\r