What does UsbPt104Enumerate return?

Post your C and C++ discussions here
Post Reply
chris660
Newbie
Posts: 0
Joined: Tue Sep 17, 2013 2:49 pm

What does UsbPt104Enumerate return?

Post by chris660 » Tue Sep 17, 2013 3:11 pm

One of the outputs of the UsbPt104Enumerate() funtion: char *details", is defined in the programming manual as:
details, a string buffer to receive a maximum of length characters
Unfortunately the manual doesn't define the format of the data that will be written to the buffer provided, just that the function outputs:
a list of all the attached PT-104 devices of the specified port type
Presumably this will be a list of device serial numbers (that can then be passed to UsbPt104OpenUnit() to open a device), but how is the list delimited? What's the output if there are no connected devices (empty string?)?

Can anyone help with answers to these questions?

Thanks, Chris.

Hitesh
Site Admin
Site Admin
Posts: 2845
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: What does UsbPt104Enumerate return?

Post by Hitesh » Mon Sep 23, 2013 11:35 am

Hi Chris,

If I include the following bits of code in the main function of the Console Example just for USB devices:

Code: Select all

PICO_STATUS status;
char details[100] = {NULL};
unsigned long length = 0;

/* Other bits of code */

if(USB)
	{
		status = UsbPt104Enumerate(&details[0], &length, CT_USB);

		printf("Units: %s\n", details);
		printf("Serial Length: %d\n", length);

                /* Proceed to attempt to open unit */
I get the following:
  • With 0 units connected:

    Units:
    Serial Length: 0
    Unable to open device. Status code: 0x3
  • With 1 unit connected:

    Units: USB:AY429/085
    Serial Length: 14
    USB PT-104 Opened.
    AY429/085
The string returned will be null terminated i.e. with '\0'

I hope this helps.
Hitesh

Technical Support Engineer

Post Reply