LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-27-2012, 09:07 AM   #1
andaya
LQ Newbie
 
Registered: Oct 2008
Posts: 6

Rep: Reputation: 0
How to read file directly from compact flash?


Hello,

I notice when I read a file in linux or more easy, if I make "cat file_from_CF", the first time read from compact flash ( light status is blinking ), but if I repeat operation again, light status does not blink (I think its read from a cache or similar) .

Is there any way to force read directly from compact flash??

I have a embedded system and I would like to make a program to read a file every 1 sec to find read problems.

Best regards.
 
Old 11-27-2012, 09:52 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
What makes you think the read from cache will be incorrect? A good rule of thumb is to not try to outsmart the filesystem. If the file has been modified since your last read, the filesystem will know, and either read from the block device media, or will have updated the cache accordingly. There may be options available for your filesystem to disable caching. If you think there is a problem is with the block device, you can read and write it directly.

--- rod.
 
Old 11-27-2012, 10:06 AM   #3
andaya
LQ Newbie
 
Registered: Oct 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by theNbomr View Post
What makes you think the read from cache will be incorrect? A good rule of thumb is to not try to outsmart the filesystem. If the file has been modified since your last read, the filesystem will know, and either read from the block device media, or will have updated the cache accordingly. There may be options available for your filesystem to disable caching. If you think there is a problem is with the block device, you can read and write it directly.

--- rod.
Hello rod,

I dont think the read from cache is incorrect.
I would like to test IDE adapter because sometimes, I have some boards that ide adapter is not soldier correctly, and return me some read problems.

For example, I find some options:

open() with O_DIRECT flag to acces directly to CF, for example.
Is there other way to do it? for example, fopen().

Best regards.
 
Old 11-27-2012, 11:41 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
The filesystem will just get in the way. You should not mount the filesystem, and just use the block device (/dev/hdxx) directly in order to diagnose problems. Or, better still, access the hardware directly, either from userspace or with a kernel-mode diagnostic (that you will most likely have to write).

--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Program to read total read/write cycles for compact flash card timetraveler Linux - Hardware 0 05-06-2010 10:49 PM
How do you duplicate a 512 Meg Compact flash to a 1 GB compact flash using dd??? allen00860 Linux - Newbie 5 05-23-2009 09:48 PM
pcmcia compact flash reader file system errors drmcc Linux - Hardware 0 01-30-2006 12:33 AM
Compact flash mngmd Linux - Hardware 2 11-18-2005 10:57 PM
linux doesn't read compact flash wazilian Linux - Hardware 0 10-22-2004 01:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration