How to read/write raw bytes from a flash card in C++?

K

Kelvin @ SG

Hi, group:

I am intermediate in C programming, basically I programmed in Unix for
digital signal processing...

Now I need to write a C++ program to read/write the whole volume of a FAT
formatted smartmedia
card...I can view the raw data in WinHex...now what I want is, in generic C
codes to read all the data
I see in WinHex...

Could anybody teach me on how to handle this kind of work? Any websites are
welcome.

Best Regards,
Kelvin
 
K

Kelvin @ SG

By the way, I actually understands FAT, I need to know the functions and
headers in C that
allows me to implement a simple reader for FAT...Some example codes and
websites will
be great.

Kelvin
 
M

Mark A. Odell

By the way, I actually understands FAT, I need to know the functions and
headers in C that
allows me to implement a simple reader for FAT...Some example codes and
websites will
be great.

Your still off-topic. Try this question in comp.arch.embedded - not a
language ng.
 
D

Dan Pop

In said:
I am intermediate in C programming, basically I programmed in Unix for
digital signal processing...

Now I need to write a C++ program to read/write the whole volume of a FAT
formatted smartmedia
card...I can view the raw data in WinHex...now what I want is, in generic C
codes to read all the data
I see in WinHex...

fopen on the raw device and then fread should do the job if you want to
bypass the file system.

Dan
 
P

pete

Mark said:
Your still off-topic. Try this question in comp.arch.embedded - not a
language ng.

When I was interested in File Allocation Tables,
I read my compiler documentation to find nonstandard functions
which dealt with the topic.
I don't recall anything about the topic,
which would suggest that there was an embedded aspect to it.
 
T

Thomas Matthews

pete said:
When I was interested in File Allocation Tables,
I read my compiler documentation to find nonstandard functions
which dealt with the topic.
I don't recall anything about the topic,
which would suggest that there was an embedded aspect to it.

The _standard_ C language has no facilities for File
Allocation Tables. File allocation is an operating
systems topic and best discussed in a newsgroup that
discusses your operating system.

A File Allocation Table (FAT) is a mapping that shows
what chunks of a file system are allocated. Many
file based operating systems will use an array of
bits for this.

Some OS's might also indicate what file is occupying
which chunks.

But all of this has nothing to do with the C language.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
M

Mark A. Odell

pete said:
When I was interested in File Allocation Tables,
I read my compiler documentation to find nonstandard functions
which dealt with the topic.
I don't recall anything about the topic,
which would suggest that there was an embedded aspect to it.

We use the FAT file system often times in embedded systems, therefore we
need to know how it works and how to implement it. Thus, we'd be more than
happy to explain it to someone over there.
 
G

Gordon Burditt

I am intermediate in C programming, basically I programmed in Unix for
digital signal processing...

Now I need to write a C++ program to read/write the whole volume of a FAT
formatted smartmedia
card...I can view the raw data in WinHex...now what I want is, in generic C
codes to read all the data
I see in WinHex...

On some systems, a smartmedia card connected through a USB card
reader shows up in the system as a 'umass' device and a virtual
disk drive. Mount it (assuming the system requires mounting: UNIX
does, Windows doesn't). Access it as though it were a filesystem
on a hard disk (using appropriate file names for the files on the
flash card). You need to use system-specific functions to determine
that it is *NOT* a hard disk.

If you want to see the whole filesystem image, in UNIX you can
use the device name for the virtual disk partition. From there,
feed it to fopen(), open as a binary file, and read data as needed.
I'm not sure how you do that in Windows.

Gordon L. Burditt
 
K

Kelvin @ SG

Thank you all for your replies! Basically I have some clue now.
I will use WinHex to save my entire Smartmedia image into a mega-file...
Then I will open the mega-file in binary access mode...
And I will write some C codes to implement how to read/write (extract
actually) files
to/from this mega-file. That is all programming all about.

Eventually I will write assembly code or use FPGA to interface directly to
my Smartmedia
and do something fun with it...

Do I sound logical?

Best Regards,
Kelvin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top