Hi Guys,
I have written some code which talks to a modem. At first I used large char arrays attached to a modem object to get it to work.
I have been reading up more on object orientated design (Yes I understand this is an embedded platform!), and I refactored the code to be a bit more generic, and encapsulated.
I made a modem interaction class which has the buffer, and all the information for sending a command to the modem and receiving the response. The TX buffer is a char[128], and the rx buffer is a char[256] circular buffer.
Now my question is, that is every time a new function is called, I have to create a new Modem Interaction object, which has these large buffers. What kind of overhead is it for the micro? I would probably have at max 2 of these objects instantiated at any given time. I really only need 1, but 2 due to the function calls.
At first I was dynamically allocating and freeing up memory, but after reading up a bit on this forum,it seems to be discouraged due to fragmentation so I moved away from that.
I was thinking of making the Modem_Interaction class static, but I see C++ does not support static classes.
Alternatively one could pass the Modem_Interaction object between each function, but I feel this just makes all the function calls verbose.
I was thinking of making the Modem object have one instance of the Modem_Interaction (composition), is this the way to go?
Any advice on the above?