I am trying to clean up an existing application where handling of incoming serial data is done inside an event function OnRxData() of the serial component.
I want to move the processing into a regular procedure so I can later add a different hardware channel (TCP/IP) as a user choice.
Now when looking at the existing code in the RxData() procedure I see that there is a while loop retrieving one character at a time from the serial port and processing it. In the processing these characters are stuffed into a temp string buffer until the complete packet is ready.
If I divide the single procedure into two where the event procedure would have the while loop extracting the character and then call a handling procedure with the char as argument then the processor cannot have the while, but it must have the buffer...
The only way I could imagine this to work is if:
1) I use a globally defined string variable as buffer
2) It is somehow possible to define the buffer as a static local var.
So since I don't really want to use a global, is it possible to declare a local variable static in the sense that it retains its values across calls to the procedure?
If so how is it done?
