Exemplo n.º 1
0
static int wince_clear_halt(
	struct libusb_device_handle *handle,
	unsigned char endpoint)
{
	struct wince_device_priv *priv = _device_priv(handle->dev);
	if (!UkwClearHaltHost(priv->dev, endpoint)) {
		return translate_driver_error(GetLastError());
	}
	if (!UkwClearHaltDevice(priv->dev, endpoint)) {
		return translate_driver_error(GetLastError());
	}
	return LIBUSB_SUCCESS;
}
Exemplo n.º 2
0
static void performHaltOperation(char line[])
{
    char* linePtr = line + 1;

    // Parse the device index
    DWORD devIdx = 0;
    linePtr = parseNumber(linePtr, devIdx);
    if (!linePtr) {
        printf("Please provide a decimal device number following the command\n");
        return;
    }
    DWORD endpoint = 0;
    linePtr = parseNumber(linePtr, endpoint);
    if (!linePtr) {
        printf("Please provide a decimal endpoint number following the command\n");
        return;
    }
    if (devIdx >= gDeviceListSize || devIdx < 0) {
        printf("Invalid device index '%d' provided\n", devIdx);
        return;
    }
    if (endpoint >= UCHAR_MAX || endpoint < 0) {
        printf("Invalid endpoint '%d' provided\n", endpoint);
        return;
    }
    UKW_DEVICE device = gDeviceList[devIdx];
    UCHAR ep = static_cast<UCHAR>(endpoint);
    switch (line[0]) {
    case 'q':
    {
        BOOL halted = FALSE;
        BOOL result = UkwIsPipeHalted(device, ep, &halted);
        if (!result) {
            printf("Failed to retrieve pipe halted status on endpoint %d on device %d: %d\n",
                   ep, devIdx, GetLastError());
        } else {
            printf("Halted status on endpoint %d on device %d is %d\n", ep, devIdx, halted);
        }
        break;
    }
    case 'c':
    {
        BOOL result = UkwClearHaltHost(device, ep);
        if (!result) {
            printf("Failed to clear halt/stall (host) on endpoint %d on device %d: %d\n", ep, devIdx, GetLastError());
        } else {
            printf("Cleared halt/stall (host) on endpoint %d successfully\n", ep);
        }
        break;
    }
    case 's':
    {
        BOOL result = UkwClearHaltDevice(device, ep);
        if (!result) {
            printf("Failed to clear halt/stall (device) on endpoint %d on device %d: %d\n", ep, devIdx, GetLastError());
        } else {
            printf("Cleared halt/stall (device) on endpoint %d successfully\n", ep);
        }
        break;
    }
    default:
        printf("Unknown halt operation provided\n");
        break;
    }
}