User manual

USB TC-08 Help17
Copyright 2004 Pico Technology Limited. All rights reserved.
// could terminate the application here
}
//
// Start using the open units
//
3.3.2.2 usb_tc08_open_unit_async
short usb_tc08_open_unit_async (void)
This routine begins enumerating USB TC-08 units in the background and provides a return
immediately, so the calling thread can continue executing other code.
Note: The driver is thread safe and will not allow access to a single unit from more than one application.
If, therefore,
usb_tc08_open_unit_async
does not find a unit, check that other applications are
not using the same USB TC-08. This includes applications on other user accounts on the same
computer, where fast user switching is supported.
Arguments
None
Returns:
1
- The call was successful.
0
- No more units were found.
-1
- An error occurred, call
usb_tc08_get_last_error
with a handle of 0 to obtain the error
code.
Example
The following code is a fragment of a C application which demonstrates how to open a single unit with
the asynchronous open unit functions:
//======================================================
// Opening a unit asynchronously
//======================================================
// Tell the driver to start enumerating the unit in the background
// (usb_tc08_open_unit_async returns immediately)
result =
usb_tc08_open_unit_async
();
// handle any error conditions
if
(result == -
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
}
else
if
(result ==
0
)
{
printf(
"No USB TC08 units found"
);