Uploading an object to a SDCard

I want to write some data onto a SD Card. The data is in the form of an object, with several int variables. How do I write all this onto an SD Card?

1 Like

This is what’s known as serialization (and deserialization to pull the object back off the SD Card).

There is, as far as I and a quick Google can tell you, no way to do this without a little working using just the C++ standard library, but you can probably figure something out, even if not especially efficient, using an std::ios::binary fstream or you could probably also just find some code online to do the same thing.

How much programming knowledge do you have? This is either a relatively trivial task or a pretty daunting one depending on how well you know C++.


This is all assuming you’re using C++.

I know PROS gives you direct access to the filesystem with stdlib commands, I have no idea if VEXCode or RMS do. What I described would need the stdlib, since I doubt any wrapper that VEXCode or RMS may or may not provide would support binary blobs without you jumping through more hoops (not that these hoops would make this any more especially difficult, you could probably just cast to an std::bitset and convert that to a string, I’ve done something similar in the past without much issue).

If you’re using RMS Python, then this is very easy! Just import pickle (assuming they give you access to this part of the stdlib, I’m not 100% certain they do) and look up the python pickle docs, it’s pretty simple to use.

1 Like

Whoa, hang on a second. You’re overcomplicating the problem a bit. It definitely is not the simplest problem though, I agree with you on that.

Because the OP placed his thread in the VexCode V5 Text Support, this is actually more simple than it might sound.

VexCode has SD Card commands that can be used to write to the SD Card.

This is the VexCode API that has an index of the commands.

And this is an example from JPearman

Together, these should help the OP figure out how to do what they want.

But this is not a beginner project for C++. If you aren’t very confident in C++, this probably isn’t the best thing to be working on.


The last, and possibly most simple option that I forgot to mention is just printing out each variable in the object in some order and then building a very easy parser to re-instantiate the object later. This actually wouldn’t be that hard if it’s just a simple object with a bunch of ints but once you start having nested custom objects it gets more complicated.

1 Like

This information actually makes the problem slightly harder, as I alluded to in my 2nd post, since you have to go through either the C File API (not super easy (EDIT: I think this might’ve been VCS only, idk if it’s an option for vexcode too)) or you have to convert to a blob. I would probably just go with what i mentioned above this about building a simple parser in that case since he said the object is just a bunch of ints.

1 Like

It is an option for VexCode, since it is in the VexCode docs.

Your methods are likely superior, I simply thought that it would be easier to work off of what VexCode already has structured rather than try to figure out the alternate methods suggested (I could be wrong, I’m not really sure). Regardless, I don’t have very much to offer in this area, and I appreciate you giving some help and suggestions to the OP.


I was saying that the C FILE api might not be an option for vexcode, jpearman was talking about vcs when he said it on the forum and the docs don’t mention it so I’m not sure.

The vexcode file api is designed for transferring text, not blobs, so you would have to convert the object the a blob beforehand and know how to cast it back to the object (deserialize it).

Neither of these things are especially difficult, assuming vexcode exposes whatever header contains std::bitset, which I don’t know why it wouldn’t.

I would recommend that he looks into methods to convert between objects to/from bitsets and bitsets to/from strings.

Once again though, for this probably pretty simple object I would recommend just making a simple parser if he struggles with that.


It’s a… working knowledge I guess. Thanks for the help