Consider a board with two processors A and B. A receive 16 MiB of data
in 2 MiB chunks.
Upon receipt of data A will 'keep' the first 8 MiB. The remainder A
will B will transfer to B.
My current approach works but I question the maintainability.
Because of 'board specific API calls' I'll provide a pseduo code
version of my current approach on the the board with the two
processors.
So now:
size_t const kilobyte(1024);
size_t const mebibyte(kilobyte*kilobyte);
bool new_msg_available(true); // assume true first time
unsigned int count(0);
size_t const payload(2 * mebibyte);
size_t source[payload];
size_t dest[8 * mebibyte];
size_t dest2[8 * mebibyte];
void test_func::rx_data_from_sender()
{
while (1)
{
// semTake (some_sema, -1);<- wait forever on a semaphore [1]
if ( new_msg_available )
{
size_t const msg_size(16 * mebibyte); // [2]
size_t const num_runs = msg_size / mebibyte;
//size_t const distribution = msg_size / payload;
new_msg_available = false;
count = 0;
}
if (count < (num_runs / 2))
{
memcpy(source, dest, payload); [3]
++count;
}
if (count >= num_runs ) // now 'copy' to B's memory
{
memcpy(source, dest2, payload);
++count;
}
if (count == num_runs) new_msg_available = true; // reset
}
}
Item [1] is RTOS 'functionality'
[2] The size varies and is obtained from a header. For demonstration
purposes I hard coded it.
[3] is not a memcpy but we use memcpy for demonstration purposes.
This of course is a synopsis. I suspect - perhaps - a chain of
responsibility approach would suffice here because in reality I ahve 4
processors on card. The example only show 2.
I'd like to be able to derive from a class and have objects maintain
their own state. When object A is done it hands off to B. B when
complete will 'reset'. I'm having a hard time determining how to do
this. Sample source appreaciated.
Thanks