long session_handle;
unsigned char state_buffer[15360];
short result, cnt = 0;
/* 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 on the 1-Wire network */
while (result > 0)
{
cnt++;
/* find next device */
result = TMNext(session_handle, state_buffer);
}
/* close the session with a call to TMEndSession */
...