User manual

Technical reference 18
Copyright 2004 Pico Technology Limited. All rights reserved.
// could terminate the application here
}
// No errors, so start polling usb_tc08_open_unit_progress
// continuously for its enumeration state
do
{
result =
usb_tc08_open_unit_progress
(&handle, &progress);
switch
(result)
{
case
USBTC08_PROGRESS_FAIL:
// enum equates to: -1
error_code =
usb_tc08_get_last_error
(
0
);
printf(
"Unit failed to open\nThe error code is %d"
, error_code);
// could terminate the application here
break
;
case
USBTC08_PROGRESS_PENDING:
// enum equates to: 0
printf(
"\nThe unit is %d percent enumerated"
, progress);
Sleep(
500
);
// wait for approx. half a second
break
;
case
USBTC08_PROGRESS_COMPLETE:
// enum equates to: 1
printf(
"\n\nThe unit with handle '%d', opened successfully"
, handle);
break
;
}
}
while
(result == USBTC08_PROGRESS_PENDING);
//
// Start using the open unit
//
3.3.2.3 usb_tc08_open_unit_progress
short usb_tc08_open_unit_progress( short * handle,
short * progress)
This function should be called after
usb_tc08_open_unit_async
. Repeatedly call this function
to determine the state of the background enumeration process. For an example of usage, see
usb_tc08_open_unit_async
.
Arguments:
handle
(Out) A handle (positive short) to the unit if the enumeration is
completed. Handle will always be 0 if the enumeration is incomplete.
progress
(Out) (Optional - can pass NULL) returns a number from 0 to 100
representing the percentage completion of the enumeration of one
unit.