-
Notifications
You must be signed in to change notification settings - Fork 200
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
Unable to read from SD inside of tasks #4
Comments
I can confirm, If I run the following piece of code I can write to the SD Card. If I run it in a task, it will create the text file, however it will not write anything to it.
Again, in setup it works 100%, but in a task for whatever reason it will not write to the SD Card. |
I've had a quick look at this, and the Serial() class is used for writing text to the SD card.
I'm still trying to figure out what is the underlying cause of entanglement. My suspicion is that it is to do with namespace and variable declaration. |
It looks like we got it working by opening the file in the setup and leaving it open in the task. IE, the file should already be opened by the time the task gets a hold of it. |
That's good to hear. I'm certain there is a String() class issue underlying this issue though. The only avenue I have to investigate is the potential for a variable declaration / freeing issue in the difference between the Arduino implementation, where setup() and loop() are both called by the main() function and hence may have corresponding variable space, and the FreeRTOS case where main() is never called directly. But, I haven't nailed down anything concrete yet. I've done a bit of investigation, and it seems necessary to declare Strings as Global variables, otherwise they get allocated each time the Task for() loop is run, and then reserve() space for them, to prevent reallocation. Also, conversion of int to String seems somehow problematic. Some working code is here, on Issue #3, for reference. |
When I create a task to read from the SD card using:
File myFile = SD.open("temp.txt",FILE_READ);
The file can't be opened. I tried placing noInterrupts(); in various places with no luck, as well as increasing the stack size for the task.
I can both read and write from the same file in the setup, the issue only occurs when placing the code in a task.
The text was updated successfully, but these errors were encountered: