TMSkipFamily Code Example

long session_handle;
unsigned char state_buffer[15360];
short result, cnt = 0, ROM[8];

/* session_handle set from a call to TMExtendedStartSession */
...

/* attempt to find the first device on 1-Wire network */
result = TMFirst(session_handle, state_buffer);

/* loop to count all of the devices that don't have the family code 0x0C on the 1-Wire network */
while (result == 1)
{
   /* read the ROM to see if need to skip */
   ROM[0] = 0; /* reset to read */
   result = TMRom(session_handle, state_buffer, ROM);
   if (result != 1)
      /* error, session not valid */

   if (ROM[0] == 0x0C)
   {
      /* skip this ROM */
      result = TMSkipFamily(session_handle, state_buffer);
      if (result != 1)
         /* error session not valid */
   }
   else
      cnt++;  /* count this device because not 0x0C */

   /* find next device */
   result = TMNext(session_handle, state_buffer);
}

/* close the session with a call to TMEndSession */
...