Beispiel #1
0
/*----------------------------------------------------------------------
 * Find the first device with a particular family
 */
short FindFirstFamily(short family, long session_handle)
{
   short j;
   short ROM[9];
   
   /* set up to find the first device with family 'family */
   if (TMFamilySearchSetup(session_handle,&state_buffer,family) == 1)
   { 
      /* get first device in list with the specified family */
      if (TMNext(session_handle,state_buffer) == 1)
      {  
         /* read the rom number */
         ROM[0] = 0;
         TMRom(session_handle,state_buffer,ROM);   
         
         /* check if correct type */
         if ((family & 0x7F) == (ROM[0] & 0x7F))
         {
            printf("Serial ROM ID: ");  
            for (j = 7; j >= 0; j--)
               printf("%02X",ROM[j]);
            printf("\n\n");
            return 1;
         }        
      }
   }
     
   /* failed to find device of that type */
   return 0;                              
}
Beispiel #2
0
//--------------------------------------------------------------------------
// Setup the search algorithm to find a certain family of devices
// the next time a search function is called 'owNext'.
//
// 'portnum'       - number 0 to MAX_PORTNUM-1.  This number was provided to
//                   OpenCOM to indicate the port number.
// 'search_family' - family code type to set the search algorithm to find
//                   next.
//
void owFamilySearchSetup(int portnum, SMALLINT search_family)
{
   TMFamilySearchSetup(SessionHandle[portnum], StateBuffer[portnum], 
                       (short)search_family);
}