File read and Write in Legato 18.09.0


#1

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


#2

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 applicationsampleApp.zip (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.

Regards,
Muralidhara N.


#3

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?


#4

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 legato.io link on config tree:
https://docs.legato.io/latest/c_config.html

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:
apps/platformServices/airVantageConnector/avcDaemon

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 legato.io 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.
https://docs.legato.io/latest/apiFilesSyntax.html

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

Regards,
Muralidhara N.


#5

Great thanks for all your help