Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : (MM)Is there anyway to show SD card size?
Author | Message | ||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9307 |
Hiya. :) FILES command lists all files and their file-size, but is there any way to display the remaining space on the SD card, or internal A: drive? I know that MEMORY shows general memory usage, but I can't find any way to show the remaining space left on the drives. ...perhaps this is simply not allowed for in the MM code? Smoke makes things work. When the smoke gets out, it stops! |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Hmmm, Good question..... I don't think so... I know the maximum size supported is 32GB but not how to check how full the card is or how much is left. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9307 |
That would be handy, but I guess if it is not there, then it's not there.(as a feature or option). I might flick an e-mail off to Geoff - perhaps it is something he would consider adding in a future firmware update... I guess the issue really is, that with modern SD cards being so huge in capacity these days, you really don't NEED to know how much room is left on the card... In the days of the Atari 800XL, the disks were a massive 180KB each side in "Enhanced density", or 92KB in single density. ;) Capacities that you needed to watch to make sure you had room enough on the disk for saving the new program, or for the datafiles it used. I guess with even a 1GB card on the MM, that is not really going to be something you need to keep track of, however, it would still be a nice touch. ;) Smoke makes things work. When the smoke gets out, it stops! |
||||
MOBI Guru Joined: 02/12/2012 Location: AustraliaPosts: 819 |
If you only want to know how much room is on the SD, then plugging it into a PC and check properties will do it. If you want to do it under programme control, well I guess that is a matter Geoff. :) David M. David M. |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9307 |
Yep, wanted to check and display remaining space on SD card via program control. Smoke makes things work. When the smoke gets out, it stops! |
||||
vk4tec Senior Member Joined: 24/03/2012 Location: AustraliaPosts: 239 |
Actually that sort of feature would be good for my GPS logger I could put on to an LCD "XX% of storage used" Can you do much with the file system ? - Andrew - Andrew Rich VK4TEC www.tech-software.net |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9307 |
I'm assuming you know about the standard MM commands for listing files, opening, closing, appending, creating/renaming/deleting directories. It's actually quite clever what can be done so easily with the MM filesystem, and being PC compatible makes data transfer and code backup so easy. However, I myself don't know much about it at all, as I am pretty new to MM. I have an original B/W MM, but have a colour MM coming in the post. I did not pay it that much attention when it was still B/W, although, was very impressed with what it could do even then. Now that it has colour and stereo sound, I just HAVE to play around with it. Smoke makes things work. When the smoke gets out, it stops! |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
I have had a couple of tries at adding the free space to the FILES command without success. The problem is that (as far as I know) the only way to work out the free space is to calculate the capacity of the card (which is complex in its own right) and then step through the FAT table and calculate the space taken by each file and subtract that from the capacity. This is both complex and very slow. There must be a better way but I have not found it yet Geoff Geoff Graham - http://geoffg.net |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9307 |
Forgive me as I know practically nothing about the nitty-gritty of SD cards, but is there not any way to query the card as to it's capacity? I would have thought that the SD card's on-board controller IC would be able to supply the specs of the card, if the correct query command was sent to it. If it is not actually as simple as that(Read: SD cards don't have any suck query command), how do full-blown OS's work out what capacity card they have? Is it just raw speed and maths? I would also think that the card itself must contain the FAT, and therein, you would imagine there being some kind of total-space data... However, I certainly see what you mean if there is no such "Intelligence" in the SD card itself. Smoke makes things work. When the smoke gets out, it stops! |
||||
VK2MCT Senior Member Joined: 30/03/2012 Location: AustraliaPosts: 120 |
To work out space available (probably): I think the boot sector contains the byte count for a sector/cluster. Then step thru the FAT and count the zeroed entries. Multiply zeroed count by sector/cluster size and you have usable empty space. Also counting file size etc doesn't account for the leftover unusable space (slack space) between file end and cluster/sector end. Regards, John B VK2MCT |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
You can get the number of sectors, clusters and bytes per sector and work out the card's capacity and that will give the total size. But the real problem is the time consuming stepping through the files adding up their size. As I said, there must be a better way. Also, as someone has already pointed out... most cards have such a large capacity that the free space is irrelevant - so you have to ask how much effort this particular feature is worth. Geoff Graham - http://geoffg.net |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
For the free space you need to scan the fat table and count the unallocated clusters. It would take at least a few seconds to almost a minute for big sd cards. Even in a pc it takes some time before an sd card information is available. This question has come up on the microchip forum it contains some useful info and some code: http://www.microchip.com/forums/m440180.aspx Microblocks. Build with logic. |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
Excellent, thank you very much. Geoff Graham - http://geoffg.net |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9307 |
It was me. I consider this matter closed because of the extra work that would be required for no real benefit other then to be able to show the available space. It was just a curiosity more then anything else - would have been nice, but if it involves much trouble to do, then "Forget it!". Smoke makes things work. When the smoke gets out, it stops! |
||||
Print this page |