detect.c

00001 /*=========================================================================
00002 | (c) 2005-2008  Total Phase, Inc.
00003 |--------------------------------------------------------------------------
00004 | Project : Cheetah Examples
00005 | File    : detect.c
00006 |--------------------------------------------------------------------------
00007 | Simple Cheetah Device Detection Example
00008 |--------------------------------------------------------------------------
00009 | Redistribution and use of this file in source and binary forms, with
00010 | or without modification, are permitted.
00011 |
00012 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00013 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00014 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00015 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
00016 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00017 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00018 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00019 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00020 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00021 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00022 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00023 | POSSIBILITY OF SUCH DAMAGE.
00024  ========================================================================*/
00025 
00026 //=========================================================================
00027 // INCLUDES
00028 //=========================================================================
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 #include <string.h>
00032 #include "cheetah.h"
00033 
00034 
00035 //=========================================================================
00036 // GENERIC DETECTION ROUTINE
00037 //=========================================================================
00038 static void _find_devices ()
00039 {
00040     u16 ports[16];
00041     u32 unique_ids[16];
00042     int nelem = 16;
00043 
00044     // Find all the attached devices
00045     int count = ch_find_devices_ext(nelem, ports, nelem, unique_ids);
00046     int i;
00047 
00048     printf("%d device(s) found:\n", count);
00049 
00050     // Print the information on each device
00051     if (count > nelem)  count = nelem;
00052     for (i = 0; i < count; ++i) {
00053         // Determine if the device is in-use
00054         const char *status = "(avail) ";
00055         if (ports[i] & CH_PORT_NOT_FREE) {
00056             ports[i] &= ~CH_PORT_NOT_FREE;
00057             status = "(in-use)";
00058         }
00059 
00060         // Display device port number, in-use status, and serial number
00061         printf("    port=%-3d %s (%04d-%06d)\n",
00062                ports[i], status,
00063                unique_ids[i]/1000000,
00064                unique_ids[i]%1000000);
00065     }
00066 }
00067 
00068 
00069 //=========================================================================
00070 // MAIN PROGRAM ENTRY POINT
00071 //=========================================================================
00072 int main (int argc, char *argv[])
00073 {
00074     printf("Searching for Cheetah adapters...\n");
00075     _find_devices();
00076     printf("\n\n");
00077 
00078     return 0;
00079 }
Generated on Sun May 8 08:42:06 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3