From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26985 invoked by alias); 29 Jun 2012 13:16:01 -0000 Received: (qmail 26967 invoked by uid 22791); 29 Jun 2012 13:15:58 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,MIME_QP_LONG_LINE,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from outbound003.roc2.bluetie.com (HELO outbound003.roc2.bluetie.com) (208.89.132.143) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Jun 2012 13:15:45 +0000 Received: from web005.roc2.bluetie.com ([10.200.2.99]) by outbound003.roc2.bluetie.com with bizsmtp id UDFl1j00828AQ4S01DFlSQ; Fri, 29 Jun 2012 09:15:45 -0400 X-CMAE-OUT-Analysis: v=2.0 cv=K7+g7lqI c=1 sm=1 a=HH-tsQuWXOsA:10 a=i-wQWBNYtOgA:10 a=IkcTkHD0fZMA:10 a=FmX3VfpdAAAA:8 a=QoHJ8kPOAAAA:8 a=d44NX1khmZ-xw3jcORIA:9 a=QEXdDO2ut3YA:10 a=H01LYRIV_7WogOf_:21 a=XMbX6TvqHF_hKs4r:21 a=vL3HbRNXJhJQQ3qw5A4SiA==:117 X-CMAE-OUT-Score: 0.00 Received: from web005.roc2.bluetie.com (localhost.localdomain [127.0.0.1]) by web005.roc2.bluetie.com (Postfix) with ESMTP id 1A12BE9015E for ; Fri, 29 Jun 2012 09:15:45 -0400 (EDT) Message-ID: <20120629091545.28040@web005.roc2.bluetie.com> X-HTTP-Received: from kenkyee.excite [68.165.80.158] by web005.roc2.bluetie.com (BlueTie WebMail ); Fri, 29 Jun 2012 09:15:45 -0400 Date: Fri, 29 Jun 2012 13:16:00 -0000 Cc: To: ecos-discuss@ecos.sourceware.org From: "Ken Yee" Content-transfer-encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: [ECOS] reading size and used space on compact flash (CF) card? X-SW-Source: 2012-06/txt/msg00064.txt.bz2 I haven't been able to dig anything up on this using the search engine or G= oogle. Has anyone been able to read the size and free space left on a CF card (whi= ch 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 =3D sizeof(cyg_disk_info_t); int error =3D cyg_io_lookup(CFDEV_, &cf_handle); if (error!=3D0) { printf("lookup error:%i\n",error); return 0; } else { error =3D cyg_io_get_config(cf_handle,0,&cf_info,&len); // //printf("cf get_config error: %i %i\n",error,-EINVAL); // shou= ld get -EINVAL??? uint32_t block_size =3D cf_info.block_size; uint32_t blocks_num =3D cf_info.blocks_num; uint32_t phys_block_size =3D cf_info.phys_block_size; bool is_connected =3D 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, conne= cted:%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 megabyt= es block_size =3D 1; // hack for now because it's returning 33MB f= or 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 rang= e 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 dev= ices? -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss