Comments (6)
I can't help you write apps, too many people ask.
If you find a bug, isolate the bug in your app and post a simple example that demonstrates the bug.
from sdfat-beta.
In the picture bellow you can see what it comes out after running the example program bench with some modifications.
here is the code i added to represent in a simple way my case.
.
.
.
struct sample{
float x; float y;
};
sample lino[BUF_SIZE];
sample* pl = lino;
.
.
.
// fill buf with known data
if (BUF_SIZE > 1) {
for (size_t i = 0; i < (BUF_SIZE - 2); i++) {
buf[i] = 'A' + (i % 26);
pl[i].x = esp_random();
Serial.print(pl[i].x);
Serial.print('\t');
pl[i].y = esp_random();
Serial.println(pl[i].y);
}
buf[BUF_SIZE-2] = '\r';
pl[BUF_SIZE-2].x = 0.0;
pl[BUF_SIZE-2].y = 0.0;
}
buf[BUF_SIZE-1] = '\n';
pl[BUF_SIZE-1].x = 0.0;
pl[BUF_SIZE-1].y = 0.0;
.
.
.
if (file.write(pl, BUF_SIZE) != BUF_SIZE) {
error("write failed");
}
.
.
.
The size from the bench file is correct:
I would like to know if there is a special reason why you define buf as a uint_8 pointer and cast buffer32 into an uint8_t? And which would be the consecuences in the spi performance if i defined as an struct
from sdfat-beta.
I toked a look at the FatFile write function, then I had to inform my self about "reinterpret_cast conversion" and so far as I understand it works only for integers and pointers. As you defined in write-function, buf is void* pointer type and it will be casted direct at the beginning.
const uint8_t* src = reinterpret_cast<const uint8_t*>(buf);
I would like to know how to work with different variables types like float and struct, in order to write them in the Sd-Card. Or if its actually possible to work with them.
Thanks for your time
from sdfat-beta.
if (file.write(pl, BUF_SIZE) != BUF_SIZE) {
error("write failed");
}
The size of pl is not BUF_SIZE bytes. It is sizeof(pl) so you are only writing a portion of the array.
Casting a variable will not result in a text file.
I cast a uint32_t to uint8_t in the bench example since some processors require DMA writes to be aligned on 4-byte boundaries for maximum speed. The Teensy 4 board can write at 22 MB/sec with it's fast 4-bit wide SDHC controller.
Since my µC only has 600µs to write
This rate can't be achieved with a simple program. SD cards can have write latency times of many milliseconds so you must acquire and buffer data to write at this speed. This may require data acquisition in an interrupt routine or a RTOS.
It may not be possible with your board since it is slow for SPI writes.
from sdfat-beta.
This may require data acquisition in an interrupt routine or a RTOS.>
That´s my plan. I use a time interrupt to check the values from my sensor, this happen every 1ms and it´s needs ~350µs to read the values. So every 1ms it will be a new sample to my array, is the array full then should be copied in the Sd.
I would be satisfied if I get at least the right values in the Sd, then i would work on the timing problem.
from sdfat-beta.
You must fix your bugs. You are not writing the correct amount of data to the SD. The data is written as binary, not text.
I am closing this since I don't have time to tutor C++ programming.
from sdfat-beta.
Related Issues (20)
- ESP32, Multiple cards, and Software Serial questions HOT 13
- SPI access to external SD Card other than normal SPI Pins (not soft spi) HOT 10
- lfnGetName might not properly null terminate callerstring HOT 7
- Moving cursor position with O_APPEND HOT 1
- Support for Multiple Partitions HOT 2
- FsVolume support partition? Also maybe memory leaks HOT 9
- Maybe support __has_include for configuration for sketch or library override of configuration. HOT 5
- Warning "'next' may be used uninitialized in this function" HOT 3
- Conflict between SdFat-beta library and USBFat library
- cannot open File with UTF-8 Name HOT 1
- Any attempt to have Web SD file Downloader
- ESP32 check sd format HOT 6
- SD Card hot swap HOT 1
- 'SdFat {aka class SdFs}' has no member named 'vwd' HOT 7
- SDIO multi-sector read timings HOT 2
- Some SDCard Samples work others not ,SdFat Lib HOT 3
- ESP32: SD-card on HSPI port HOT 4
- [Feature Request] ESP8266 compatible wrapper HOT 3
- ESP32 S3 usage of SPI3, how to do? HOT 1
- PrintFile and StreamFile warnings with -Woverloaded-virtual HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdfat-beta.