
Hey list, I got myself a Beaglebone and will use it to stabilize and fly a drone with Haskell. The ghc support seems good enough (text doesn't compile, everything else does), but I have a question about inputs/outputs. They are all set through sysfs, and I think a wrapper over it would be easiest and most straightforward to have. The operation of most pins goes along the lines of 'activate a pin -> do some stuff -> turn it off'. Is there some particular mechanism/library you would suggest me to look into to handle that? Any thoughts or own experience with doing similar things with Haskell? Any tips will be appreciated:) Michal

Michal,
I am doing similar things (not arial) on a MinnowBoardMax. Did not want to deal with ARM and Haskell. But if you make that work, I think it would be worth publishing how you did it. I struggled to build a cross compiler for ARM and gave up.
As for MinnowBoardMax, I am running Ubuntu with a 3.18.1 kernel and a solid state drive. A little heavy on the weight when you consider the batteries required to run a 5W system.
I have libraries for I2C, UART, and GPIO, but not published.
Here is an example of how I deal with ALERTB
module SMBusAlert (
alert
) where
import System.IO
alert :: IO Bool
alert = do
writeFile "/sys/class/gpio/export" "340"
writeFile "/sys/class/gpio/gpio340/direction" "in"
s <- readFile "/sys/class/gpio/gpio340/value"
s `seq` writeFile "/sys/class/gpio/unexport" "340"
if s!!0 == '0' then return True else return False
On Jan 27, 2015, at 7:45 AM, Michal Kawalec
Hey list,
I got myself a Beaglebone and will use it to stabilize and fly a drone with Haskell. The ghc support seems good enough (text doesn't compile, everything else does), but I have a question about inputs/outputs.
They are all set through sysfs, and I think a wrapper over it would be easiest and most straightforward to have. The operation of most pins goes along the lines of 'activate a pin -> do some stuff -> turn it off'. Is there some particular mechanism/library you would suggest me to look into to handle that? Any thoughts or own experience with doing similar things with Haskell?
Any tips will be appreciated:) Michal
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Tue, Jan 27, 2015 at 5:02 PM, Michael Jones
Michal,
I am doing similar things (not arial) on a MinnowBoardMax. Did not want to deal with ARM and Haskell. But if you make that work, I think it would be worth publishing how you did it. I struggled to build a cross compiler for ARM and gave up.
As for MinnowBoardMax, I am running Ubuntu with a 3.18.1 kernel and a solid state drive. A little heavy on the weight when you consider the batteries required to run a 5W system.
I have libraries for I2C, UART, and GPIO, but not published.
Here is an example of how I deal with ALERTB
module SMBusAlert ( alert ) where
import System.IO
alert :: IO Bool alert = do writeFile "/sys/class/gpio/export" "340" writeFile "/sys/class/gpio/gpio340/direction" "in" s <- readFile "/sys/class/gpio/gpio340/value" s `seq` writeFile "/sys/class/gpio/unexport" "340" if s!!0 == '0' then return True else return False
While I do not understand much about what you're doing, I would suggest instead : alert :: IO Bool alert = do writeGpio "export" "340" writeGpio "gpio340/direction" "in" c <- withFile "/sys/class/gpio/gpio340/value" ReadMode getChar writeGpio "unexport" "340" return (c == '0') where writeGpio p = writeFile ("/sys/class/gpio/" ++ p) and maybe writeGpio (or a general gpio transformer) should be part of an utility library since those IO to related files/devices seems to form a large part of your code. (Also the "if blabla then return True else return False" == "return blabla" is a common mistake) -- Jedaï
participants (3)
-
Chaddaï Fouché
-
Michael Jones
-
Michal Kawalec