rtel wrote on Tuesday, May 02, 2017:
char *atf; //incoming data command stored here
I presume you know this already, but in case not, this is not allocating
space to store data, merely allocating a pointer that can point to data.
There are many ways you could pass received data to another task. The
best method will depend on how many bytes are being passed.
If there are relatively few bytes, say less than 5, and if data is
arriving slowly, then you could copy the bytes into a queue
http://www.freertos.org/Inter-Task-Communication.html. Each demo
project in the FreeRTOS download demonstrates how to do this, and the
FreeRTOS book will also walk you through it
http://www.freertos.org/Documentation/RTOS_book.html. Each space in the
queue will need to be large enough to hold the maximum number of bytes
the message can contain though, hence this is only suitable for small
amounts of data. The benefit of doing it that way is each task has its
only copy of the data, so you don’t need to worry about one task
corrupting data that is being used by another task.
Another way is to have more than one buffer and just pass a pointer to
the buffer between tasks on a queue. For example, when buffer A
contains a message pass the address of A on a queue to the other task,
then start using buffer B. Once buffer B contains a full message pass
the address of B to the other task. If the other task has finished with
buffer A it can be used to hold the next message again, etc. This
scheme has the advantage that the queue only needs to hold pointers, not
the actual data, so the queue storage area is smaller. It is harder to
implement though as you need to make sure that only one task is using
any given buffer at any given time.
There are many other ways too. For example, just write the data into a
circular buffer, and use a task notification, event group, counting
semaphore, etc. to unblock the task that reads from the buffer each time
a complete message has been received.