BeagleBone Black Continuous Analog Reads

Asked by 1 month ago
The main way of reading the inputs (analog or digital) on a BeagleBone Black is through the Linux file system. I'm still pretty new to Clojure and come from an object oriented background. I would like to do a continuous read of the BBB's analog inputs through the file system and make decisions based on the values. There are different ways of handling this from an OOP perspective, but I'm not sure how to approach it from a functional perspective. Can someone point me in the right direction?

Your Answer


All Answers

Answer by 1 month ago
I would say it's not so much about programming paradigm rather than system calls. It all boils down to how often you would want to read the data. If it's not more than some times per second, and it's not super important with timing, you could probably put a reading function in a SchedulingThreadPool (you can add Clojure functions as is since they are Runnable) or have a look at the at-at library spawned from overtone. One way to react on the incoming values are to swap! or reset! them into an atom, which has a watcher-function added which could things based on the new and old values. shows an example with agents, but it works for atoms as well. If you want to store an incoming series of values for further processing, either use the clojure.lang.PeristentQueue or some Java equivalent. If you want to sample in very high frequency, (kilohertz) you'll need to fetch the values in some loop close to machine an batch it into Clojure by primitive-buffers or similar (like soundcards, UARTs and network stacks do). /Linus 2014-06-18 5:08 GMT+02:00 Jeremy Wright wrightjmf [ at ]