您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ usb_set_configuration函数代码示例

51自学网 2021-06-03 09:21:12
  C++
这篇教程C++ usb_set_configuration函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中usb_set_configuration函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_set_configuration函数的具体用法?C++ usb_set_configuration怎么用?C++ usb_set_configuration使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了usb_set_configuration函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: generic_probe

static int generic_probe(struct usb_device *udev){	int err, c;	/* Choose and set the configuration.  This registers the interfaces	 * with the driver core and lets interface drivers bind to them.	 */	if (udev->authorized == 0)		dev_err(&udev->dev, "Device is not authorized for usage/n");	else {		c = usb_choose_configuration(udev);		if (c >= 0) {			err = usb_set_configuration(udev, c);			if (err) {				dev_err(&udev->dev, "can't set config #%d, error %d/n",					c, err);				/* This need not be fatal.  The user can try to				 * set other configurations. */			}		}	}	/* USB device state == configured ... usable */	usb_notify_add_device(udev);	return 0;}
开发者ID:despierto,项目名称:imx_233_linux,代码行数:26,


示例2: main

int main(int argc, char **argv){  usb_dev_handle      *handle = NULL;  const unsigned char rawVid[2] = {USB_CFG_VENDOR_ID}, rawPid[2] = {USB_CFG_DEVICE_ID};  char                vendor[] = {USB_CFG_VENDOR_NAME, 0}, product[] = {USB_CFG_DEVICE_NAME, 0};  char                buffer[50] = "";  unsigned char	      request;  int                 vid, pid, nBytes;  usb_init();  if(argc < 2){   /* we need at least one argument */    printf("Arguments Missing");    exit(1);  }  request = atoi(argv[1]);    /* compute VID/PID from usbconfig.h so that there is a central source of information */  vid = rawVid[1] * 256 + rawVid[0];  pid = rawPid[1] * 256 + rawPid[0];    /* The following function is in opendevice.c: */  if(usbOpenDevice(&handle, vid, vendor, pid, product, NULL, NULL, NULL) != 0){    fprintf(stderr, "Could not find USB device /"%s/" with vid=0x%x pid=0x%x/n", product, vid, pid);    exit(1);  }    /* Since we use only control endpoint 0, we don't need to choose a     * configuration and interface. Reading device descriptor and setting a     * configuration and interface is done through endpoint 0 after all.     * However, newer versions of Linux require that we claim an interface     * even for endpoint 0. Enable the following code if your operating system     * needs it: */#if 0  int retries = 1, usbConfiguration = 1, usbInterface = 0;  if(usb_set_configuration(handle, usbConfiguration) && showWarnings){    fprintf(stderr, "Warning: could not set configuration: %s/n", usb_strerror());  }    /* now try to claim the interface and detach the kernel HID driver on     * Linux and other operating systems which support the call. */  while((len = usb_claim_interface(handle, usbInterface)) != 0 && retries-- > 0){#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP    if(usb_detach_kernel_driver_np(handle, 0) < 0 && showWarnings){      fprintf(stderr, "Warning: could not detach kernel driver: %s/n", usb_strerror());    }#endif  }#endif  nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, request, 0, 0, (char *)buffer, sizeof(buffer), 5000);				  if(nBytes < 0)    printf("error in USB control transfer: %s/n", usb_strerror());				  usb_close(handle);  return 0;}
开发者ID:abhianet,项目名称:ippnar.old,代码行数:59,


示例3: err

static void *rtl8150_probe(struct usb_device *udev, unsigned int ifnum,			   const struct usb_device_id *id){	rtl8150_t *dev;	struct net_device *netdev;	udev->config[0].bConfigurationValue = 1;	if (usb_set_configuration(udev, udev->config[0].bConfigurationValue)) {		err("usb_set_configuration() failed");		return NULL;	}	dev = kmalloc(sizeof(rtl8150_t), GFP_KERNEL);	if (!dev) {		err("Out of memory");		goto exit;	} else		memset(dev, 0, sizeof(rtl8150_t));	netdev = init_etherdev(NULL, 0);	if (!netdev) {		kfree(dev);		err("Oh boy, out of memory again?!?");		dev = NULL;		goto exit;	}	init_MUTEX(&dev->sem);	dev->udev = udev;	dev->netdev = netdev;	SET_MODULE_OWNER(netdev);	netdev->priv = dev;	netdev->open = rtl8150_open;	netdev->stop = rtl8150_close;	netdev->do_ioctl = rtl8150_ioctl;	netdev->watchdog_timeo = RTL8150_TX_TIMEOUT;	netdev->tx_timeout = rtl8150_tx_timeout;	netdev->hard_start_xmit = rtl8150_start_xmit;	netdev->set_multicast_list = rtl8150_set_multicast;	netdev->set_mac_address = rtl8150_set_mac_address;	netdev->get_stats = rtl8150_netdev_stats;	netdev->mtu = RTL8150_MTU;	dev->intr_interval = 100;	/* 100ms */	if (rtl8150_reset(dev) || !alloc_all_urbs(dev)) {		err("couldn't reset the device");		free_all_urbs(dev);		unregister_netdev(dev->netdev);		kfree(netdev);		kfree(dev);		dev = NULL;		goto exit;	}	set_ethernet_addr(dev);	/* let's not be very nasty :-) */	info("%s: rtl8150 is detected", netdev->name);exit:	return dev;}
开发者ID:JBTech,项目名称:ralink_rt5350,代码行数:59,


示例4: jtag_libusb_set_configuration

int jtag_libusb_set_configuration(jtag_libusb_device_handle *devh,		int configuration){	struct jtag_libusb_device *udev = jtag_libusb_get_device(devh);	return usb_set_configuration(devh,			udev->config[configuration].bConfigurationValue);}
开发者ID:EmuxEvans,项目名称:openocd,代码行数:8,


示例5: rusb_set_configuration

/* USB::DevHandle#usb_set_configuration(configuration) */static VALUErusb_set_configuration(VALUE v, VALUE configuration){  usb_dev_handle *p = get_usb_devhandle(v);  int ret = usb_set_configuration(p, NUM2INT(configuration));  check_usb_error("usb_set_configuration", ret);  return Qnil;}
开发者ID:atoulme,项目名称:ruby-usb,代码行数:9,


示例6: l_usb_set_configuration

static int l_usb_set_configuration(lua_State *L) {	struct usb_dev_handle * dev_handle = lua_touserdata(L, 1);  	int configuration = lua_tonumber(L, 2);  		int ret = usb_set_configuration(dev_handle, configuration);		return (proccess_return_code(L, ret));}
开发者ID:nfurquez,项目名称:LabRobEmb2013,代码行数:8,


示例7: usb_open_device

/* taken (modified) from avrdude usbasp.c */static int usb_open_device(struct usb_dev_handle **device, int vendor, int product){    struct usb_bus      *bus;    struct usb_device   *dev;    usb_dev_handle      *handle = NULL;    int                 errorCode = USB_ERROR_NOTFOUND;    static int          didUsbInit = 0;    if (!didUsbInit)    {        didUsbInit = 1;        usb_init();    }    usb_find_busses();    usb_find_devices();    for (bus=usb_get_busses(); bus; bus=bus->next)    {        for (dev=bus->devices; dev; dev=dev->next)        {            DEBUG( "Enumerating device list.. VID: 0x%4.4x, PID: 0x%4.4x/n", dev->descriptor.idVendor, dev->descriptor.idProduct);            if (dev->descriptor.idVendor == vendor && dev->descriptor.idProduct == product)            {                /* we need to open the device in order to query strings */                handle = usb_open(dev);                if (handle == NULL)                {                    errorCode = USB_ERROR_ACCESS;                    avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s/n", progname, usb_strerror());                    continue;                }                // return with opened device handle                else                {                    avrdude_message(MSG_NOTICE, "Device %p seemed to open OK./n", handle);                    if ((errorCode = usb_set_configuration(handle, 1)) < 0)                    {                        avrdude_message(MSG_INFO, "Could not set configuration. Error code %d, %s./n"                                "You may need to run avrdude as root or set up correct usb port permissions.", errorCode, usb_strerror());                    }                    if ((errorCode = usb_claim_interface(handle, 0)) < 0)                    {                        avrdude_message(MSG_INFO, "Could not claim interface. Error code %d, %s/n"                                "You may need to run avrdude as root or set up correct usb port permissions.", errorCode, usb_strerror());                    }                    errorCode = 0;                    *device = handle;                    return 0;                }            }        }    }    return -1;}
开发者ID:MelanieT,项目名称:avrdude,代码行数:59,


示例8: generic_disconnect

static void generic_disconnect(struct usb_device *udev){    usb_notify_remove_device(udev);    /* if this is only an unbind, not a physical disconnect, then     * unconfigure the device */    if (udev->actconfig)        usb_set_configuration(udev, -1);}
开发者ID:shalashaskaa,项目名称:ardrone-kernel,代码行数:9,


示例9: pn53x_usb_scan

static size_tpn53x_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const size_t connstrings_len){  (void)context;  usb_prepare();  size_t device_found = 0;  uint32_t uiBusIndex = 0;  struct usb_bus *bus;  for (bus = usb_get_busses(); bus; bus = bus->next) {    struct usb_device *dev;    for (dev = bus->devices; dev; dev = dev->next, uiBusIndex++) {      for (size_t n = 0; n < sizeof(pn53x_usb_supported_devices) / sizeof(struct pn53x_usb_supported_device); n++) {        if ((pn53x_usb_supported_devices[n].vendor_id == dev->descriptor.idVendor) &&            (pn53x_usb_supported_devices[n].product_id == dev->descriptor.idProduct)) {          // Make sure there are 2 endpoints available          // with libusb-win32 we got some null pointers so be robust before looking at endpoints:          if (dev->config == NULL || dev->config->interface == NULL || dev->config->interface->altsetting == NULL) {            // Nope, we maybe want the next one, let's try to find another            continue;          }          if (dev->config->interface->altsetting->bNumEndpoints < 2) {            // Nope, we maybe want the next one, let's try to find another            continue;          }          usb_dev_handle *udev = usb_open(dev);          if (udev == NULL)            continue;          // Set configuration          int res = usb_set_configuration(udev, 1);          if (res < 0) {            log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to set USB configuration (%s)", _usb_strerror(res));            usb_close(udev);            // we failed to use the device            continue;          }          // pn53x_usb_get_usb_device_name (dev, udev, pnddDevices[device_found].acDevice, sizeof (pnddDevices[device_found].acDevice));          log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "device found: Bus %s Device %s", bus->dirname, dev->filename);          usb_close(udev);          snprintf(connstrings[device_found], sizeof(nfc_connstring), "%s:%s:%s", PN53X_USB_DRIVER_NAME, bus->dirname, dev->filename);          device_found++;          // Test if we reach the maximum "wanted" devices          if (device_found == connstrings_len) {            return device_found;          }        }      }    }  }  return device_found;}
开发者ID:h4ck3rm1k3,项目名称:php5-nfc,代码行数:57,


示例10: sizeof

struct pegoda_handle *pegoda_open(void){	struct usb_device *pegoda;	unsigned char rbuf[16];	unsigned int rlen = sizeof(rbuf);	struct pegoda_handle *ph;	usb_init();	usb_find_busses();	usb_find_devices();	pegoda = find_device(USB_VENDOR_PHILIPS, USB_DEVICE_PEGODA);	if (!pegoda)		return NULL;	ph = malloc(sizeof(*ph));	if (!ph)		return NULL;	memset(ph, 0, sizeof(*ph));	printf("found pegoda, %u configurations/n",		pegoda->descriptor.bNumConfigurations);	printf("config 2 [nr %u] has %u interfaces/n",		pegoda->config[1].bConfigurationValue,		pegoda->config[1].bNumInterfaces);	printf("config 2 interface 0 has %u altsettings/n",		pegoda->config[1].interface[0].num_altsetting);	ph->handle = usb_open(pegoda);	if (!ph->handle) 		goto out_free;	if (usb_set_configuration(ph->handle, 2))		goto out_free;	printf("configuration 2 successfully set/n");	if (usb_claim_interface(ph->handle, 0))		goto out_free;	printf("interface 0 claimed/n");	if (usb_set_altinterface(ph->handle, 1))		goto out_free;	printf("alt setting 1 selected/n");	pegoda_transceive(ph, PEGODA_CMD_PCD_CONFIG, NULL, 0, rbuf, &rlen);	return ph;out_free:	free(ph);	return NULL;}
开发者ID:dpavlin,项目名称:librfid,代码行数:57,


示例11: usb_init

usb_dev_handle *m4Init() {  struct usb_bus *bus;  struct usb_device *dev;  usb_init();  if (usb_find_busses() < 0) {    return NULL;  }  if (usb_find_devices() < 0) {    return NULL;  }  bus = usb_get_busses();  while (bus) {    dev = bus->devices;    while (dev) {      if (dev->descriptor.idVendor == VENDOR &&          dev->descriptor.idProduct == PRODUCT) {	usb_dev_handle *handle = usb_open(dev);	if (handle) {#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP          /* Linux usually claims HID devices for its usbhid driver. */          usb_detach_kernel_driver_np(handle, 0);#endif	  if (usb_set_configuration(handle, 1) >= 0) {	    if (usb_claim_interface(handle, 0) >= 0) {	      if (usb_set_altinterface(handle, 0) < 0) {	        usb_close(handle);		return NULL;              }	    } else {	      usb_close(handle);	      return NULL;	    }	  } else {	    usb_close(handle);	    return NULL;	  }	  return handle;	}      }      dev = dev->next;    }    bus = bus->next;  }  return NULL;}
开发者ID:hordurk,项目名称:power_supplies,代码行数:56,


示例12: setup_libusb_access

/** * Initialize all Temper Devices currently attached to the system * @return pcsensor_devices* */pcsensor_devices* setup_libusb_access() {    static pcsensor_devices *available_devices;    if (debug) {        usb_set_debug(255);    } else {        usb_set_debug(0);    }    usb_init();    usb_find_busses();    usb_find_devices();    // Get an array of MAX_SENSORS    available_devices = find_lvr_winusb();    if (available_devices->sensor_count == 0) {        if (debug) {            printf("Couldn't find the USB device, Exiting/n");        }        return NULL;    }    int i;    for (i = 0; i < available_devices->sensor_count; i++) {        usb_dev_handle *lvr_winusb = available_devices->sensors[i];        usb_detach(lvr_winusb, INTERFACE1);        usb_detach(lvr_winusb, INTERFACE2);        if (usb_set_configuration(lvr_winusb, 0x01) < 0) {            if (debug) {                printf("Could not set configuration 1/n");            }            return NULL;        }        // Microdia tiene 2 interfaces        if (usb_claim_interface(lvr_winusb, INTERFACE1) < 0) {            if (debug) {                printf("Could not claim interface/n");            }            return NULL;        }        if (usb_claim_interface(lvr_winusb, INTERFACE2) < 0) {            if (debug) {                printf("Could not claim interface/n");            }            return NULL;        }    }    return available_devices;}
开发者ID:longjos,项目名称:temper,代码行数:60,


示例13: usb_set_configuration

void MainWindow::DisconnectUSBDevice( void ){  if ( pDevH )  {    usb_set_configuration( pDevH, 0 );    usb_release_interface( pDevH, 0 );    usb_close( pDevH );    pDevH = NULL;  }}
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:10,


示例14: QLOG_ERROR

bool M64BirDevice::connectDevice(){    int err;    char str[100];    // At this point device should point to a valid usb_device if a M64Bir was attached    if( mDevice == NULL )    {        QLOG_ERROR() << "No M64BIR device defined: " << usb_strerror();        return false;    }    // Open the USB device    usb_dev_handle *handle = usb_open( mDevice );    err = usb_set_configuration( handle, 1 );    if( err < 0 )    {        QLOG_ERROR() << "usb_set_configuration() returned " << usb_strerror();        usb_close( handle );        return false;    }    err = usb_claim_interface( handle, 0 );    if( err < 0 )    {        QLOG_ERROR() << "usb_claim_interface() returned " << usb_strerror();        usb_close( handle );        return false;    }    mDeviceHandle = handle;    // Print device information    if( mDevice->descriptor.iManufacturer )    {        err = usb_get_string_simple( mDeviceHandle, mDevice->descriptor.iManufacturer, str, sizeof(str) );        if( err > 0 )        {            mDeviceManufacturer = str;            QLOG_INFO() << "Manufacturer is " << mDeviceManufacturer;        }    }    if( mDevice->descriptor.iProduct )    {        err = usb_get_string_simple( mDeviceHandle, mDevice->descriptor.iProduct, str, sizeof(str) );        if( err > 0 )        {            mDeviceProductName = str;            QLOG_INFO() << "Product is " << mDeviceProductName;        }    }    return true;}
开发者ID:isorg,项目名称:MagicPad,代码行数:55,


示例15: set_bConfigurationValue

static ssize_tset_bConfigurationValue (struct device *dev, const char *buf, size_t count){	struct usb_device	*udev = udev = to_usb_device (dev);	int			config, value;	if (sscanf (buf, "%u", &config) != 1 || config > 255)		return -EINVAL;	value = usb_set_configuration (udev, config);	return (value < 0) ? value : count;}
开发者ID:xricson,项目名称:knoppix,代码行数:11,


示例16: open_interface

static int open_interface(struct cp210x_transport *tr,			  struct usb_device *dev, int ino,			  int baud_rate){#if defined(__linux__)	int drv;	char drName[256];#endif	printc_dbg(__FILE__": Trying to open interface %d on %s/n",	       ino, dev->filename);	tr->int_number = ino;	tr->handle = usb_open(dev);	if (!tr->handle) {		pr_error(__FILE__": can't open device");		return -1;	}#if defined(__linux__)	drv = usb_get_driver_np(tr->handle, tr->int_number, drName,				sizeof(drName));	printc(__FILE__" : driver %d/n", drv);	if (drv >= 0) {		if (usb_detach_kernel_driver_np(tr->handle,						tr->int_number) < 0)			pr_error(__FILE__": warning: can't detach "			       "kernel driver");	}#endif#ifdef __Windows__	if (usb_set_configuration(tr->handle, 1) < 0) {		pr_error(__FILE__": can't set configuration 1");		usb_close(tr->handle);		return -1;	}#endif	if (usb_claim_interface(tr->handle, tr->int_number) < 0) {		pr_error(__FILE__": can't claim interface");		usb_close(tr->handle);		return -1;	}	if (configure_port(tr, baud_rate) < 0) {		printc_err("Failed to configure for V1 device/n");		usb_close(tr->handle);		return -1;	}	return 0;}
开发者ID:dlbeer,项目名称:mspdebug,代码行数:54,


示例17: empeg_startup

static int  empeg_startup (struct usb_serial *serial){	dbg("%s", __FUNCTION__);	dbg("%s - Set config to 1", __FUNCTION__);	usb_set_configuration (serial->dev, 1);	/* continue on with initialization */	return 0;}
开发者ID:JBTech,项目名称:ralink_rt5350,代码行数:12,


示例18: usbobex_connect_request

/* * Function usbobex_connect_request (self) * *    Open the USB connection * */int usbobex_connect_request(obex_t *self){	int ret;#ifndef _WIN32	DEBUG(4, "/n");	self->trans.self.usb.dev_control = usb_open(self->trans.self.usb.device);	self->trans.self.usb.dev_data = usb_open(self->trans.self.usb.device);	ret = usb_set_configuration(self->trans.self.usb.dev_control, self->trans.self.usb.configuration);	if (ret < 0) {		DEBUG(4, "Can't set configuration %d", ret);	}	ret = usb_claim_interface(self->trans.self.usb.dev_control, self->trans.self.usb.control_interface);	if (ret < 0) {		DEBUG(4, "Can't claim control interface %d", ret);		goto err1;	}	ret = usb_set_altinterface(self->trans.self.usb.dev_control, self->trans.self.usb.control_setting);	if (ret < 0) {		DEBUG(4, "Can't set control setting %d", ret);		goto err2;	}	ret = usb_claim_interface(self->trans.self.usb.dev_data, self->trans.self.usb.data_interface);	if (ret < 0) {		DEBUG(4, "Can't claim data interface %d", ret);		goto err2;	}	ret = usb_set_altinterface(self->trans.self.usb.dev_data, self->trans.self.usb.data_active_setting);	if (ret < 0) {		DEBUG(4, "Can't set data active setting %d", ret);		goto err3;	}	self->trans.mtu = OBEX_MAXIMUM_MTU;	DEBUG(2, "transport mtu=%d/n", self->trans.mtu);	return 1;err3:	usb_release_interface(self->trans.self.usb.dev_data, self->trans.self.usb.data_interface);	err2:	usb_release_interface(self->trans.self.usb.dev_control, self->trans.self.usb.control_interface);err1:	usb_close(self->trans.self.usb.dev_data);	usb_close(self->trans.self.usb.dev_control);	return ret;#endif /* _WIN32 */}
开发者ID:Camelek,项目名称:qtmoko,代码行数:59,


示例19: setup_libusb_access

static usb_dev_handle* setup_libusb_access() {	usb_dev_handle *lvr_winusb;	if(debug) {		usb_set_debug(255);	} else {		usb_set_debug(0);	}	usb_init();	usb_find_busses();	usb_find_devices(); 	if(!(lvr_winusb = find_lvr_winusb())) {		if(debug){			printf("Couldn't find the USB device, Exiting/n");		}		return NULL;	}                	usb_detach(lvr_winusb, INTERFACE1);        	usb_detach(lvr_winusb, INTERFACE2);         	if (usb_set_configuration(lvr_winusb, 0x01) < 0) {		if(debug){			printf("Could not set configuration 1/n");		}		return NULL;	} 	// Microdia tiene 2 interfaces	if (usb_claim_interface(lvr_winusb, INTERFACE1) < 0) {		if(debug){			printf("Could not claim interface/n");		}		return NULL;	} 	if (usb_claim_interface(lvr_winusb, INTERFACE2) < 0) {		if(debug){			printf("Could not claim interface/n");		}		return NULL;	} 	return lvr_winusb;}
开发者ID:raff,项目名称:temper,代码行数:52,


示例20: usbSetConfiguration

intusbSetConfiguration (UsbDevice *device, unsigned char configuration) {  UsbDeviceExtension *devx = device->extension;  int result;  logMessage(LOG_CATEGORY(USB_IO), "setting configuration: %u", configuration);  result = usb_set_configuration(devx->handle, configuration);  if (result >= 0) return 1;  errno = -result;  logSystemError("USB configuration set");  return 0;}
开发者ID:plundblad,项目名称:brltty,代码行数:13,


示例21: usbSetConfiguration

intusbSetConfiguration (  UsbDevice *device,  unsigned char configuration) {  UsbDeviceExtension *devx = device->extension;  int result = usb_set_configuration(devx->handle, configuration);  if (result >= 0) return 1;  errno = -result;  logSystemError("USB configuration set");  return 0;}
开发者ID:Feechka,项目名称:UOBP,代码行数:13,


示例22: usb_open

usb_dev_handle *open_device (struct usb_device *dev) {	usb_dev_handle *hdl;	hdl = usb_open (dev);	int open_status = usb_set_configuration (hdl, 1);	open_status = usb_claim_interface (hdl, 0);	open_status = usb_set_altinterface (hdl, 0);	usb_control_msg(hdl, 0x40, 0x0c, 0x5003, 0x00f0, "/x10", 1, 1000); 	usb_control_msg(hdl, 0x40, 0x0c, 0x5003, 0xffff, "/xd0", 1, 1000); 	return hdl;}
开发者ID:johnlepikhin,项目名称:catbeat,代码行数:13,


示例23: libusb_claim_interface

int libusb_claim_interface(libusb_device_handle* dev, int interface_number){	usb_dev_handle* device_handle (translate(dev));	if (0 == usb_claim_interface(device_handle, interface_number))	{		int ok2 = usb_set_configuration(device_handle, 1);	}	// LIBUSB_ERROR_NOT_FOUND if the requested interface does not exist	// LIBUSB_ERROR_BUSY if another program or driver has claimed the interface	// LIBUSB_ERROR_NO_DEVICE if the device has been disconnected	// a LIBUSB_ERROR code on other failure	// 0 on success	return(0);}
开发者ID:CFC-Media-Lab,项目名称:unification,代码行数:14,


示例24: usb_standard_request_set_configuration_setup

static usb_request_status_t usb_standard_request_set_configuration_setup(	usb_endpoint_t* const endpoint) {	const uint8_t usb_configuration = endpoint->setup.value_l;	if( usb_set_configuration(endpoint->device, usb_configuration) ) {		if( usb_configuration == 0 ) {			// TODO: Should this be done immediately?			usb_set_address_immediate(endpoint->device, 0);		}		usb_endpoint_schedule_ack(endpoint->in);		return USB_REQUEST_STATUS_OK;	} else {		return USB_REQUEST_STATUS_STALL;	}}
开发者ID:13572293130,项目名称:hackrf,代码行数:15,


示例25: initialize_spectrometer

int initialize_spectrometer(){  char cmd;  /* Set up USB communication */  if (usb_set_configuration(handle, USB_CONFIGURATION) != 0) {    fprintf(stderr, "ERROR: Set configuration failed./n");    return 1;  }  if (usb_claim_interface(handle, USB_INTERFACE) != 0) {    fprintf(stderr, "ERROR: Claim interface failed./n");    return 1;  }  atexit(release_spectrometer_interface);  if (usb_set_altinterface(handle, USB_ALT_INTERFACE) != 0) {    fprintf(stderr, "ERROR: Set altinterface failed./n");    return 1;  }  /* Clear halt status */  if (usb_clear_halt(handle, EP1Out) != 0) {    fprintf(stderr, "ERROR: Clear halt status on endpoint 1 out failed./n");    return 1;  }  if (usb_clear_halt(handle, EP1In) != 0) {    fprintf(stderr, "ERROR: Clear halt status on endpoint 1 in failed./n");    return 1;  }  if (usb_clear_halt(handle, EP2In) != 0) {    fprintf(stderr, "ERROR: Clear halt status on endpoint 2 in failed./n");    return 1;  }  /* Initialise spectrometer */  cmd = 0x01;  if (usb_bulk_write(handle, EP1Out, &cmd, 1, TIMEOUT) != 1) {    fprintf(stderr, "ERROR: Initialise spectrometer failed./n");    return 1;  }  return 0;}
开发者ID:soemraws,项目名称:acqspect,代码行数:47,


示例26: main

int main(void){    usb_dev_handle *dev = NULL; /* the device handle */    char tmp[BUF_SIZE];    usb_init(); /* initialize the library */    usb_find_busses(); /* find all busses */    usb_find_devices(); /* find all connected devices */    if(!(dev = open_dev()))    {        printf("error: device not found!/n");        return 0;    }    if(usb_set_configuration(dev, 1) < 0)    {        printf("error: setting config 1 failed/n");        usb_close(dev);        return 0;    }    if(usb_claim_interface(dev, 0) < 0)    {        printf("error: claiming interface 0 failed/n");        usb_close(dev);        return 0;    }    if(usb_bulk_write(dev, EP_OUT, tmp, sizeof(tmp), 5000)            != sizeof(tmp))    {        printf("error: bulk write failed/n");    }    if(usb_bulk_read(dev, EP_IN, tmp, sizeof(tmp), 5000)            != sizeof(tmp))    {        printf("error: bulk read failed/n");    }    usb_release_interface(dev, 0);    usb_close(dev);    return 0;}
开发者ID:variability,项目名称:leon3,代码行数:47,


示例27: usb_bus_reset

static void usb_bus_reset(usb_device_t* const device) {	// According to UM10503 v1.4 section 23.10.3 "Bus reset":	usb_reset_all_endpoints();	usb_set_address_immediate(device, 0);	usb_set_configuration(device, 0);		// TODO: Enable endpoint 0, which might not actually be necessary,	// as the datasheet claims it can't be disabled.	//wait_ms(3);	//	//if( USB0_PORTSC1 & USB0_PORTSC1_PR ) {	//	// Port still is in the reset state.	//} else {	//	usb_hardware_reset();	//}}
开发者ID:Aerobota,项目名称:hackrf,代码行数:17,


示例28: defined

bool GammaBlockUSB::deviceReset(){#if defined(_MSC_VER) && defined(GAMMA_USB_CYAPI)	if(!m_usbDevice->IsOpen() || !m_usbDevice->Reset())	{		return false;	}#else	if( /*0 > usb_reset(m_usbDevice) ||*/		0 > usb_set_configuration(m_usbDevice, 1) || 		0 > usb_claim_interface(m_usbDevice, 0))	{		return false;	}#endif	return true;}
开发者ID:mateusz-plociennik,项目名称:gamma-view,代码行数:17,



注:本文中的usb_set_configuration函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ usb_set_intfdata函数代码示例
C++ usb_serial_register函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。