I am getting in to the serialport class at the moment and I can read data without any problem but the thing is where do I store it.
I just would like your opinion about what is the best way to store my ring buffer data.
I would like to create two methods one read_data_from_serial and one read_data_from_ringbuffer (unsigned char buffer[1000] = {0);
- Do I setup a managed variable for the ring buffer or a unmanaged variable
- Do I create a global variable? and how
- Do I save the data in a class? and how
Everywhere where I read it says it is eval to use globals.
I know how to create a class and how to call it but the thing I miss is how I can store multiple times data in a class.
I have a timer that collects the data and is called every 100ms so if I define a class in the timer and call it I will get an different copy every time right ?
I know how to create a class and how to call it but the thing I miss is how I can store multiple times data in a class.
I have a timer that collects the data and is called every 100ms so if I define a class in the timer and call it I will get an different copy every time right ?
so how should I approach this?
I don't really get the point- you want to define a class inside your timer class? And what do you mean by calling a class? (Im very sorry, my English isn't that well).
Collecting data ist mostly done by arrays. You can use a std::vector (or a std::set, but then you would have to implement a comparison operator for the class to store inside it).
I have a time class that runs every 100ms this picks up the data into a unsigned char^ array I would like to copy this data into a ring buffer. that keeps saved.
if my class is called serialPort I would do the following in my timer class.
serialPort saveData;
saveData.Storedata(pointer to my data);
but since the timer class is called every 100 ms I will get a new copy of serialPort every time so I can't keep my data.