C++ (Qt)void MainWindow::ReScanDevices(){ struct hid_device_info *devs, *cur_dev; devs = hid_enumerate(0x483, 0x5750); cur_dev = devs; while (cur_dev) { qDebug("Device Found\n type: %04hx %04hx\n path: %s\n serial_number: %ls", cur_dev->vendor_id, cur_dev->product_id, cur_dev->path, cur_dev->serial_number); qDebug(" Manufacturer: %ls\n", cur_dev->manufacturer_string); qDebug(" Product: %ls\n", cur_dev->product_string); qDebug(" Release: %hx\n", cur_dev->release_number); qDebug(" Interface: %d\n", cur_dev->interface_number); cur_dev = cur_dev->next; } if (devs && (connected_device = hid_open_path(devs->path))) { qDebug("open device"); } else{ qDebug("error open"); } hid_free_enumeration(devs); }
void MainWindow::ReScanDevices(){ struct hid_device_info *devs, *cur_dev; devs = hid_enumerate(0x483, 0x5750); cur_dev = devs; while (cur_dev) { qDebug("Device Found\n type: %04hx %04hx\n path: %s\n serial_number: %ls", cur_dev->vendor_id, cur_dev->product_id, cur_dev->path, cur_dev->serial_number); qDebug(" Manufacturer: %ls\n", cur_dev->manufacturer_string); qDebug(" Product: %ls\n", cur_dev->product_string); qDebug(" Release: %hx\n", cur_dev->release_number); qDebug(" Interface: %d\n", cur_dev->interface_number); cur_dev = cur_dev->next; } connected_device = hid_open_path(devs->path); if (connected_device) { qDebug("open device"); } else{ qDebug("error open"); } hid_free_enumeration(devs);}
Cconnected_device = hid_open_path( "/dev/hidraw2" );
all: testguiCC=gccCXX=g++COBJS=../libusb/hid.oCPPOBJS=test.oOBJS=$(COBJS) $(CPPOBJS)CFLAGS=-I../hidapi -Wall -g -c `fox-config --cflags` `pkg-config libusb-1.0 --cflags`LIBS=-ludev -lrt -lpthread `fox-config --libs` `pkg-config libusb-1.0 --libs`testgui: $(OBJS) g++ -Wall -g $^ $(LIBS) -o testgui$(COBJS): %.o: %.c $(CC) $(CFLAGS) $< -o $@$(CPPOBJS): %.o: %.cpp $(CXX) $(CFLAGS) $< -o $@clean: rm *.o testgui.PHONY: clean