X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device%2Fexamples%2Fds390%2Fow390%2Ftstow.c;h=2a2d585bc709edf144570f67c5fa9c4f4b01b97d;hb=10c9f9db0ff831a36b97b4b648c3fe64a20add7e;hp=cd68247f4abdd30803d9745146be6080946db257;hpb=3dd7456daf476cb6ec13317c808b3abbe85c76de;p=fw%2Fsdcc diff --git a/device/examples/ds390/ow390/tstow.c b/device/examples/ds390/ow390/tstow.c old mode 100755 new mode 100644 index cd68247f..2a2d585b --- a/device/examples/ds390/ow390/tstow.c +++ b/device/examples/ds390/ow390/tstow.c @@ -81,7 +81,7 @@ int main() //short argc, char **argv) //---------------------------------------- // Introduction printf("\n/---------------------------------------------\n"); - printf(" The following is a test excersize of the\n" + printf(" The following is a test excersize of the\n" " 1-Wire Net public domain library Version 2.00.\n\n" " This test was run using with 2 DS1920's (DS1820),\n" " 1 DS1971 (DS2430), and 1 DS1996.\n\n"); @@ -109,8 +109,12 @@ int main() //short argc, char **argv) owFamilySearchSetup(portnum,0x0C); - // find the next device - printf("search result %d\n",owNext(portnum,TRUE, FALSE)); + // find the first 0x0c device + TempSerialNum[0]=0; + while (TempSerialNum[0]!=0x0c && owNext(portnum,TRUE,FALSE)) { + owSerialNum(portnum,TempSerialNum,TRUE); + } + printf("search result %d\n",TempSerialNum[0]==0x0c); // print the Serial Number of the device just found PrintSerialNum(portnum); @@ -158,7 +162,7 @@ int main() //short argc, char **argv) for (j = 0; j < 4; j++) { for (i = 0; i < 29; i++) - tran_buffer[i] = (uchar)i + j; + tran_buffer[i] = (uchar)i + j; printf("Write page %d: %d\n",j,owWritePacketStd(portnum,j,tran_buffer,29,FALSE,FALSE)); @@ -183,10 +187,11 @@ int main() //short argc, char **argv) for (i = 0; i < 2000; i++) tran_buffer[i] = i % 255; printf("Format and write file DEMO.000 %d\n", - owFormatWriteFile(portnum,filename,2000,tran_buffer)); + owFormatWriteFile(portnum,filename,2000,tran_buffer)); + // clear the buffer for (i = 0; i < 2000; i++) - tran_buffer[i] = 0; + tran_buffer[i] = 0x55; printf("Read file DEMO.000 %d\n",owReadFile(portnum,filename,tran_buffer)); // print the data result for (i = 0; i < 2000; i++)