Pages: [1]   Go Down
Author Topic: Writing a binary file to SD.  (Read 1428 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to build a data logger but rather than using a text file I want it to use a binary file. Is there a library that is available that can already do binary file writes similar to that of C/C++. The plan is to just have the Arduino append the senor readings onto a file contained on a SD card. Then I can pull the SD card and use a computer program, most likely written in C++, to analyze the data.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 615
Posts: 49388
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the SD library, the function to write to a file takes as an argument a const void * (a pointer to the data, of any type, to write to the file).

If doesn't care what is in that array - binary or ascii (not that there is really a difference). It just copies the data to the file.
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is true of pretty much all filesystems on all operating systems I know of...  A file is a vector of bytes, nothing in the filesystem code should care what those bytes are, or what they represent.  To the filesystem code "binary file" and "text file" is a meaningless distinction.
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: