Skip to content

Instantly share code, notes, and snippets.

@NickCrews
Created February 4, 2019 22:55
Show Gist options
  • Save NickCrews/b93b03d2a78628d36653a77d383afbc9 to your computer and use it in GitHub Desktop.
Save NickCrews/b93b03d2a78628d36653a77d383afbc9 to your computer and use it in GitHub Desktop.
Test for Wilco EC Event notification
#!/usr/bin/python
import select, array, fcntl
fname = '/dev/wilco_ec'
with open(fname, "r+") as file:
p = select.poll()
p.register(file.fileno(), select.POLLIN)
events = p.poll(100)
print "result of poll: ", events
IOCTL_READ = 2148062464 #hardcoded command number
buf = array.array('c', 'x'*1024) #init buffer to fill
do_modify_buf = 1
with open(fname, "wb") as fd:
ret = fcntl.ioctl(fd, IOCTL_READ, buf, do_modify_buf)
print 'ioctl() returned event of size=%d' % ret
print 'event data: ', buf.tolist()[:ret]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment