def devs(): buf=hci_dev_list_req() buf.dev_num=HCI_MAX_DEV ctl = bluetooth.BluetoothSocket(proto=bluetooth.HCI) ret=ioctl(ctl.fileno(), HCIGETDEVLIST, hci_dev_list_p(buf)) if ret < 0 : raise Exception("something failed") out = {} for i in range(buf.dev_num): dev_req = buf.dev_req[i] dev = hci_dev_info() dev.dev_id = dev_req.dev_id ret = ioctl(ctl.fileno(), HCIGETDEVINFO, hci_dev_info_p(dev)) out[dev.dev_id] = dev return out
def getInputDevices(self): for evdev in sorted(listdir("/dev/input")): try: fd = os_open("/dev/input/%s" % evdev, O_RDONLY | O_CLOEXEC) except: continue buf = "\0" * 256 try: size = ioctl(fd, EVIOCGNAME(len(buf)), buf) except: os_close(fd) continue os_close(fd) if size <= 0: continue name = buf[:size - 1] if name: if name == "dreambox advanced remote control (native)" and config.misc.rcused.value not in ( 0, 2): continue if name == "dreambox remote control (native)" and config.misc.rcused.value in ( 0, 2): continue if name == "dreambox front panel": continue self.Devices[evdev] = { 'name': name, 'type': self.getInputDeviceType(name), 'enabled': False, 'configuredName': None }
def getInputDevices(self): for evdev in sorted(listdir("/dev/input")): try: fd = os_open("/dev/input/%s" % evdev, O_RDONLY | O_CLOEXEC) except: continue buf = "\0"*256 try: size = ioctl(fd, EVIOCGNAME(len(buf)), buf) except: os_close(fd) continue os_close(fd) if size <= 0: continue name = buf[:size - 1] if name: if name == "dreambox advanced remote control (native)" and config.misc.rcused.value not in (0, 2): continue if name == "dreambox remote control (native)" and config.misc.rcused.value in (0, 2): continue if name == "dreambox front panel": continue self.Devices[evdev] = {'name': name, 'type': self.getInputDeviceType(name),'enabled': False, 'configuredName': None }
def ioctlGenarator(ioctlLines): # Add iOctls allIoctls = [] buff = [] for line in ioctlLines: if len(buff) == 0: buff.append(line) continue if len(line.split('\t'))<2: allIoctls.append(ioctl(buff)) buff = [line] else: buff.append(line) allIoctls.append(ioctl(buff)) outTxt = [] for i in allIoctls: outTxt.append(str(i)) return allIoctls
def test_ioctl(self, get_ioctl_fn_mock): ioctl_fn = mock.Mock() ioctl_fn.return_value = 42 get_ioctl_fn_mock.return_value = ioctl_fn value_ptr = ctypes.byref(ctypes.c_int(13)) ret = ioctl.ioctl(1, 2, value_ptr) assert ret == 42 assert ioctl_fn.call_count == 1 args = ioctl_fn.call_args[0] assert len(args) == 3 assert type(args[0]) == type(ctypes.c_int(1)) assert args[0].value == 1 assert type(args[1]) == type(ctypes.c_ulong(2)) assert args[1].value == 2 assert args[2] == value_ptr