Пример #1
0
static int wince_get_active_config_descriptor(
	struct libusb_device *device,
	unsigned char *buffer, size_t len, int *host_endian)
{
	struct wince_device_priv *priv = _device_priv(device);
	DWORD actualSize = len;
	*host_endian = 0;
	if (!UkwGetConfigDescriptor(priv->dev, UKW_ACTIVE_CONFIGURATION, buffer, len, &actualSize)) {
		return translate_driver_error(GetLastError());
	}
	return actualSize;
}
Пример #2
0
static int wince_get_config_descriptor(
	struct libusb_device *device,
	uint8_t config_index,
	unsigned char *buffer, size_t len, int *host_endian)
{
	struct wince_device_priv *priv = _device_priv(device);
	DWORD actualSize = len;

	*host_endian = 0;
	if (!UkwGetConfigDescriptor(priv->dev, config_index, buffer, len, &actualSize))
		return translate_driver_error(GetLastError());

	return actualSize;
}
Пример #3
0
static void requestConfigurationDescriptor(char line[])
{
    // Parse the device index
    DWORD devIdx = 0;
    line = parseNumber(line, devIdx);
    if (!line) {
        printf("Please provide a decimal device number following the command\n");
        return;
    }
    if (devIdx >= gDeviceListSize || devIdx < 0) {
        printf("Invalid device index '%d' provided\n", devIdx);
        return;
    }
    // Parse the optional configuration number
    DWORD configuration = UKW_ACTIVE_CONFIGURATION;
    line = parseNumber(line, configuration);

    // Parse the optional buffer size number
    DWORD bufferLength = MAX_CONFIG_BUFFER;
    if (line) {
        // See if there is another parameter for buffer length
        line = parseNumber(line, bufferLength);
        if (bufferLength > MAX_CONFIG_BUFFER) {
            printf("Provided buffer length is too large, the maximum is %d\n", MAX_CONFIG_BUFFER);
            return;
        }
    }

    // Print the command which is about to be issued
    if (configuration == UKW_ACTIVE_CONFIGURATION) {
        printf("No configuration specified, reading active configuration from device %d, length %d\n",
               devIdx, bufferLength);
    } else {
        printf("Requesting descriptor for configuration %d from device %d, length %d\n",
               configuration, devIdx, bufferLength);
    }

    // All parameters decoded, issue command
    UKW_DEVICE device = gDeviceList[devIdx];
    unsigned char descBuf[MAX_CONFIG_BUFFER];
    DWORD descLength = 0;
    BOOL status = UkwGetConfigDescriptor(device, configuration, descBuf, bufferLength, &descLength);
    if (status) {
        printf("Retrieved descriptor of length %d\n", descLength);
        printHexDump(descBuf, descLength);
    } else {
        printf("Failed to retrieve configuration descriptor with error %d\n", GetLastError());
    }
}