int hidc_reset_device_class() { int ec; /* error code */ int dd; uint32_t cur_cls; /* current Device Class */ if (org_device_class == 0) return 0; if ((dd = open_hci_dev()) < 0) return dd; if ((ec = get_device_class(dd, &cur_cls)) < 0) { close_hci_dev(dd); return ec; } if (cur_cls != org_device_class) { if ((ec = set_device_class(dd, org_device_class)) < 0) { close_hci_dev(dd); return ec; } } if ((ec = close_hci_dev(dd)) < 0) return ec; org_device_class = 0; return 0; }
int hidc_set_hid_device_class() { int ec; /* error code */ int dd; uint32_t cur_cls; /* current Device Class */ uint32_t new_cls; /* new Device Class */ if ((dd = open_hci_dev()) < 0) return dd; if ((ec = get_device_class(dd, &cur_cls)) < 0) { close_hci_dev(dd); return ec; } if (org_device_class == 0) org_device_class = cur_cls; /* change only the last 12 bits */ new_cls = cur_cls & 0xfffff000; new_cls |= DC_PERI_KEYBOARD; if (new_cls != cur_cls) { if ((ec = set_device_class(dd, new_cls)) < 0) { close_hci_dev(dd); return ec; } } if ((ec = close_hci_dev(dd)) < 0) return ec; return 0; }
void RoiCounters::get_device_property() { // Initialize your default values here (if not done with POGO). //------------------------------------------------------------------ // Read device properties from database.(Automatic code generation) //------------------------------------------------------------------ Tango::DbData dev_prop; dev_prop.push_back(Tango::DbDatum("NbRoiCounters")); dev_prop.push_back(Tango::DbDatum("__x")); dev_prop.push_back(Tango::DbDatum("__y")); dev_prop.push_back(Tango::DbDatum("__width")); dev_prop.push_back(Tango::DbDatum("__height")); // Call database and extract values //-------------------------------------------- if(Tango::Util::instance()->_UseDb == true) get_db_device()->get_property(dev_prop); Tango::DbDatum def_prop, cl_prop; RoiCountersClass *ds_class = (static_cast<RoiCountersClass *>(get_device_class())); int i = -1; // Try to initialize NbRoiCounters from class property cl_prop = ds_class->get_class_property(dev_prop[++i].name); if(cl_prop.is_empty() == false) cl_prop >> nbRoiCounters; else {
void hidc_wait_for_empty_service_class(int timeout) { int dd; uint32_t cur_cls = 0; /* current Device Class */ time_t timeout_end = time(NULL) + timeout; log_d("start waiting for empty service class"); if ((dd = open_hci_dev()) < 0) return; get_device_class(dd, &cur_cls); while (((cur_cls & 0x00fff000) != 0) && (time(NULL) <= timeout_end)) { usleep(10 * 1000); get_device_class(dd, &cur_cls); } close_hci_dev(dd); log_d("stop waiting for empty service class"); }
void update_service_classes(const bdaddr_t *bdaddr, uint8_t value) { struct hci_dev_list_req *dl; struct hci_dev_req *dr; int i, sk; sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (sk < 0) return; dl = g_malloc0(HCI_MAX_DEV * sizeof(*dr) + sizeof(*dl)); dl->dev_num = HCI_MAX_DEV; dr = dl->dev_req; if (ioctl(sk, HCIGETDEVLIST, dl) < 0) { close(sk); g_free(dl); return; } dr = dl->dev_req; for (i = 0; i < dl->dev_num; i++, dr++) { struct hci_dev_info di; uint8_t cls[3]; int dd; if (hci_devinfo(dr->dev_id, &di) < 0) continue; if (hci_test_bit(HCI_RAW, &di.flags)) continue; if (get_device_class(di.dev_id, cls) < 0) continue; dd = hci_open_dev(di.dev_id); if (dd < 0) continue; set_service_classes(dd, cls, value); hci_close_dev(dd); update_adapter(di.dev_id); } g_free(dl); close(sk); }
void PCI::scan_devices() { int device_count = 0; for (uint32_t bus = 0; bus < 256; bus++) { for (uint32_t slot = 0; slot < 32; slot++) { for (uint32_t function = 0; function < 8; function++) { //根据配置空间的第0个寄存器是否返回0FFFFH值来判断是否存在该PCI设备 uint32_t vendor = getVendorID(bus, slot, function); if (vendor == 0xffff) break; uint32_t device = getDeviceID(bus, slot, function); uint32_t baseclass = getBaseClass(bus, slot, function); uint32_t subclass = getSubClass(bus, slot, function); uint32_t progif = getProgIF(bus, slot, function); PCI_IDS* pci_ids = get_device_ids(vendor, device, 0, 0); PCI_DEVICE_CLASS* pci_class = get_device_class(baseclass, subclass, progif); if (pci_ids != NULL) { printf("%d %02X:%02X:%X device: %s\n", device_count++, bus, slot, function, pci_ids->device_name); } else { printf("%d %02X:%02X:%X vendor: %x device: %x class: %x subclass: %x \n", device_count++, bus, slot, function, vendor, device, baseclass, subclass); } uint32_t header_type = getHeaderType(bus, slot, function); if ( (header_type & 0x80) == 0) break; /*pci_device *pdev = (pci_device *)malloc(sizeof(pci_device)); pdev->vendor = vendor; pdev->device = device; pdev->func = function; pdev->driver = 0; add_pci_device(pdev);*/ } } } }