def __init__(self): self.seq1 = 0x0001 self.seq2 = 0x0068 self.handle = None # Setup Device hidapi.hid_init() for dev in hidapi.hid_enumerate(vendor_id=0x03eb, product_id=0x2013): self.handle = hidapi.hid_open_path(dev.path) self.tx_type1(self.handle, '*IDN?') self.info = self.rx(self.handle)
def setup(headset, is_research=True): ''' `is_research` should be True if EPOC+, try False if you have an EPOC ''' hidapi.hid_init() path, serial_number = hid_enumerate() if len(path) == 0: print("Could not find device.") print_hid_enumerate() exit() headset['device'] = hidapi.hid_open_path(path) # Setup crypto if is_old_model(serial_number): headset['old_model'] = True k = ['\0'] * 16 k[0] = serial_number[-1] k[1] = '\0' k[2] = serial_number[-2] if is_research: k[3] = 'H' k[4] = serial_number[-1] k[5] = '\0' k[6] = serial_number[-2] k[7] = 'T' k[8] = serial_number[-3] k[9] = '\x10' k[10] = serial_number[-4] k[11] = 'B' else: k[3] = 'T' k[4] = serial_number[-3] k[5] = '\x10' k[6] = serial_number[-4] k[7] = 'B' k[8] = serial_number[-1] k[9] = '\0' k[10] = serial_number[-2] k[11] = 'H' k[12] = serial_number[-3] k[13] = '\0' k[14] = serial_number[-4] k[15] = 'P' key = ''.join(k) print("Decryption key: " + key) backend = default_backend() cipher = Cipher(algorithms.AES(key.encode()), modes.ECB(), backend=backend) decryptor = cipher.decryptor() headset['decryptor'] = decryptor
def __init__(self, file_name=None, mode="hid", hid=None, file=None, **kwargs): self.mode = mode self.file = file self.file_name = file_name self.hid = hid self.platform = system_platform self.serial_number = None self.lock = Lock() self.save_data = Queue() self.save_data_size = 0 self._stop_signal = True if self.platform != "Windows": hidapi.hid_init() self.setup_platform = { 'Windows': self.setup_windows, 'Darwin': self.setup_not_windows, 'Linux': self.setup_not_windows, 'Reader': self.setup_reader, } if self.mode == "csv": if file_name is None: raise ValueError( "CSV file name must be specified when initializing an EmotivReader class using mode " "'csv'.") if sys.version_info >= (3, 0): self.file = open(file_name, 'r') else: self.file = open(file_name, 'rb') self.reader = csv.reader(self.file, quoting=csv.QUOTE_ALL) self.platform = "Reader" elif self.mode == 'hid': self.reader = None else: self.reader = None self.data = Queue() self.setup_platform[self.platform]() self.running = False self.stopped = True if self.reader is not None: self.thread = Thread(target=self.run, kwargs={'source': self.reader}) else: self.thread = Thread(target=self.run, kwargs={'source': self.hid}) self.thread.setDaemon(True) self._stop_signal = False
def __init__(self, file_name=None, mode="hid", hid=None, file=None, **kwargs): self.mode = mode self.file = file self.file_name = file_name self.hid = hid self.platform = system_platform self.serial_number = None self.lock = RLock() if self.platform != "Windows": hidapi.hid_init() self.setup_platform = { "Windows": self.setup_windows, "Darwin": self.setup_not_windows, "Linux": self.setup_not_windows, "Reader": self.setup_reader, } if self.mode == "csv": if file_name is None: raise ValueError( "CSV file name must be specified when initializing an EmotivReader class using mode " "'csv'." ) if sys.version_info >= (3, 0): self.file = open(file_name, "r") else: self.file = open(file_name, "rb") self.reader = csv.reader(self.file, quoting=csv.QUOTE_ALL) self.platform = "Reader" elif self.mode == "hid": self.reader = None else: self.reader = None self.data = Queue() self.setup_platform[self.platform]() self.running = False self.stopped = True if self.reader is not None: self.thread = Thread(target=self.run, kwargs={"source": self.reader}) else: self.thread = Thread(target=self.run, kwargs={"source": self.hid}) self.thread.setDaemon(True) self._stop_signal = False
def SendCommand(packet_array): packets = chr(0x00) # pre-pad with 0x00 per hid_write documentation for byte in packet_array: packets = packets + chr(int(byte, 16)) hidapi.hid_init() # Connect to the RadioSHARK dev = hidapi.hid_open(0x077d, 0x627a) # Write the packets packets_written = hidapi.hid_write(dev, packets) # Close out hidapi.hid_close(dev) if (args.debug): print "Packet Array: %s" % packet_array print "Number of Packets Sent: %s" % str(1 + len(packet_array)) print "Number of Packets Written: %i" % packets_written
########################################################################## # Copyright (C) 2014 Mark J. Blair, NF6X # # This file is part of pyhidapi. # # pyhidapi is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # pyhidapi is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with pyhidapi. If not, see <http://www.gnu.org/licenses/>. ########################################################################## """Enumerate all HID devices on the system.""" import hidapi if __name__ == '__main__': hidapi.hid_init() print 'Loaded hidapi library from: {:s}\n'.format(hidapi.hid_lib_path()) for dev in hidapi.hid_enumerate(): print '------------------------------------------------------------' print dev.description()
# This file is part of pyhidapi. # # pyhidapi is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # pyhidapi is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with pyhidapi. If not, see <http://www.gnu.org/licenses/>. ########################################################################## """Enumerate all HID devices on the system.""" import hidapi if __name__ == '__main__': hidapi.hid_init() print 'Loaded hidapi library from: {:s}\n'.format(hidapi.hid_lib_path()) for dev in hidapi.hid_enumerate(): print '------------------------------------------------------------' print dev.description()
def open(self) -> None: """Opens the connection to the RoIP device.""" hidapi.hid_init() self.hid_device = hidapi.hid_open(self.device[0], self.device[1]) self._logger.info('Opened hid_device="%s"', self.hid_device)
def initBase(self): hidapi.hid_init() device = hidapi.hid_open(0x0e6f, 0x0129) hidapi.hid_set_nonblocking(device, False) return device
def main(): hidapi.hid_init() dump_all_devices()