From: "Ken Yee" <kenkyee@excite.com>
To: ecos-discuss@ecos.sourceware.org
Subject: [ECOS] reading size and used space on compact flash (CF) card?
Date: Fri, 29 Jun 2012 13:16:00 -0000 [thread overview]
Message-ID: <20120629091545.28040@web005.roc2.bluetie.com> (raw)
I haven't been able to dig anything up on this using the search engine or Google.
Has anyone been able to read the size and free space left on a CF card (which uses the IDE driver)?
Closest thing I found was this code that I modified slightly:
int get_size() {
cyg_disk_info_t cf_info;
char cf_model[41];
cyg_io_handle_t cf_handle;
cyg_uint32 len = sizeof(cyg_disk_info_t);
int error = cyg_io_lookup(CFDEV_, &cf_handle);
if (error!=0) {
printf("lookup error:%i\n",error);
return 0;
} else {
error = cyg_io_get_config(cf_handle,0,&cf_info,&len); //
//printf("cf get_config error: %i %i\n",error,-EINVAL); // should get -EINVAL???
uint32_t block_size = cf_info.block_size;
uint32_t blocks_num = cf_info.blocks_num;
uint32_t phys_block_size = cf_info.phys_block_size;
bool is_connected = cf_info.connected;
memset(cf_model, 0, sizeof(cf_model));
strncpy(cf_model,cf_info.ident.model_num,sizeof(cf_model));
printf("block size:%d, phys_block_size:%d, num_blocks:%d, connected:%d, model:%s\n"
,block_size,phys_block_size,blocks_num,is_connected,cf_model);
// block_size should be 512 bytes and we want to return megabytes
block_size = 1; // hack for now because it's returning 33MB for block size from the current API :-P
return (((blocks_num/1024)*block_size)/1024);
}
}
But as mentioned in the code, it's returning crazy numbers in the 33MB range no matter what size CF card I install (I've tried 32MB and 128MB :-(
Is there any other official API to read the size of it or any other IDE devices?
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
next reply other threads:[~2012-06-29 13:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-29 13:16 Ken Yee [this message]
2012-06-29 22:42 ` Frank Pagliughi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120629091545.28040@web005.roc2.bluetie.com \
--to=kenkyee@excite.com \
--cc=ecos-discuss@ecos.sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).