We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# accessory.py # License GPLv2 # (c) Manuel Di Cerbo, Nexus-Computing GmbH # https://github.com/rosterloh/pyusb-android/blob/master/accessory.py import os import socket NETLINK_KOBJECT_UEVENT = 15 def main(): while True: sock = socket.socket(socket.AF_NETLINK, socket.SOCK_RAW, NETLINK_KOBJECT_UEVENT) sock.bind((os.getpid(), -1)) while True: data = sock.recv(512) vid = parse_uevent(data) if vid is not None: break sock.close() accessory_task(vid) def parse_uevent(data): """ :param bytes data: :return: """ lines = data.decode('UTF8', 'ignore').split('\0') #lines = data.decode('UTF8').split('\0')#.replace('\fe', b'').decode('UTF8') print(lines) keys = [] for line in lines: val = line.split('=') if len(val) == 2: keys.append((val[0], val[1])) attributes = dict(keys) if 'ACTION' in attributes and 'PRODUCT' in attributes: if attributes['ACTION'] == 'add': parts = attributes['PRODUCT'].split('/') return int(parts[0], 16) return None def accessory_task(teste): print(teste) if __name__ == '__main__': main()
The text was updated successfully, but these errors were encountered:
#19 Initial tests with USB detection (#20) and android usb acessory
678a8d0
No branches or pull requests
The text was updated successfully, but these errors were encountered: