Bob the Pleo Forums

Pleo Stuff => Pleo Archives => Archive -- Technical Classic => Topic started by: alunoist on July 29, 2010, 03:15:15 AM

Title: Make pleo write to a file
Post by: alunoist on July 29, 2010, 03:15:15 AM
Hi,

I need help with my school project.
I have a specific behaviour for pleo in my sd card. I would like to know if its possible to make pleo write to a file.

For example if I touch the back sensor I would like for pleo to write to a text file that exists on the sd card something like "back sensor has been touched".

Is it possible? If so could you post the piece of code that does that.

Thanks
Title: Re: Make pleo write to a file
Post by: InmemoryofRomeo on August 01, 2010, 06:20:33 PM
Free bump to remind people, you need one of the smart peeps to come on.
Title: Re: Make pleo write to a file
Post by: ohnart on August 02, 2010, 12:13:36 AM
Cant help you, but it would be an awesome project!
Title: Re: Make pleo write to a file
Post by: PleoPet on August 03, 2010, 06:31:49 AM
>  I would like for pleo to write to a text file that exists on the sd card something like "back sensor has been touched".
Look at the File functions of the PDK (in File.inc) and the file_example example.



    device_change(device_sd);
        // put it on the SD card

    new File: file_handle = file_open("whatever.txt", io_write);
        // opens file for writing, will replace old contents
        // you may want "io_append" if you want to keep a longer log

    if (!file_handle)
    {
        // oops - file was not created
        // do something to handle the error, perhaps file locked
    }
    else
    {
        // write to file, and close
        file_puts(file_handle, "back sensor has been touched");
        file_close(file_handle);
    }

Title: Re: Make pleo write to a file
Post by: alunoist on August 06, 2010, 06:45:41 AM
Thanks pleopet!!

I will test the code.
SimplePortal 2.3.5 © 2008-2012, SimplePortal