Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: MarkTTU on January 25, 2018, 04:14:12 PM

Title: Store & Retrieve data from SD card?
Post by: MarkTTU on January 25, 2018, 04:14:12 PM
Planning to send data to a web server where it will be logged into a database. Got all that worked out, but had the thought of what to do with the data if the web/database server is off-line for a time. Could the SD card be used to store data and then retrieve it and send it on to the server once the server is on-line again? Asking here because I don't have time to dig around and see if this is possible at the moment.
Title: Re: Store & Retrieve data from SD card?
Post by: BobO on January 25, 2018, 04:25:43 PM
Absolutely. There is a full file API for creating and managing files on both the SDCard and the ram disk.
Title: Re: Store & Retrieve data from SD card?
Post by: MarkTTU on January 25, 2018, 04:37:16 PM
Awesome! Thanks!
Title: Re: Store & Retrieve data from SD card?
Post by: Bolt on January 25, 2018, 07:14:54 PM
This depends on the volume, frequency, and type of data you are sending to your web server, but what I did recently was create a buffer with 128 strings.  The PLC writes the data to the buffer strings, and then if the connection to server is available, writes to the server.  If the server were to be down, it would keep filling the buffer, and once server comes back online, it will post it all to the database on the server.  For me the 128 strings will keep me happy for a short server outage of an hour or so.  Obviously the buffer could be made larger, at the expense of system memory.  The SD card is a much larger storage option.
Title: Re: Store & Retrieve data from SD card?
Post by: MarkTTU on January 25, 2018, 08:36:53 PM
I really like the buffer of strings solution; that could be very very good indeed. We're probably looking at about 100 pieces of data, mostly 3-4 digit numbers, at a frequency of between 30 and 120 writes per hour. In an extreme case I figure we need to be able to store about a weeks worth of data; hence my interest in the SD card.