X-Git-Url: http://git.smho.de/gw/?p=owSlave2.git;a=blobdiff_plain;f=stest%2Fmain.cpp;fp=stest%2Fmain.cpp;h=0000000000000000000000000000000000000000;hp=c1ca42f56630c3538a98cfaa9f0209b75de6a167;hb=3608ace7dd5bd4fa5d7d49224ef770b21596092c;hpb=3f2aceaf525eeceff3baece206b2048bbf286c40 diff --git a/stest/main.cpp b/stest/main.cpp deleted file mode 100644 index c1ca42f..0000000 --- a/stest/main.cpp +++ /dev/null @@ -1,184 +0,0 @@ -//============================================================================ -// Name : owtools.cpp -// Author : -// Version : -// Copyright : Your copyright notice -// Description : Hello World in C++, Ansi-style -//============================================================================ - -#include -#include -using namespace std; -extern "C" { -#include -} - -#include -#include -#include -#include - - -#include -#include -#include -#include - - - -unsigned char conf2(const char *s) { - unsigned char b = 0; - for (int i = 0; i < 2; i++) { - b = b * 16; - if ((s[i] >= '0') && (s[i] <= '9')) { - b += s[i] - '0'; - } else - if ((s[i] >= 'A') && (s[i] <= 'F')) { - b += s[i] - 'A'+10; - } else - if ((s[i] >= 'a') && (s[i] <= 'f')) { - b += s[i] - 'a'+10; - } - - } - return b; -} - -void strcpys(char *s, const char* d,bool up) { - if (strlen(d) > 7990) { - strncpy(s, d, 7990); - s[200] = 0; - } - else strcpy(s, d); - if (up) { - for (int i = 0; i= 'a') && (s[i] <= 'z')) - s[i] += 'A' - 'a'; - } -} - -int main(int argc, char *argv[]) { - uchar SNum[8]; - int rslt, cnt, i; - uchar send_block[256]; - uchar send_cnt = 0; - int portnum; - char adapter[20]; - int found = 0; - int rw = 0; - int err = 0; - char s[8000]; - int adt = 0; - int mod = 0; - if (argc >= 2) { - strcpys(s, argv[1],true); - - - if (strncmp(s,"USB",3)==0) {adt = 6;} - if (strncmp(s, "COM", 3) == 0) { adt = 5; } - if (adt != 0) { - strcpy(s, argv[1] + 3); - sprintf(adapter, "DS2490-%s\0",s); - //sprintf(adapter, "{%s,%i}\0",s,adt); - printf("Open Port %s\n", argv[1]); - if ((portnum = owAcquireEx(adapter)) < 0) { - printf("ERROR \n", adt); - } - else mod = 1; - - } - if ((argc == 2) && (mod == 1)) mod = 2; - if (argc > 2) { - strcpys(s, argv[2],true); - if (strncmp(s, "DC", 2) == 0) { - if (argc > 3) { - if (strlen(argv[3])>=16) - for (int i = 0; i < 16; i += 2) { - SNum[7 - (i / 2)] = conf2(argv[3] + i); - - } - printf("Select: %02X%02X%02X%02X%02X%02X%02X%02X\n", SNum[7], SNum[6], SNum[5], SNum[4], SNum[3], SNum[2], SNum[1], SNum[0]); - mod = 3; - } - - } - } - if ((mod == 3) && (argc>4)) { - strcpys(s, argv[4], true); - mod = 4; - } - - } - - if (mod == 2) { - rslt = owFirst(portnum, TRUE, FALSE); - cnt = 0; - while (rslt) { - cnt++; - owSerialNum(portnum, &SNum[0], TRUE); - printf("%02X%02X%02X%02X%02X%02X%02X%02X\n", SNum[7], SNum[6], SNum[5], SNum[4], SNum[3], SNum[2], SNum[1], SNum[0]); - // fprintf(ft,"%02X%02X%02X%02X%02X%02X%02X%02X\n",SNum[7],SNum[6],SNum[5],SNum[4],SNum[3],SNum[2],SNum[1],SNum[0]); -/* switch (SNum[0]) { - - - case 0x14: { - //TestDS2430(portnum,&SNum[0]); - //scanf("%i",&i); - //ResetDS2430(portnum,&SNum[0]); - //uchar id[]={0x14,0xF5 ,0xEA ,0x24 ,0x06 ,0x00 ,0x00 ,0x5E}; - //SetIDDS2430(portnum,&SNum[0],id); - if (rw) WriteDS2430(portnum, &SNum[0]); else ReadDS2430(portnum, &SNum[0]); - //WriteDS2430(portnum,&SNum[0],"5E00000624EAF514.bin"); - break; - } - case 0x23: { - //TestDS2433(portnum,&SNum[0]); - //TestDS2433_reset(portnum,&SNum[0]); - //scanf("%i",&i); - if (rw) WriteDS2433(portnum, &SNum[0]); else ReadDS2433(portnum, &SNum[0]); - break; - } - }*/ - rslt = owNext(portnum, TRUE, FALSE); - } - } - if (mod == 4) { - owSerialNum(portnum, SNum, FALSE); - strcat(s, "_R"); - int len = strlen(s); - int i = 0; - while (i < len) { - if (s[i] == '_') { - if (s[i + 1] == 'R') { - if (owAccess(portnum)) { - if (owBlock(portnum, FALSE, send_block, send_cnt)) { - for (int j = 0; j < send_cnt; j++) { - printf("%02X", send_block[j]); - } - printf("\n"); - } - else printf("ERROR RESET\n"); - } - else printf("ERROR SEND\n"); - send_cnt = 0; - } - if (s[i + 1] == 'P') { - if (i + 2 < len) { - i += 2; - msDelay(conf2(s + i)); - - } - } - } - else { - send_block[send_cnt++] = conf2(s + i); - } - i += 2; - - - } - } - if (mod>0) owRelease(portnum); - - return 0; -}