I have implemented a Linux driver (beaglebone) that queries some hardware by SPI and copies the received data in a kfifo (which can get full if it is not emptied). - This kfifo is emptied by performing reads on a char device file (let's call it /dev/foo). - An userland program is responsible for reading the correct fifo entry size (or a multiple of it). - The driver is started and stopped through sysfs entries.
The example C userland program reads this file in blocking mode (i.e., the read returns when data is available).
Now here's my problem: I have a server in node.js running on the beaglebone for administration purposes and would also like to make it "collect" the data (on /dev/foo) and send it via websockets.
I don't really know how to do that, since /dev/foo is not a regular file (so fs.watch does not work), and data keeps on being available randomly on it.
Questions: - Can I solve this problem with node's standard library (like with streams, etc?) - Is there a node module that could solve my problem? - Or do I have to write a node module myself (using libuv?)
Thanks for your hints on any of these points.