Technical reference
16
© 2005 Pico Technology Limited. All rights reserved.
USBTC08044-2
3.3.2
New USB mode and legacy mode
3.3.2.1
usb_tc08_open_unit
short usb_tc08_open_unit (void)
This routine returns a valid handle to the USB TC-08 if the driver successfully opens it. If
the routine fais, see the error code explanations in the
you wish to use more than one USB TC-08, call this routine once for each unit connected
to the PC. The function will return 0 if there are no more units found. The driver is thread-
safe and will not allow access to a single unit from more than one application. If,
does not find a unit, check that other applications are
not using the USB TC-08. This includes applications on other user accounts on the same
computer, where fast user switching is supported.
function provides a simple way to open USB TC-08
units. However, the function call locks up the calling thread until the attached USB TC-08
unit has been fully enumerated. If a single-threaded application needs to perform
concurrent processing, such as displaying a progress bar, use
- No more units were found.
- Unit failed to open. Call
0 to obtain the error code.
The following code is a fragment of a C application which demonstrates how to open
multiple units with the USB TC-08 driver. The handles to the open units are stored in an
//======================================================
// Opening multiple units
//======================================================
// store the handle in an array
handle_array[i] = new_handle;
// deal with the error if there is one,
// if new_handle was zero, then there was no error
// and we reached the last available unit
"Unit failed to open\nThe error code is %d"
// could terminate the application here