I found that this seemed to work:
const STICK_INPUT_DEV="/dev/input/event0"
@async begin
stream, pipe = open(`cat $STICK_INPUT_DEV`)
while true
s = read(stream, Stick)
if s.ev_type == EV_KEY
println(s)
end
end
end
but it would be nice if there was a way to do this without cat
On Tuesday, 1 November 2016 11:17:31 UTC, Simon Byrne wrote:
>
> I'm trying to read from an input device asynchronously. I tried the obvious
>
> @async begin
> dev = open(STICK_INPUT_DEV)
> while true
> s = read(dev, Stick)
> if s.ev_type == EV_KEY
> println(s)
> end
> end
> end
>
> But this doesn't seem to yield correctly. The full code is available here:
> https://gist.github.com/simonbyrne/70f8c944ed7a76c95b1c90a964e9d7d1
>
> I did come across this related discussion for file IO which didn't really
> resolve the issue:
> https://groups.google.com/d/topic/julia-users/kfu_hgM3bnI/discussion
>
> What's the best way to do this?
>
> Simon
>