You're welcome, and I'm very glad you didn't give up so quickly!
FWIW, I was not sure it was a problem with that version of Nim -- only that
when I changed the type environment enough to compile your code that it worked
for me on a devel version. In the future, providing more whole code context
So after reading "Nim in Action" I decided to have another go and managed to
get everything to work. For anyone looking for an example of using selectors on
a raw posix file, please take a look at my github respository for driving
TEMPer USB thermometers from Nim (on linux).
Cheers for your help. You are right, compiling Nim is not that hard. Just for
anyone who finds this thread:
sudo apt install nim
git clone https://github.com/Araq/Nim
cd Nim
sh build_all.sh
Run
and I have nim 0.19.9 (compiled, but not installed). Whilst
0.19.0 is very old in "Nim years" { like "dog years", but even more compressed
;-) }. 0.19.2 works better, but personally I would recommend `git clone
https://github.com/Araq/Nim` and learning how to build that/run right out of
the build. It's not too hard to follow the instructions. I think
Agreed, I don't want to waste your time, and am happy to update. I am using
Nim Compiler Version 0.19.0 [Linux: amd64]
Compiled at 2018-10-27
Copyright (c) 2006-2018 by Andreas Rumpf
active boot switches: -d:release
Run
Which was installed from the
Well, to make it work without the rest of your type environment, I changed just
the first couple lines of your posted code to:
import posix, selectors
proc readDevice(dev: string) =
let devfd = posix.open(dev, posix.O_RDWR)
Run
Then it compiled fine for me.
Thank you very much. You are quite correct. An unbuffered file is ideal, and
yes, linux only (OpenWrt). Thank you for pointing me to the posix module (and
getFileHandle()). I am trying to decipher the most elegant way of accomplishing
this, but am failing miserably. this is what I have
There is also `proc open*(a1: cstring, a2: cint)` in the `posix` module:
import posix
let fd = open("/dev/mydevice", O_RDONLY)
Run
if you want an unbuffered raw file handle which sounds like it might be the
case (and you don't need portability which is implied by
You probably want `proc getFileHandle*(f: File): FileHandle` from the system
module (no need to import). That just calls through to the C fileno().
The answer to this question is probably very simple, but I can't seem to get it
to work, and the documnetation is very sparse for these functions for some
reason. I need to read a linux device file until there is nothing left to read
for 0.1 second. I know that I need to use a selector, but I
10 matches
Mail list logo