Larger Timeout for Serial
authorTobias <tm@tm3d.de>
Mon, 21 Aug 2017 08:13:59 +0000 (10:13 +0200)
committerTobias <tm@tm3d.de>
Mon, 21 Aug 2017 08:13:59 +0000 (10:13 +0200)
src/main.cpp
src/owCOMInterface.cpp

index 9a998e2..2e7e655 100755 (executable)
@@ -124,7 +124,9 @@ printf("            [database]\n");
 printf("            [prefix] -> a prefix of all tables \n\n");
 printf("      -r Search every time for new Devices\n");
 printf("   -f [hexfile]    flash new\n");
-printf("   -n change id   \n");
+printf("   -n [\"id as 64bit Hex\"] change id   \n");
+printf("               example: -n \"5D02160084D9A220\" \n");
+printf("               no argument increments id by 256 (keep family code) \n");
 printf("      -g get from server\n");
 printf("   -w [1|2] show Warnings (1) or all information (2)\n");
 printf("   -m memory functions\n");
@@ -463,7 +465,7 @@ int main(int argc, char *argv[]) {
        if(adapter.find("COM")!=std::string::npos) {
                owi=new owCOMInterface();
                int port=atoi(adapter.substr(adapter.find("COM")+3).c_str());
-               printf("Open /dev/ttyS%i\n",port);
+               printf("Open /dev/ttyUSB%i\n",port);
                owi->InitAdapter(port);
        } else 
        if(adapter.find("USB")!=std::string::npos) {
@@ -676,6 +678,7 @@ int main(int argc, char *argv[]) {
                sel-=1;
                
                snum_t snum=owi->devices[sel]->getNum();
+               
                if ((getArg("g"))=="1") {
                        printf("get ID from Server\n");
                        char s[255];
@@ -720,7 +723,18 @@ int main(int argc, char *argv[]) {
                                snum.num=isnum.num;
                        } else (printf("ERROR %i\n",err));
                } else {
-                       snum.num+=256;
+                       if (s=="1") {
+                               snum.num+=256;
+                       } else {
+                               unsigned long long l=strtol(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);
+                               }
+                               snum.num=l;
+                               //printf("->%016llX\n",(unsigned long long)l);
+                       }
+                       
                }
 
 
index b825b6e..6b55e94 100755 (executable)
@@ -331,7 +331,7 @@ int owCOMInterface::ReadCOM( int inlen, uint8_t *inbuf)
       FD_SET(fd,&filedescr);
       // set timeout to 10ms
       tval.tv_sec = 0;
-      tval.tv_usec = 10000;
+      tval.tv_usec = 20000;
 
       // if byte available read or return bytes read
       if (select(fd+1,&filedescr,NULL,NULL,&tval) != 0)
@@ -343,7 +343,7 @@ int owCOMInterface::ReadCOM( int inlen, uint8_t *inbuf)
          }
       }
       else {
-               log->set(OWLOG_ERROR,"Read Error on Serial (select)");
+               log->set(OWLOG_ERROR,"Read Error on Serial (select) (new time)");
         return cnt;
        }
    }
@@ -428,7 +428,7 @@ void owCOMInterface::SetBaudCOM( uint8_t new_baud)
       close(fd);
   }
 }
-
 
 //---------------------------------------------------------------------------
 // Attempt to resyc and detect a DS2480B