How to read from .csv file into controller module?

I have my own controller module, which works fine other than this problem. I have an m by n array stored in a .csv file on the microsd card that I want to read in and use in the controller module. What I am currently doing is not working:

static const char *csv_file = PX4_ROOTFSDIR"/fs/microsd/myfile.csv";
FILE* stream = fopen(csv_file, "r");
PX4_INFO("Arbitrary message");
...parse into vector of vectors...

For some reason, I can never even get as far as the arbitrary message.

I’m not sure if I’m doing something fundamentally wrong, but alternatively I would really appreciate any higher-level advice about how to go about this objective: reading an array from a .csv file into a vector of vectors in my controller module. I would not call myself a programmer in any language, let alone C/C++, so any help is useful!

Thank you

Are you running this manually or at startup time?
Do you have a console attached?

Are you aware of SITL? You could initially get it working on your PC and only then move over to actual hardware.

If I understand you correctly, I’m running this at startup time. I’m using HITL and running it when I switch into my controller module in the flight simulation.

Yes, I have the NSH attached.

I’m hoping I can do this all in HITL.

Now I’ve tried hardcoding (copy/pasting essentially) my vector of vectors into the module itself, as to avoid having to read anything off the sd card. But with the size of my matrices - four matrices, each around 100 by 20 - I’m running into memory issues.

I was trying to determine how and where you’re running this. If you aren’t seeing “Arbitrary message” your code probably isn’t running.

HITL is fine for development. The main benefit of SITL is faster compile, debug cycles and better debugging tools.

Okay, I’ll look into SITL as an alternative.

It now seems I shouldn’t even bother worrying about this reading function until I can figure out what to do about the size of the data I want to read in.

Just briefly…If I want to use about 100KB for these vectors, is that ever going to work with the Pixhawk or might I just as well give up on that?

Are you sure you need them all in memory at the same time? Run free on your pixhawk to see what’s available.

I don’t know what you’re trying to do, but one option could be offloading the computation to a companion computer (intel edison or odroid) connected to the pixhawk