Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Read file from sys (emacstheviking)
   2. Re:  Read file from sys (mukesh tiwari)
   3. Re:  Read file from sys (Libor Wagner)
   4. Re:  recvFrom return value different from length of resulting
      string (Karl Voelker)


----------------------------------------------------------------------

Message: 1
Date: Sat, 11 May 2013 11:51:47 +0100
From: emacstheviking <[email protected]>
Subject: Re: [Haskell-beginners] Read file from sys
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <CAEiEuU+YEdUXh=4B8M0qKbvH+_V8=bShtEQF05y32ig+DcG=a...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Buffering?

On 11 May 2013 10:10, Libor Wagner <[email protected]> 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
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130511/fddc3a69/attachment-0001.htm>

------------------------------

Message: 2
Date: Sat, 11 May 2013 17:20:41 +0530
From: mukesh tiwari <[email protected]>
Subject: Re: [Haskell-beginners] Read file from sys
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell        <[email protected]>,
        [email protected]
Message-ID:
        <cafhzve_mkypv2y5q_8fittdwixjpz9_fahiefy8sedgmq-w...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

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 <[email protected]> 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
> [email protected]
> 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-0001.htm>

------------------------------

Message: 3
Date: Sat, 11 May 2013 14:25:37 +0200
From: Libor Wagner <[email protected]>
Subject: Re: [Haskell-beginners] Read file from sys
To: mukesh tiwari <[email protected]>
Cc: The, beginner-level topics related to Haskell
        <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Hi, 

thanks for suggestion, I have tried 's  <- readProcess "cat"  [w1paht] []'. 
Probably not a cleanest solution but it works.

Libor 


On Saturday, May 11, 2013 at 13:50, mukesh tiwari wrote:

> 
> 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 <[email protected] 
> (mailto:[email protected])> 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
> > [email protected] (mailto:[email protected])
> > http://www.haskell.org/mailman/listinfo/beginners
> 






------------------------------

Message: 4
Date: Sat, 11 May 2013 11:43:15 -0700
From: Karl Voelker <[email protected]>
Subject: Re: [Haskell-beginners] recvFrom return value different from
        length of resulting string
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Message-ID:
        <CAFfow0wzd=+3gmz3msjxwqkovy_3rvxf2bmhm-h441nwpxx...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Unless your network data happens to be character data using the encoding
assumed by the functions in Network.Socket, bad things are going to happen.

Here is a quote from Network.Socket:

"Do not use the send and recv functions defined in this module in new code,
as they incorrectly represent binary data as a Unicode string. As a result,
these functions are inefficient and may lead to bugs in the program."

-Karl


On Fri, May 10, 2013 at 1:50 PM, Nathan H?sken <[email protected]>wrote:

> It works when I am using Network.Socket.ByteString.
> I assume this is because the other recvFrom encodes the message with
> peekCStringLen, but I am not sure.
>
> Should the 2 implementations not behave the same besides returning a
> different datastructure for the received data??
>
>
> On 05/10/2013 06:34 PM, Nathan H?sken wrote:
>
>> Hey,
>>
>> I am trying to write a small haskell application which forwards udp
>> messages. The complete program is here: http://hpaste.org/87681
>>
>> Notice the lines:
>>
>> 43  (msg,bytes,addr) <- recvFrom sock 1024
>> 44  putStrLn $ "Received: " ++ show bytes ++ " = " ++ (show . length $
>> msg)
>>
>> If I understand correctly, bytes is the number of bytes in the message.
>> This should be ?quivalent to (length msg), correct?
>>
>> Now I send an udp message (by connecting over the forwarded port with
>> enet), and get this output:
>>
>> Received: 52 = 41
>>
>> than I run it again, and get this output:
>>
>> Received: 52 = 43
>>
>> Why is the length of msg not equal  to 52?
>> And why is it different from run to run?
>>
>> enet is unable to connect over this forward, by the way.
>>
>> Thanks!
>> Nathan
>>
>> ______________________________**_________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>>
>
>
> ______________________________**_________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130511/cc3428d0/attachment-0001.htm>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 59, Issue 11
*****************************************

Reply via email to