int teensy_open(void) { teensy_close(); libusb_teensy_handle = open_usb_device(0x16C0, 0x0478); if (!libusb_teensy_handle) libusb_teensy_handle = open_usb_device(0x03eb, 0x2067); if (!libusb_teensy_handle) return 0; return 1; }
int teensy_open(void) { teensy_close(); iokit_teensy_reference = open_usb_device(0x16C0, 0x0478); if (!iokit_teensy_reference) iokit_teensy_reference = open_usb_device(0x03eb, 0x2067); if (!iokit_teensy_reference) return 0; return 1; }
int teensy_open(void) { teensy_close(); uhid_teensy_fd = open_usb_device(0x16C0, 0x0478); if (uhid_teensy_fd < 0) uhid_teensy_fd = open_usb_device(0x03eb, 0x2067); if (uhid_teensy_fd < 0) return 0; return 1; }
int hard_reboot(void) { int r, rebootor_fd; rebootor_fd = open_usb_device(0x16C0, 0x0477); if (rebootor_fd < 0) rebootor_fd = open_usb_device(0x03eb, 0x2067); if (rebootor_fd < 0) return 0; r = write(rebootor_fd, "reboot", 6); delay(0.1); close(rebootor_fd); if (r == 6) return 1; return 0; }
static int teensy_open(void) { teensy_close(); iokit_teensy_reference = open_usb_device(0x16C0, 0x0478); if (iokit_teensy_reference) return 1; return 0; }
static int teensy_open(void) { teensy_close(); win32_teensy_handle = open_usb_device(0x16C0, 0x0478); if (win32_teensy_handle) return 1; return 0; }
int teensy_open(int hid, int pid) { teensy_close(); libusb_teensy_handle = open_usb_device(hid, pid); if (!libusb_teensy_handle) return 0; return 1; }
int hard_reboot(void) { usb_dev_handle *rebootor; int r; rebootor = open_usb_device(0x16C0, 0x0477); if (!rebootor) rebootor = open_usb_device(0x03eb, 0x2067); if (!rebootor) return 0; r = usb_control_msg(rebootor, 0x21, 9, 0x0200, 0,(char *)"reboot", 6, 100); usb_release_interface(rebootor, 0); usb_close(rebootor); if (r < 0) return 0; return 1; }
int hard_reboot(void) { IOHIDDeviceRef rebootor; IOReturn ret; rebootor = open_usb_device(0x16C0, 0x0477); if (!rebootor) rebootor = open_usb_device(0x03eb, 0x2067); if (!rebootor) return 0; ret = IOHIDDeviceSetReport(rebootor, kIOHIDReportTypeOutput, 0, (uint8_t *)("reboot"), 6); close_usb_device(rebootor); if (ret == kIOReturnSuccess) return 1; return 0; }
static int hard_reboot(void) { HANDLE rebootor; int r; rebootor = open_usb_device(0x16C0, 0x0477); if (!rebootor) return 0; r = write_usb_device(rebootor, "reboot", 6, 100); CloseHandle(rebootor); return r; }
static int test_command(int argc, const char* argv[]) { int fd; zx_handle_t svc; zx_status_t status = open_usb_device(&fd, &svc); if (status != ZX_OK) { return status; } zx_status_t status2; status = fuchsia_hardware_usb_peripheral_DeviceClearFunctions(svc, &status2); if (status == ZX_OK) status = status2; if (status == ZX_OK) { status = device_init(svc, &test_function); } close_device(fd, svc); return status == ZX_OK ? 0 : -1; }
int main(int argc, char *argv[]) { int ret; int i; ret = open_usb_device(); if (ret) { fprintf(stderr, "open_usb_device error\n"); return 1; } //read_romid(); write_input_info(); read_input_info(); ret = close_usb_device(); if (ret) { fprintf(stderr, "read_a_packet error\n"); return 1; } return 0; }
void check_runtime_interface( struct dfu_if *_rt_dif, struct dfu_if *dif, struct dfu_status *status ) { if( !_rt_dif->flags & DFU_IFF_DFU ) { while(1) { /* In the 'first round' during runtime mode, there can only be one * DFU Interface descriptor according to the DFU Spec. */ /* FIXME: check if the selected device really has only one */ claim_interface(_rt_dif); printf( "Determining device status: " ); if( dfu_get_status ( _rt_dif->dev_handle, _rt_dif->interface, status ) < 0 ) { fprintf( stderr, "error get_status: %s\n", usb_strerror( ) ); exit( 1 ); } printf( "state = %s, status = %d\n", dfu_state_to_string( status->bState ), status->bStatus ); switch ( status->bState ) { case DFU_STATE_appIDLE: case DFU_STATE_appDETACH: printf( "Device really in Runtime Mode, send DFU " "detach request...\n" ); if( dfu_detach( _rt_dif->dev_handle, _rt_dif->interface, 1000 ) < 0 ) { fprintf( stderr, "error detaching: %s\n", usb_strerror( ) ); exit( 1 ); break; } printf( "Resetting USB...\n" ); int ret = usb_reset( _rt_dif->dev_handle ); if( ret < 0 && ret != -ENODEV ) fprintf( stderr, "error resetting after detach: %s\n", usb_strerror( ) ); sleep( 2 ); break; case DFU_STATE_dfuERROR: printf( "dfuERROR, clearing status\n" ); if( dfu_clear_status( _rt_dif->dev_handle, _rt_dif->interface ) < 0 ) { fprintf( stderr, "error clear_status: %s\n", usb_strerror( ) ); exit( 1 ); break; } break; default: fprintf( stderr, "WARNING: Runtime device already " "in DFU state ?!?\n" ); break; } if( in_array( status->bState, ( unsigned char[3] ) { DFU_STATE_appIDLE, DFU_STATE_appDETACH, DFU_STATE_dfuERROR}, 3 ) >= 0 ) { /* now we need to re-scan the bus and locate our device */ int ret = 0; if( ( ret = usb_find_devices( ) ) < 2 ) printf( "not at least 2 device changes found ?!?\n" ); locate_dfu_device(dif,"Lost device after RESET?"); open_usb_device(dif); } else break; sleep(1); }
static int mode_command(int argc, const char* argv[]) { int fd; zx_handle_t svc; zx_status_t status = open_usb_device(&fd, &svc); if (status != ZX_OK) { return status; } zx_status_t status2; if (argc == 1) { // print current mode usb_mode_t mode; status = fuchsia_hardware_usb_peripheral_DeviceGetMode(svc, &status2, &mode); if (status == ZX_OK) status = status2; if (status != ZX_OK) { fprintf(stderr, "fuchsia_hardware_usb_peripheral_DeviceGetMode failed: %d\n", status); } else { switch (mode) { case USB_MODE_NONE: printf("NONE\n"); break; case USB_MODE_HOST: printf("HOST\n"); break; case USB_MODE_PERIPHERAL: printf("PERIPHERAL\n"); break; case USB_MODE_OTG: printf("OTG\n"); break; default: printf("unknown mode %d\n", mode); break; } } } else { usb_mode_t mode; if (strcasecmp(argv[1], "none") == 0) { mode = USB_MODE_NONE; } else if (strcasecmp(argv[1], "host") == 0) { mode = USB_MODE_HOST; } else if (strcasecmp(argv[1], "peripheral") == 0) { mode = USB_MODE_PERIPHERAL; } else if (strcasecmp(argv[1], "otg") == 0) { mode = USB_MODE_OTG; } else { fprintf(stderr, "unknown USB mode %s\n", argv[1]); status = ZX_ERR_INVALID_ARGS; } if (status == ZX_OK) { status = fuchsia_hardware_usb_peripheral_DeviceSetMode(svc, mode, &status2); if (status == ZX_OK) status = status2; if (status != ZX_OK) { fprintf(stderr, "fuchsia_hardware_usb_peripheral_DeviceSetMode failed: %d\n", status); } } } close_device(fd, svc); return status; }