这篇教程C++ usb_init函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中usb_init函数的典型用法代码示例。如果您正苦于以下问题:C++ usb_init函数的具体用法?C++ usb_init怎么用?C++ usb_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了usb_init函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: scan_usbint scan_usb(){ int dev_cnt = 0; usb_init(); usb_find_busses(); usb_find_devices(); struct usb_bus *bus = NULL; struct usb_device *dev = NULL; for(bus = usb_get_busses(); bus; bus = bus->next) { for(dev = bus->devices; dev; dev=dev->next) { scan_device(dev, &dev_cnt); if(dev_cnt==MAX_DEVICES) return dev_cnt; } } return dev_cnt;}
开发者ID:jesjimher,项目名称:eagle-owl,代码行数:21,
示例2: mainint main(int argv, char** argc){ atexit(adb_cleanup);#if defined(HAVE_FORKEXEC) // No SIGCHLD. Let the service subproc handle its children. signal(SIGPIPE, SIG_IGN);#endif init_transport_registration(); // The minimal version of adbd only uses USB. if (access("/dev/android_adb", F_OK) == 0) { usb_init(); } fdevent_loop(); usb_cleanup(); return 0;}
开发者ID:SkrilaxCZ,项目名称:open_recovery,代码行数:21,
示例3: k8061_Initvoid k8061_Init( void ) { int i = 0; // Initialise libusb usb_init(); // Close all filehandles for ( i=0; i<8; i++ ) { _k8061_IsOpen[i] = 0; _k8061_Handle[i] = NULL; } // Reset buffers for ( i=0; i<50; i++ ) { _k8061_ReadBuffer[i] = 0; _k8061_WriteBuffer[i] = 0; } return;}
开发者ID:binomaiheu,项目名称:k8061,代码行数:21,
示例4: irecv_initstruct usb_dev_handle* irecv_init(unsigned int devid) { struct usb_dev_handle *handle = NULL; struct usb_device *dev = NULL; struct usb_bus *bus = NULL; 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) { if (dev->descriptor.idVendor == VENDOR_ID && dev->descriptor.idProduct == devid) { handle = usb_open(dev); return handle; } } } return NULL;}
开发者ID:iphonenerdjack,项目名称:irecovery,代码行数:21,
示例5: setup_libusb_accessusb_dev_handle* setup_libusb_access() { usb_dev_handle *lvr_winusb; usb_set_debug(255); usb_init(); usb_find_busses(); usb_find_devices(); if(!(lvr_winusb = find_lvr_winusb())) { printf("Couldn't find the USB device, Exiting/n"); return NULL; } if (usb_set_configuration(lvr_winusb, 1) < 0) { printf("Could not set configuration 1 : /n"); return NULL; } if (usb_claim_interface(lvr_winusb, INTERFACE) < 0) { printf("Could not claim interface: /n"); return NULL; } return lvr_winusb;}
开发者ID:gxliu,项目名称:lvr_winusb,代码行数:21,
示例6: mainintmain(void){ Temper *t; char buf[256]; int i, ret; usb_set_debug(0); usb_init(); usb_find_busses(); usb_find_devices(); t = TemperCreateFromDeviceNumber(0, USB_TIMEOUT, 0); if(!t) { perror("TemperCreate"); exit(-1); }/* TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0); TemperSendCommand(t, 0x43, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0); TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0);*/ float tempc; if(TemperGetTemperatureInC(t, &tempc) < 0) { perror("TemperGetTemperatureInC"); exit(1); } printf("temperature %.2fF %.2fC/n", (9.0 / 5.0 * tempc + 32.0), tempc); return 0;}
开发者ID:czytom,项目名称:temper,代码行数:40,
示例7: mainint main(int argc, char **argv) { signal(SIGHUP, sighandler); signal(SIGINT, sighandler); signal(SIGTERM, sighandler); signal(SIGPIPE, SIG_IGN); // Setting default file permissions to o+rw umask(~(S_IRUSR | S_IWUSR)); // Turning off buffering setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); processcommandline(argc, argv); if (!config_init(configfilename)) return 1; daemon_poll_init(); if (!usb_init()) return 2; while (!nai_flags.sigexit) { if (!usb_process()) break; if (!daemon_poll_process()) break; if (!nai_process()) break; } usb_deinit(); daemon_poll_deinit(); config_deinit(); printf("main: exiting./n"); return 0;}
开发者ID:nonoo,项目名称:nalarminterface,代码行数:40,
示例8: usb_initusb_dev_handle* LibUSButils::GetFirstDevice(int vendorid, int productid){ struct usb_bus* bus; struct usb_device* dev; usb_dev_handle* device_handle = NULL; // it's a null usb_init(); usb_set_debug(0); /* 3 is the max setting */ usb_find_busses(); usb_find_devices(); // Loop through each bus and device until you find the first match // open it and return it's usb device handle for (bus = usb_busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if (dev->descriptor.idVendor == vendorid && dev->descriptor.idProduct == productid) { device_handle = usb_open(dev); // Need error checking for when the device isn't found! if (!device_handle) { Logger::Log(ERROR, "Couldn't open usb device: %s", strerror(errno)); // errno = Exxxxx; // usb_open should set the error code. return NULL; } Logger::ClearLastError(); return (device_handle); } } } Logger::SetLastError("No Such device"); errno = ENOENT; // No such device return (device_handle);}
开发者ID:altagir,项目名称:x10-widget,代码行数:40,
示例9: mainint main(void){ // set for 1 MHz clock CPU_PRESCALE(4); // set all pins as inputs with pullup resistors #if defined(PORTA) DDRF = 0; PORTF = 0xFF; #endif DDRB = 0; PORTB = 0xFF; DDRC = 0; PORTC = 0xFF; DDRD = 0; PORTD = 0xFF; #if defined(PORTE) DDRE = 0; PORTE = 0xFF; #endif #if defined(PORTF) DDRF = 0; PORTF = 0xFF; #endif // initialize USB usb_init(); // do nothing (USB code handles reboot message) while (1) { _delay_ms(1); // put the CPU into low power idle mode set_sleep_mode(SLEEP_MODE_IDLE); cli(); sleep_enable(); sei(); sleep_cpu(); sleep_disable(); }}
开发者ID:NICOLASGON,项目名称:teensy_loader_cli,代码行数:40,
示例10: vport_openstruct vport* vport_open(){ struct usb_bus *busses; struct usb_dev_handle* usb_handle; struct usb_bus *bus; struct usb_device *dev; struct vport * tmp; tmp = (struct vport*)malloc(sizeof(struct vport)); usb_init(); usb_find_busses(); usb_find_devices(); busses = usb_get_busses(); /* find vport device in usb bus */ for (bus = busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { /* condition for sucessfully hit (too bad, I only check the vendor id)*/ if (dev->descriptor.idVendor == 0x0400) { tmp->usb_handle = usb_open(dev); usb_set_configuration (tmp->usb_handle,dev->config[0].bConfigurationValue); usb_claim_interface(tmp->usb_handle, 0); usb_set_altinterface(tmp->usb_handle,0); return tmp; } } } return 0; }
开发者ID:BackupTheBerlios,项目名称:usbn2mc-svn,代码行数:40,
示例11: USBDeviceFactory_DiscoverDevicesunsigned int USBDeviceFactory_DiscoverDevices( LPSKYETEK_DEVICE** lpDevices ){ struct usb_bus *bus; struct usb_device *dev; unsigned int deviceCount; LPSKYETEK_DEVICE lpDevice; if((lpDevices == NULL) || (*lpDevices != NULL)) return 0; deviceCount = 0; usb_init(); usb_find_busses(); usb_find_devices(); for(bus = usb_busses; bus; bus = bus->next) { for(dev = bus->devices; dev; dev = dev->next) { if((dev->descriptor.idVendor == VID) && (dev->descriptor.idProduct == PID)) { /*printf("USB filename: %s/r/n", dev->filename);*/ if(USBDeviceFactory_CreateDevice(dev->filename, &lpDevice) != SKYETEK_SUCCESS) continue; /*printf("USB CreateDevice succeded/r/n");*/ deviceCount++; *lpDevices = (LPSKYETEK_DEVICE*)realloc(*lpDevices, (deviceCount * sizeof(LPSKYETEK_DEVICE))); *lpDevices[(deviceCount - 1)] = lpDevice; } } } return deviceCount;}
开发者ID:simbits,项目名称:Ad-Hoc-Dark-Roast-Network-Travel-Mug-,代码行数:40,
示例12: mainint main(void){ // set for 16 MHz clock CPU_PRESCALE(0); usb_init(); //D0->4 Output Bits for Transistors to individual displays DDRD = 0b01011111; PORTD = 0b00000000; //C0->7 Initially setting bits to input. Will set to output to turn on. DDRC = 0b00000000; PORTC = 0b00000000; //DDRC = 0b11111111; DDRF = 0b00000000; PORTF = 0b11101010; TCCR1B = 0b00000011; TIFR1 = 0b00000001; TIMSK1 = 0b00000001; //sei(); //Turn on one of the columns for interupt purposes. PORTF &= ~(1<<2); //Setting Low DDRF |= (1<<2); //Set to Output uint8_t peeps = 0; uint16_t hourly = 0; peeps = getPeople(); hourly = getHourly(); while (1) { //.26 ticks per second, we'll say .25 for simplicity. displayMultiF((float)peeps*(float)hourly*ticks/60.0f/60.0f/4.0f); }}
开发者ID:pcorliss,项目名称:Teensy-Projects,代码行数:39,
示例13: USB_initvoid USB_init(cyg_addrword_t data){ cyg_sem_t sem; cyg_semaphore_init(&sem, 0); ppause(200); //20 Ticks, 200m seconds //init memory pci_usb_pool_init(); //usb usb_init(); //ohci ohci_hcd_init(0x5C, SYSPA_USB11_OPERATION_BASE_ADDR); //ehci ehci_hcd_init(0x6B, SYSPA_USB20_OPERATION_BASE_ADDR); //Printer Class usblp_init(); cyg_semaphore_wait(&sem); cyg_semaphore_destroy(&sem); }
开发者ID:3a1fa340-312c-11e6-8775-0016d322cfd3,项目名称:4b204d7c-312f-11e6-bd79-0016d322cfd3,代码行数:22,
示例14: usb_initusb_dev_handle *dpf_usb_open(void){ struct usb_device *d; usb_dev_handle *usb_dev; usb_init(); usb_find_busses(); usb_find_devices(); d = find_dev(); if (!d) { handle_error("No matching USB device found!"); return NULL; } usb_dev = usb_open(d); if (usb_dev == NULL) { handle_error("Failed to open usb device!"); return NULL; } return usb_dev;}
开发者ID:auuuux,项目名称:multigcs,代码行数:22,
示例15: usb_initstruct usb_device *cc1800_find (void) { int r; struct usb_bus *busses, *bus; struct usb_device *dev; usb_init(); r = usb_find_busses(); if (r < 0) return NULL; r = usb_find_devices(); if (r < 0) return NULL; busses = usb_get_busses(); for (bus = busses; bus != NULL; bus = bus->next) { for (dev = bus->devices; dev != NULL; dev = dev->next) { if (dev->descriptor.idVendor == CC1800_VENDOR_ID && dev->descriptor.idProduct == CC1800_PRODUCT_ID) { return dev; } } } return NULL;}
开发者ID:iggarpe,项目名称:cc1800,代码行数:22,
示例16: usb_close_outputstatic int usb_close_output(hw_ext_module_t * hw_module,audio_devices_t device){ struct usb_internal_data_s * usb_info = (struct usb_internal_data_s *)hw_module->data; audio_policy_anm *apm=hw_module->apm; struct str_parms *param; if(usb_info==NULL) return -1; switch(usb_info->state) { case IO_OPENED: case IO_DISCONNECTED: //continue treatment break; case IO_CONNECTED: ALOG_WARN("usb_close_output : USB output is not in disconnected state ; Impossible to close it"); return -1; break; case IO_CLOSED: ALOG_WARN("usb_close_output : already closed"); return 0; break; default: ALOG_WARN("usb_close_output : unknown state"); } if (usb_info->output_handle <=0 ) { ALOG_WARN("USB output is invalid ; Impossible to connect it"); return -1; } ALOG_INFO("USB request closing "); param = str_parms_create_str("closing"); str_parms_add_str(param, "closing", "true"); apm->mp_client_interface->set_parameters(apm->mService, usb_info->output_handle, str_parms_to_str(param), 0); str_parms_destroy(param); apm->mp_client_interface->close_output(apm->mService, usb_info->output_handle); ALOG_INFO("Usb closed "); return(usb_init(hw_module));}
开发者ID:Meticulus,项目名称:vendor_st-ericsson_u8500,代码行数:39,
示例17: mainint main(int argc, char **argv){ usb_dev_handle *handle = NULL; unsigned char buffer[8]; int nBytes; usb_init(); if(usbOpenDevice(&handle, USBDEV_SHARED_VENDOR, 0, USBDEV_SHARED_PRODUCT, 0) != 0){ fprintf(stderr, "Could not find USB device /"PowerSwitch/" with vid=0x%x pid=0x%x/n", USBDEV_SHARED_VENDOR, USBDEV_SHARED_PRODUCT); exit(1); } /* We have searched all devices on all busses for our USB device above. Now * try to open it and perform the vendor specific control operations for the * function requested by the user. */DWORD time = GetTickCount();int count = 1000; for(int i=0;i<count;i++) { nBytes = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, 0, 0, 0, (char *)buffer, sizeof(buffer), 5000); if(nBytes < 2){ if(nBytes < 0) fprintf(stderr, "USB error: %s/n", usb_strerror()); fprintf(stderr, "only %d bytes received in iteration %d/n", nBytes, i); continue; } std::cout << (char *)buffer << std::endl; } time = GetTickCount()-time; std::cout << (float)count*8 / time * 1000.f << std::endl; std::ofstream file("123.txt"); file << time; printf("test succeeded/n"); usb_close(handle); system("pause"); return 0;}
开发者ID:KonstantinChizhov,项目名称:AvrProjects,代码行数:39,
示例18: usb_initvoid *lothar_usb_new(uint16_t vendor, uint16_t product){ struct usb_bus *bus; usb_dev_handle *result = NULL; static int init = 0; static int interface = 0; if(!init) { usb_init(); usb_find_busses(); usb_find_devices(); init = 1; } for(bus = usb_get_busses(); bus; bus = bus->next) { struct usb_device *dev = NULL; for(dev = bus->devices; dev; dev = dev->next) { if(dev->descriptor.idVendor == vendor && dev->descriptor.idProduct == product) { result = usb_open(dev); break; } } if(result) // break out of nested loop break; } if(!result || usb_claim_interface(result, interface++)) // nothing found, or error claiming { LOTHAR_ERROR(LOTHAR_ERROR_USB_CANNOT_CREATE); return NULL; } return result; }
开发者ID:klaasjacobdevries,项目名称:lothar,代码行数:39,
示例19: xenon_make_it_faster void Hw::SystemInit(int flags){ if(init_flags==0){ xenon_make_it_faster(XENON_SPEED_FULL); if(flags & INIT_SOUND){ } if(flags & INIT_VIDEO){ } if(flags & INIT_USB){ usb_init(); } if(flags & INIT_NETWORK){ network_init(); } sfcx_init(); init_flags = flags; } }
开发者ID:magicseb,项目名称:zlx,代码行数:22,
示例20: machine_initint machine_init(void){ int i = 0; rcc_clock_setup_hse_3v3(&rcc_hse_25mhz_3v3); gpio_create(NULL, &gpio_led0); gpio_create(NULL, &gpio_button); /* UARTS */ for (i = 0; i < NUM_UARTS; i++) { uart_create(&uart_configs[i]); } /* I2Cs */ for (i = 0; i < NUM_I2CS; i++) { i2c_create(&i2c_configs[i]); } rng_create(1, RCC_RNG); sdio_conf.rcc_reg = (uint32_t *)&RCC_APB2ENR; sdio_conf.rcc_en = RCC_APB2ENR_SDMMC1EN; sdio_init(&sdio_conf); usb_init(&usb_guest); ethernet_init(ð_config); return 0;}
开发者ID:insane-adding-machines,项目名称:frosted,代码行数:22,
示例21: mainint main(){ char fileName[21]; struct usb_bus *bus; struct usb_device *dev; usb_init(); usb_find_busses(); usb_find_devices(); for (bus = usb_busses; bus; bus = bus->next) for (dev = bus->devices; dev; dev = dev->next){ char buffer1[5]; char buffer2[5]; sprintf(buffer1, "%04x", dev->descriptor.idVendor); sprintf(buffer2, "%04x", dev->descriptor.idProduct); if(strcmp(buffer1, "045e") == 0 && strcmp(buffer2, "0772") == 0) { sprintf(fileName, "/dev/bus/usb/%s/%s", bus->dirname, dev->filename); } } int fd; int rc; fd = open(fileName, O_WRONLY); if (fd < 0) { perror("Error opening output file"); return 1; } printf("Resetting USB device %s/n", fileName); rc = ioctl(fd, USBDEVFS_RESET, 0); if (rc < 0) { perror("Error in ioctl"); return 1; } printf("Reset successful/n"); close(fd); return 1;}
开发者ID:Computician,项目名称:usbreset,代码行数:39,
示例22: ldn_find_verifier//----------------------------------------------------------------------struct usb_dev_handle * ldn_find_verifier(void){ struct usb_device *dev; struct usb_dev_handle *hdl; int i; //[USB initialization] //printf("/ninitializing USB communication..."); usb_init(); usb_find_busses(); usb_find_devices(); //printf("[SUCCESS]."); dev = find_device(VENDOR_ID, PRODUCT_ID); if (dev == NULL) return NULL; //lockdown verifier not found! //printf("/nlockdown verifier found."); hdl = usb_open(dev); i = usb_set_configuration(hdl, 1); if (i < 0){ usb_close(hdl); return NULL; //usb_set_configuration failed; } //printf("/nlockdown verifier configuration selected."); i = usb_claim_interface(hdl, 0); if (i < 0) { usb_close(hdl); return NULL; //usb_claim_interface failed } //printf("/nclaimed lockdown USB interface."); return hdl;}
开发者ID:anbangr,项目名称:trustvisor-dev,代码行数:40,
示例23: libusb_searchvoidlibusb_search (libusb_t *libusb, int idVendor, int idProduct){ struct usb_bus *bus; struct usb_device *dev; usb_init(); usb_find_busses(); usb_find_devices(); libusb->busses = usb_get_busses (); libusb->dev_number = 0; for (bus = libusb->busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if ((dev->descriptor.idVendor == idVendor) && (dev->descriptor.idProduct == idProduct)) { libusb->devices[libusb->dev_number] = dev; libusb->dev_number++; } } }}
开发者ID:andypc,项目名称:lib-touchatag-1.0,代码行数:22,
示例24: encoder_initint WINAPI encoder_init (){ OutputDebugString("[FPGA] usb_init start."); if(USBDevice) { encoder_deinit(); } OutputDebugString("[FPGA] usb_init new USBDevice start."); USBDevice = new CCyUSBDevice(hDevice); OutputDebugString("[FPGA] usb_init new USBDevice end."); fpga_param.nBitrate = 4*1000;// 4000kbps if(usb_init(USBDevice)) { printf("sucess/n"); OutputDebugString("[FPGA] usb_init sucess."); } else { printf("failed/n"); OutputDebugString("[FPGA] usb_init failed."); return S_ERROR; } bool fw_index; OutputDebugString("[FPGA] first usb_downloadfw."); fw_index = usb_downloadfw(USBDevice,"fpga_usb_fw.hex"); OutputDebugString("[FPGA] second usb_downloadfw."); fw_index = usb_downloadfw(USBDevice,"fpga_usb_fw.hex"); if (fw_index) { printf("sucess/n"); OutputDebugString("[FPGA] usb_downloadfw sucess."); } else { printf("failed/n"); OutputDebugString("[FPGA] usb_downloadfw failed."); return S_ERROR; } return S_SUCCESS;}
开发者ID:southwolf,项目名称:fpga_v6,代码行数:38,
示例25: initstatic void init(void){ led_init();#ifdef CONFIG_CARL9170FW_DEBUG_UART uart_init();#endif /* CONFIG_CARL9170FW_DEBUG_UART */ /* 25/50/100ms timer (depends on cpu clock) */ timer_init(0, 50000); /* USB init */ usb_init(); /* initialize DMA memory */ memset(&dma_mem, 0, sizeof(dma_mem)); /* fill DMA rings */ dma_init_descriptors(); /* clear all interrupt */ set(AR9170_MAC_REG_INT_CTRL, 0xffff); orl(AR9170_MAC_REG_AFTER_PNP, 1); /* Init watch dog control flag */ fw.watchdog_enable = 1; set(AR9170_TIMER_REG_WATCH_DOG, AR9170_WATCH_DOG_TIMER);#ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT fw.cached_gpio_state.gpio = get(AR9170_GPIO_REG_PORT_DATA) & CARL9170_GPIO_MASK;#endif /* CONFIG_CARL9170FW_GPIO_INTERRUPT */ /* this will get the downqueue moving. */ down_trigger();}
开发者ID:pkgadd,项目名称:firmware-carl9170,代码行数:38,
示例26: xenon_make_it_faster void Hw::SystemInit(int flags){ if(init_flags==0){ xenon_make_it_faster(XENON_SPEED_FULL); if(flags & INIT_SOUND){ } if(flags & INIT_VIDEO){ } if(flags & INIT_USB){ usb_init(); usb_do_poll(); } if(flags & INIT_NETWORK){ network_init(); } if(flags & INIT_ATA){ xenon_ata_init(); } if(flags & INIT_ATAPI){ xenon_atapi_init(); } if(flags & INIT_FILESYSTEM){ mount_all_devices(); findDevices(); } if(flags & INIT_SFCX){ sfcx_init(); } init_flags = flags; } }
开发者ID:LibXenonProject,项目名称:ZLX-Library,代码行数:38,
示例27: adb_mainint adb_main(){ //strcpy(ADB_SIDELOAD_FILENAME, path); atexit(adb_cleanup);#if defined(HAVE_FORKEXEC) // No SIGCHLD. Let the service subproc handle its children. signal(SIGPIPE, SIG_IGN);#endif init_transport_registration(); // The minimal version of adbd only uses USB. if (access("/dev/android_adb", F_OK) == 0) { // listen on USB LOGE("listen on USB/n"); usb_init(); } if (setgid(AID_SHELL) != 0) { LOGE("failed to setgid to shell/n"); exit(1); } if (setuid(AID_SHELL) != 0) { LOGE("failed to setuid to shell/n"); exit(1); } LOGE("userid is %d/n", getuid()); LOGE("Event loop starting/n"); fdevent_loop(); usb_cleanup(); return 0;}
开发者ID:airy09,项目名称:miui_rec_AD682J,代码行数:38,
注:本文中的usb_init函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ usb_interrupt_read函数代码示例 C++ usb_ifnum_to_if函数代码示例 |