Code Monkey home page Code Monkey logo

Comments (4)

sjkelleyjr avatar sjkelleyjr commented on May 20, 2024 1

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.

from arduino_freertos_library.

Sailanarmo avatar Sailanarmo commented on May 20, 2024

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.

File myBaro = SD.open("test.txt", FILE_WRITE);
baro.readBaro();
Serial.println(baro.getPressure());
myBaro.println("This should be working.");
myBaro.println(baro.getPressure());
delay(200);
myBaro.close();

Again, in setup it works 100%, but in a task for whatever reason it will not write to the SD Card.

from arduino_freertos_library.

feilipu avatar feilipu commented on May 20, 2024

I've had a quick look at this, and the Serial() class is used for writing text to the SD card.
There is a known issue with the Serial() class library. See issue #3. This same issue is probably occurring.

  Serial.print("Sensor Value: "); \\  Correctly prints the text "Sensor Value: "
  Serial.println(sensorValue);  \\  just a blank, but newline & CR are printed.

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.

from arduino_freertos_library.

feilipu avatar feilipu commented on May 20, 2024

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.

from arduino_freertos_library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.