1 //============================================================================
5 // Copyright : Your copyright notice
6 // Description : Hello World in C++, Ansi-style
7 //============================================================================
23 #include <sys/types.h>
24 #include <sys/socket.h>
25 #include <netinet/in.h>
29 unsigned char conf2(const char *s) {
31 for (int i = 0; i < 2; i++) {
33 if ((s[i] >= '0') && (s[i] <= '9')) {
36 if ((s[i] >= 'A') && (s[i] <= 'F')) {
39 if ((s[i] >= 'a') && (s[i] <= 'f')) {
47 void strcpys(char *s, const char* d,bool up) {
48 if (strlen(d) > 7990) {
54 for (int i = 0; i<strlen(s); i++)
55 if ((s[i] >= 'a') && (s[i] <= 'z'))
60 int main(int argc, char *argv[]) {
63 uchar send_block[256];
74 strcpys(s, argv[1],true);
77 if (strncmp(s,"USB",3)==0) {adt = 6;}
78 if (strncmp(s, "COM", 3) == 0) { adt = 5; }
80 strcpy(s, argv[1] + 3);
81 sprintf(adapter, "DS2490-%s\0",s);
82 //sprintf(adapter, "{%s,%i}\0",s,adt);
83 printf("Open Port %s\n", argv[1]);
84 if ((portnum = owAcquireEx(adapter)) < 0) {
85 printf("ERROR \n", adt);
90 if ((argc == 2) && (mod == 1)) mod = 2;
92 strcpys(s, argv[2],true);
93 if (strncmp(s, "DC", 2) == 0) {
95 if (strlen(argv[3])>=16)
96 for (int i = 0; i < 16; i += 2) {
97 SNum[7 - (i / 2)] = conf2(argv[3] + i);
100 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]);
106 if ((mod == 3) && (argc>4)) {
107 strcpys(s, argv[4], true);
114 rslt = owFirst(portnum, TRUE, FALSE);
118 owSerialNum(portnum, &SNum[0], TRUE);
119 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]);
120 // 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]);
121 /* switch (SNum[0]) {
125 //TestDS2430(portnum,&SNum[0]);
127 //ResetDS2430(portnum,&SNum[0]);
128 //uchar id[]={0x14,0xF5 ,0xEA ,0x24 ,0x06 ,0x00 ,0x00 ,0x5E};
129 //SetIDDS2430(portnum,&SNum[0],id);
130 if (rw) WriteDS2430(portnum, &SNum[0]); else ReadDS2430(portnum, &SNum[0]);
131 //WriteDS2430(portnum,&SNum[0],"5E00000624EAF514.bin");
135 //TestDS2433(portnum,&SNum[0]);
136 //TestDS2433_reset(portnum,&SNum[0]);
138 if (rw) WriteDS2433(portnum, &SNum[0]); else ReadDS2433(portnum, &SNum[0]);
142 rslt = owNext(portnum, TRUE, FALSE);
146 owSerialNum(portnum, SNum, FALSE);
152 if (s[i + 1] == 'R') {
153 if (owAccess(portnum)) {
154 if (owBlock(portnum, FALSE, send_block, send_cnt)) {
155 for (int j = 0; j < send_cnt; j++) {
156 printf("%02X", send_block[j]);
160 else printf("ERROR RESET\n");
162 else printf("ERROR SEND\n");
165 if (s[i + 1] == 'P') {
168 msDelay(conf2(s + i));
174 send_block[send_cnt++] = conf2(s + i);
181 if (mod>0) owRelease(portnum);