Skip to content

Instantly share code, notes, and snippets.

@NickCrews
Created February 20, 2019 00:05
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/11fa41edda69aa09e4a27f5f788d45ba to your computer and use it in GitHub Desktop.
Save NickCrews/11fa41edda69aa09e4a27f5f788d45ba 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 │ CC firmware/2lib/2secdatak.o
│ CC firmware/2lib/2sha1.o
import select, os, glob │ CC firmware/2lib/2sha256.o
│ CC firmware/2lib/2sha512.o
fname = glob.glob("/dev/wilco_event*")[0] │ CC firmware/2lib/2sha_utility.o
│ CC firmware/2lib/2tpm_bootmode.o
with open(fname, "r+") as fd: │ CC firmware/2lib/2hmac.o
p = select.poll() │ CC firmware/2lib/2stub.o
p.register(fd.fileno(), select.POLLIN) │ CC firmware/lib20/api.o
events = p.poll(3000) │ CC firmware/lib20/api_kernel.o
print "result of poll: %s" % str(events) │ CC firmware/lib20/common.o
│ CC firmware/lib20/kernel.o
fd = None │ CC firmware/lib20/misc.o
try: │ CC firmware/lib20/packed_key.o
fd = os.open(fname, os.O_RDONLY) │ CC firmware/lib21/api.o
ret = os.read(fd, 1024) │ CC firmware/lib21/common.o
finally: │ CC firmware/lib21/misc.o
if (fd): │ CC firmware/lib21/packed_key.o
os.close(fd) │ CC firmware/bdb/host.o
│ CC firmware/bdb/bdb.o
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