Created
February 4, 2019 22:55
-
-
Save NickCrews/b93b03d2a78628d36653a77d383afbc9 to your computer and use it in GitHub Desktop.
Test for Wilco EC Event notification
This file contains hidden or 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, 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