Skip to content

Instantly share code, notes, and snippets.

@NickCrews
Last active February 7, 2019 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickCrews/8a55050e353b7027ca3009074eec4200 to your computer and use it in GitHub Desktop.
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
#!/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