resize a swap file

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
bakerj
Posts: 28
Joined: 21 Sep 2015 01:06

resize a swap file

#1 Post by bakerj » 25 Jul 2019 03:08

I am logging sensor data onto an SD card using a SWAP file. The swap file is needed for speed as I am logging data at a very fast rate and the latency involved in using the standard FAT32 read/write is to long. The issue is the size of the swap file. I need to initialize the file to a large size as the amount of data is variable (ie I may log data for 1 minute or one hour). I initilaize the swap to a very large value (~1GB). However depending on the particular data log I may only write to a fraction of the sectors that have been reserved for the file. So if I make the swap file 1GB but I only log say 10MB and I take the SD card out and transfer the data to a PC it transfers the entire 1GB which is unnecessary.

Is there a way to resize the original 1GB swap file to 10MB which is the portion that contains the actual data?

User avatar
stefan.filipovic
mikroElektronika team
Posts: 1135
Joined: 18 Dec 2018 10:30

Re: resize a swap file

#2 Post by stefan.filipovic » 25 Jul 2019 14:23

Hi,

Unfortunately, there is no function for resizing SWAP files, but you can try to make another one (smaller) SWAP file and read "valuable" sectors from the large SWAP file and write it to the new one file. After that, just remove the larger file.

Please find the SWAP test project in the attachment.

Kind regards,
Attachments
SD_MMC_Demo.zip
(377.33 KiB) Downloaded 61 times
Stefan Filipović

bakerj
Posts: 28
Joined: 21 Sep 2015 01:06

Re: resize a swap file

#3 Post by bakerj » 25 Jul 2019 15:18

Stefan, thanks for the reply!

Post Reply

Return to “mikroBasic PRO for PIC32 General”