Where can I store and read from a .csv file?

My controller module needs to read feedforward control data from a number of .csv files. Is there a path in the firmware where I can store these files and read from them (fopen("?/myfile.csv", “r”))?

Would I rather want to use the microSD card for this? If so, what would the path be?

Thank you

The path to the sdcard is /fs/microsd/

1 Like

Thanks. Should I be able to read from the sdcard during flight?

Yes you can.

Post must be at least 20 characters.

Thanks.

Bear with my stupid question here (I’m a bit out of my depth), but I’d like to be 100% confident I’m doing this correctly before I move on. So, in the main file of my controller module, there’s no reason I couldn’t write exactly this and expect it to work?

FILE* myfile = fopen("/fs/microsd/my_file.csv", “r”);

with “my_file.csv” located in the root directory of the microSD card.

That’s right. For example take a look at the sd_bench utility that opens the file /fs/microsd/benchmark.tmp.

Adding PX4_ROOTFSDIR to the beginning updates the path to work properly if you build and run the firmware on your PC (SITL).

1 Like

Thanks a lot.

I’m running a HITL simulation right now and when fopen() gets called, QGC says “connection lost”, which isn’t a very helpful message. I’m still figuring out debugging with PX4 though, so that’s probably the bigger issue.