Last active
February 7, 2019 17:48
-
-
Save NickCrews/8a55050e353b7027ca3009074eec4200 to your computer and use it in GitHub Desktop.
Call poll() and read() on the char device node that provides events from the Wilco EC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import select, array, os | |
fname = "/dev/wilco_event" | |
with open(fname, "r+") as fd: | |
p = select.poll() | |
p.register(fd.fileno(), select.POLLIN) | |
events = p.poll(100) | |
print "result of poll: %s" % str(events) | |
fd = None | |
try: | |
fd = os.open(fname, os.O_RDONLY) | |
ret = os.read(fd, 1024) | |
finally: | |
if (fd): | |
os.close(fd) | |
print "event data: %s " % " ".join(x.encode("hex") for x in ret) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment