File read and Write in Legato 18.09.0

Has anyone tried reading and writing a file in a single app? If so, please share this woud be a huge help

Hi @asifarshad,
Yes, We are able to do write and read operations in a single App using legato-18.9.0. See that i have attached sample (1.6 KB)
where we are writing and reading from a text file.
Is this is what you expected? If not, Please specify your requirements.

Note: We used WP85’s Release 16 and legato-18.09.0 on top of WP85’s Release.

Muralidhara N.

Thank you for you reply. I am string sensor reading to a file. they need to be stored for 6 hours and the board will be in ULPM. Then I need to push them to the cloud. Are files the best approach for this? Furthermore can I create a one app that can provide handles to other apps to read and write data on a single file?

Hi @asifarshad

I feel config tree option would be better as it will be better to store and retrieve the data. But i think config tree is not preferred for storing the huge amount of data. If you are not aware how to use config tree, You can check below link on config tree:

You can go through the source files in the below legato-AF folder path that how to use config tree API’s to store and retriev the data:

Regarding providing the file handles from one application to other application: Yes, there is an option to provide the file handles from one application to other application. You can go through the below link on how to write .api files to provide the file handles from one application to other application. I haven’t tried this myself so far, You can try.

Below is the .api syntax to provide file handle from one application to other:
file dataFile IN, ///< file descriptor as IN parameter
file dataOut OUT ///< file descriptor as OUT parameter

Muralidhara N.

Great thanks for all your help