I think maybe I’ve been staring at the glowing box for too long, overthinking a problem, but maybe someone out there has an idea for me:
In short, I have sensors that send their data over serial in the format of:
abcd, int idNumber, int data1, int data2; abcd is ignore-able.
Easy to parse out the id, data1 and data2, but what I need is to store them as variables that update whenever new data comes in. Catch: idNumber is a 6 digit code from the sensor supplier that I don’t control, and sensors will come and go at random so I can’t declare that somewhere as a variable…maybe.
Ideas:
- associative array/hashmap myArray[“idNumber”] = {data1, data2}, except I can’t seem to find such a thing for boron? Get all kinds of errors when trying something like std::map<std::string, int, std::less<std::string>> myArray; . Pairs of not-multidimensional arrays instead of one to rule them all.
- int myArray[999999]; and just have a pantload of null rows. Boron seems to crash even if the compiler says it’s ok, which I don’t think is surprising.***
- create a variable name on the fly: what a horrible old perl trick that even perl coders cringe at, but if it were possible I might get to go home, even if I wouldn’t sleep too soundly for a night or two…
ideas?
*** this actually works at some scale, but then I need a version of “retrieve only the populated ones” later on, and sorting/iterating through a giant array sounds like a bad idea