1 //---------------------------------------------------------------------------
2 // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
18 // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
22 // Except as contained in this notice, the name of Dallas Semiconductor
23 // shall not be used except as stated in the Dallas Semiconductor
25 //---------------------------------------------------------------------------
27 // tstfind.C - Test application to search for all 1-Wire devices on 1-Wire
32 // 1.02 -> 1.03 Removed caps in #includes for Linux capatibility
33 // Removed "ds2480.h", <windows.h> and <conio.h>
34 // includes because not needed
35 // Added "ownet.h" include to define TRUE/FALSE
36 // Prompt to search again
37 // Changed to use Acquire/Release 1-Wire Net functions
38 // 1.03 -> 2.00 Changed 'MLan' to 'ow'. Added support for
39 // multiple ports. Don't stop loop at end of each
47 static void PrintSerialNum(int);
51 char *argv[]={__FILE__, "exow"};
53 //----------------------------------------------------------------------
56 int main() //short argc, char **argv)
62 // check for required port name
65 printf("1-Wire Net name required on command line!\n"
66 " (example: \"COM1\" (Win32 DS2480),\"/dev/cua0\" "
67 "(Linux DS2480),\"1\" (Win32 TMEX)\n");
71 // attempt to acquire the 1-Wire Net
72 if (!owAcquire(portnum,argv[1],return_msg))
74 printf("%s",return_msg);
79 printf("%s",return_msg);
81 //----------------------------------------
83 printf("\n/---------------------------------------------\n");
84 printf(" Loop to find all iButton on 1-Wire Net.\n\n");
88 printf("-------------------- Start of search\n");
91 // find the first device (all devices not just alarming)
92 rslt = owFirst(portnum, TRUE, FALSE);
95 // print the device number
99 // print the Serial Number of the device just found
100 PrintSerialNum(portnum);
102 // find the next device
103 rslt = owNext(portnum, TRUE, FALSE);
105 printf("-------------------- End of search\n\n");
108 while (!key_abort());
110 // release the 1-Wire Net
111 owRelease(portnum,return_msg);
112 printf("%s",return_msg);
118 //----------------------------------------------------------------------
119 // Read and print the Serial Number.
121 void PrintSerialNum(int portnum)
126 owSerialNum(portnum,serial_num,TRUE);
127 for (i = 7; i >= 0; i--)
128 printf("%02X",serial_num[i]);