-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
writing block-wise in sd from an array type struct #33
Comments
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. |
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. |
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.
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. |
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. |
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. |
Hardware:
Board: NodeMCU-32S
IDE name: Sloeber
Flash Frequency: 40Mhz
Upload Speed: 115200
Computer OS: Windows 10
Description:
Hi Mr. Greiman,
I'm using the Beta Version to save data from a sensor into an sd card. I defined an array type "sample", which is a structure with 32 Byte size. Since my µC only has 600µs to write in between I decided to write in 1024 Byte-Blocks, perhaps my array´s size 4096 Bytes is. After running the program and checking the sd, I saw completely different values than I expected so I'm doing something wrong and I suppose it´s my approach with the buffer pointer.
I thought about casting my values as a string but this takes to long.
Which is the popper way to approach in my case?
Thank you very much.
Sebastian
The text was updated successfully, but these errors were encountered: