That looks about right and I don't see anything specifically wrong with it, but the algorithm for deciding whether a complete message has been received looks a bit funny. Rather than try to figure out whether it would do what you need, it's easier just to post a fragment that does work:
void handleSerial()
{
const int BUFF_SIZE = 32; // make it big enough to hold your longest command
static char buffer[BUFF_SIZE+1]; // +1 allows space for the null terminator
static int length = 0; // number of characters currently in the buffer
if(Serial.available())
{
char c = Serial.read();
if((c == '\r') || (c == '\n'))
{
// end-of-line received
if(length > 0)
{
handleReceivedMessage(buffer);
}
length = 0;
}
else
{
if(length < BUFF_SIZE)
{
buffer[length++] = c; // append the received character to the array
buffer[length] = 0; // append the null terminator
}
else
{
// buffer full - discard the received character
}
}
}
}
void handleReceivedMessage(char *msg)
{
...
}
The way I'd do the parsing in handleReceivedMessage() is to write a function which loops through your command array looking for a matching string and returns the index of the matching string - in effect, a command number. Then use a switch statement to execute the numbered command. This could incorporate the PON/POF commands too.