[Haskell-beginners] Read file from sys

mukesh tiwari mukeshtiwari.iiitm at gmail.com
Sat May 11 13:50:41 CEST 2013


Hi Libor,
Probably it has something to do reading binary file though not sure. Try
reading the binary file[1].

[1] http://www.haskell.org/haskellwiki/DealingWithBinaryData

On Sat, May 11, 2013 at 2:40 PM, Libor Wagner <liborwagner at gmail.com> wrote:

> Hi,
>
> I have small code snippet to read content of a file, which should grow
> into simple tool to read temperature from sensor on Raspberry Pi:
>
> module Main where
>
> import System.Environment
>
> main :: IO ()
> main = do
> [f] <- getArgs
> s <- readFile f
> putStr s
>
> When this is called with the test file I have copied from the real
> location it works fine:
>
> $ cat /sys/bus/w1/devices/28-000004e46240/w1_slave >test.txt
> $ ./ds18b20 test.txt
> 53 01 4b 46 7f ff 0d 10 e9 : crc=e9 YES
> 53 01 4b 46 7f ff 0d 10 e9 t=21187
>
>
>
> How ever when called with the real location nothing happens:
>
> $ ./ds18b20 /sys/bus/w1/devices/28-000004e46240/w1_slave
>
> Can someone help? I have thought that the file is not properly ended so I
> have tried to take just first line but that doest work either.
>
> Thanks
> Libor
>
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130511/1122f77c/attachment.htm>


More information about the Beginners mailing list