user35009: I know this is a basic question, but as a hardware electronics guy and not a programmer I cannot seem to fathom how to do this - so any examples of code would be greatly appreciated:
I want the arduino to spit out some initialization chatter on startup - (ok, done easy).
Then I want it to listen for serial commands, they can all be same length if that helps but I want them to be strings. i.e. identifier followed by value 
Command --- Result
PWR_TRUE --- Power on device
PWR_FLSE --- Power off device
REP_FREQ --- Print frequency over serial
SP000752 --- Set power value to 752
SP016675 --- Set power value to 16675
Obviously the commands are two types, the first two being booleans and then integers, but I cant seem to find any examples not working off a single ascii character value, which is useless to me. I need more information and then from the message be able to break it down into something the arduino does. 
An example of how to import whole commands and either do something, and / or chop the command up to get the value out, would be most useful.
Many thanks in advance :)
EDIT/UPDATE:
I now seem to have found a solution thanks to Edgar as given in the comments. However I now have another question relating to updating the variables so as to effect the loop, as well as performing actions upon receipt of commands (which itself now works)
LINK HERE

user10394: You need to read the serial input into a string(char[]) or String.  You then need to parse that string to read a series of acceptable characters and then convert that into an action.
This is semi-pseudo code (not compiled, not tested, not complete)
bool quit = false;
const int MaxCommand = 10;
char command[MaxCommand];
while (!quit)
{
   int index[0];
   bool wholeCommand = false;
   bool invalidCommand = false;
   while (!wholeCommand && !invalidCommand)
   {
      while (!Serial.available())
        ;
      command[index++] = Serial.read();
      invalidCommand = CheckInvalidCommand();
      wholeCommand = CheckWholeCommand();
   }
   if (invalidCommand)
   {
      Serial.print("That's an invalid command");
   }
   else if (wholeCommand)
   {
      if (strcmp(wholeCommand, "PWR_TRUE") == 0) // 0 means it matches
      {
         power(true);
      }
      else if strcmp(wholeCommand, "PWR_TRUE") == 0) // 0 means it matches
      {
         power (false);
      }
   }
}

However That's the hard way to do it.  A much easier way is to utilities the user's CPU a bit more and get them to type data in a more computer friendly method.  After all users are easier to program, particularly with a base ball bat.
Make you language fixed length:

POWER TRUE |FALSE
REPOR FREQ
SETPW NUMBER

For instance use 5 letters for the command and then until the end of the line for arguments.  
Probably the easiest way of manipulating strings for a newbie is to look at the String object class, but the C library string functions maybe the only way to truly get what you want (strcmp, strlen, strtok, strcpy, etc)

EDIT
If you are struggling to code something on the Arduino then what I do is try and knock it up on Visual Studio.  In this case you will need a simulated Serial object.
/// Code to simulate a Serial object on a Windows PC - Not Arduino code!!!
#pragma once
#include <afx.h>

class CSerial
{
public:
    CSerial () {}
    virtual ~CSerial () {}

    void begin (const int& baudRate) {}
    void flush (void) {}
    int available (void) {return 1;}
    unsigned char read (void) {return 42;}

    void print (const char* data) {_tprintf(L"%s", data);}
    void println (const char* data = NULL) {_tprintf(L"%s\n", data);}
    void print (const int& data) {_tprintf(L"%d", data);}
    void println (const int& data) {_tprintf(L"%d\n", data);}
};

static CSerial Serial = CSerial();

You will need to change read() and available() so that they return meaningful data.  You could do this be adding a char[] to the class that is prepopulated with data, such as "POWER TRUE\nREPOR FREQ\nPOWER FALSE" and then use an int as an index into that.

user26937: Perhaps you should consider using https://github.com/j123b567/scpi-parser
It's an API library that allows you to build an 'instrument' that uses a recognized standard 'SCPI' as the communications protocol. It makes your device compliant with an industry standard, and can be implemented using tested code. Your example protocol is pretty SCPI-like already.

user7508: Expanding on my comment... I wrote a simple command line interpreter
that you can use as a base, or an inspiration, for your own interpreter.
In order to not make a link-only answer, I will put here an annotated
and simplified version.
The incoming characters are handled by loop(). They are stored into a
static buffer until a carriage return (CR = '\r') is received. When
the CR is received:

the buffer is NUL-terminated in order to make it a proper C string
it is handed to the exec() function for interpretation
the variable storing the command length is reset to zero for the next
command

Here is the code:
while (Serial.available()) {
    static char buffer[BUF_LENGTH];
    static int length = 0;  // length of line received so far
    int data = Serial.read();
    if (data == '\r') {
        buffer[length] = '\0';     // properly terminate the string
        if (length) exec(buffer);  // give to interpreter
        length = 0;                // reset for next command
    } else if (length < BUF_LENGTH - 1) {
        buffer[length++] = data;   // buffer the incoming byte
    }
}

The exec() interpreter function uses strsep() to split the
command line into a command verb and subsequent parameters. It then
compares the command verb with all supported commands in a long if...
else if sequence, like this:
static void exec(char *cmdline)
{
    char *command = strsep(&cmdline, " ");

    if (strcmp(command, "mode") == 0) {
        int pin = atoi(strsep(&cmdline, " "));
        int mode = atoi(cmdline);
        pinMode(pin, mode);
    } else if (strcmp(command, "read") == 0) {
        int pin = atoi(cmdline);
        Serial.println(digitalRead(pin));
    } else if (strcmp(command, "write") == 0) {
        int pin = atoi(strsep(&cmdline, " "));
        int value = atoi(cmdline);
        digitalWrite(pin, value);
    } else {
        Serial.print(F("Error: Unknown command: "));
        Serial.println(command);
    }
}

This one supports the three commands:

mode <pin> <mode>, meaning pinMode()
read <pin>, meaning digitalRead()
write <pin> <value>, meaning digitalWrite()

The full version is here: Simple Arduino command line
interpreter. Compared to the version in this answer, the
main differences are:

it echoes the characters it reads, and does so in a way which is
friendly to terminal emulators:


it echoes CR as CRLF
it handles BS (backspace) and echoes it as BS + space + BS

it uses strcmp_P() instead of strcmp(), with the PSTR() macro,
in order to keep the constant strings in Flash only
it supports more commands, including "help".


35009: <p>I know this is a basic question, but as a hardware electronics guy and not a programmer I cannot seem to fathom how to do this - so any examples of code would be greatly appreciated:</p>

<p>I want the arduino to spit out some initialization chatter on startup - (ok, done easy).</p>

<p>Then I want it to listen for serial commands, they can all be same length if that helps but I want them to be strings. i.e. identifier followed by value </p>

<p>Command --- Result</p>

<p>PWR_TRUE --- Power on device</p>

<p>PWR_FLSE --- Power off device</p>

<p>REP_FREQ --- Print frequency over serial</p>

<p>SP000752 --- Set power value to 752</p>

<p>SP016675 --- Set power value to 16675</p>

<p>Obviously the commands are two types, the first two being booleans and then integers, but I cant seem to find any examples not working off a single ascii character value, which is useless to me. I need more information and then from the message be able to break it down into something the arduino does. </p>

<p>An example of how to import whole commands and either do something, and / or chop the command up to get the value out, would be most useful.</p>

<p>Many thanks in advance :)</p>

<p>EDIT/UPDATE:
I now seem to have found a solution thanks to Edgar as given in the comments. However I now have another question relating to updating the variables so as to effect the loop, as well as performing actions upon receipt of commands (which itself now works)
<a href="https://arduino.stackexchange.com/questions/40015/how-can-i-update-global-variable-within-a-loop-from-outside-the-loop">LINK HERE</a></p>
 10394: <p>You need to read the serial input into a string(char[]) or String.  You then need to parse that string to read a series of acceptable characters and then convert that into an action.</p>

<p><strong><em>This is semi-pseudo code (not compiled, not tested, not complete)</em></strong></p>

<pre><code>bool quit = false;
const int MaxCommand = 10;
char command[MaxCommand];
while (!quit)
{
   int index[0];
   bool wholeCommand = false;
   bool invalidCommand = false;
   while (!wholeCommand &amp;&amp; !invalidCommand)
   {
      while (!Serial.available())
        ;
      command[index++] = Serial.read();
      invalidCommand = CheckInvalidCommand();
      wholeCommand = CheckWholeCommand();
   }
   if (invalidCommand)
   {
      Serial.print("That's an invalid command");
   }
   else if (wholeCommand)
   {
      if (strcmp(wholeCommand, "PWR_TRUE") == 0) // 0 means it matches
      {
         power(true);
      }
      else if strcmp(wholeCommand, "PWR_TRUE") == 0) // 0 means it matches
      {
         power (false);
      }
   }
}
</code></pre>

<p>However That's the hard way to do it.  A much easier way is to utilities the user's CPU a bit more and get them to type data in a more computer friendly method.  After all users are easier to program, particularly with a base ball bat.</p>

<p>Make you language fixed length:</p>

<ul>
<li>POWER TRUE |FALSE</li>
<li>REPOR FREQ</li>
<li>SETPW NUMBER</li>
</ul>

<p>For instance use 5 letters for the command and then until the end of the line for arguments.  </p>

<p>Probably the easiest way of manipulating strings for a newbie is to look at the String object class, but the C library string functions maybe the only way to truly get what you want (strcmp, strlen, strtok, strcpy, etc)</p>

<hr>

<p>EDIT
If you are struggling to code something on the Arduino then what I do is try and knock it up on Visual Studio.  In this case you will need a simulated Serial object.</p>

<pre><code>/// Code to simulate a Serial object on a Windows PC - Not Arduino code!!!
#pragma once
#include &lt;afx.h&gt;

class CSerial
{
public:
    CSerial () {}
    virtual ~CSerial () {}

    void begin (const int&amp; baudRate) {}
    void flush (void) {}
    int available (void) {return 1;}
    unsigned char read (void) {return 42;}

    void print (const char* data) {_tprintf(L"%s", data);}
    void println (const char* data = NULL) {_tprintf(L"%s\n", data);}
    void print (const int&amp; data) {_tprintf(L"%d", data);}
    void println (const int&amp; data) {_tprintf(L"%d\n", data);}
};

static CSerial Serial = CSerial();
</code></pre>

<p>You will need to change <code>read()</code> and <code>available()</code> so that they return meaningful data.  You could do this be adding a <code>char[]</code> to the class that is prepopulated with data, such as <code>"POWER TRUE\nREPOR FREQ\nPOWER FALSE"</code> and then use an <code>int</code> as an index into that.</p>
 26937: <p>Perhaps you should consider using <a href="https://github.com/j123b567/scpi-parser" rel="nofollow noreferrer">https://github.com/j123b567/scpi-parser</a></p>

<p>It's an API library that allows you to build an 'instrument' that uses a recognized standard 'SCPI' as the communications protocol. It makes your device compliant with an industry standard, and can be implemented using tested code. Your example protocol is pretty SCPI-like already.</p>
 7508: <p>Expanding on my comment... I wrote a simple command line interpreter
that you can use as a base, or an inspiration, for your own interpreter.
In order to not make a link-only answer, I will put here an annotated
and simplified version.</p>

<p>The incoming characters are handled by <code>loop()</code>. They are stored into a
static buffer until a carriage return (CR = <code>'\r'</code>) is received. When
the CR is received:</p>

<ul>
<li>the buffer is NUL-terminated in order to make it a proper C string</li>
<li>it is handed to the <code>exec()</code> function for interpretation</li>
<li>the variable storing the command length is reset to zero for the next
command</li>
</ul>

<p>Here is the code:</p>

<pre><code>while (Serial.available()) {
    static char buffer[BUF_LENGTH];
    static int length = 0;  // length of line received so far
    int data = Serial.read();
    if (data == '\r') {
        buffer[length] = '\0';     // properly terminate the string
        if (length) exec(buffer);  // give to interpreter
        length = 0;                // reset for next command
    } else if (length &lt; BUF_LENGTH - 1) {
        buffer[length++] = data;   // buffer the incoming byte
    }
}
</code></pre>

<p>The <code>exec()</code> interpreter function uses <a href="https://www.freebsd.org/cgi/man.cgi?strsep(3)" rel="nofollow noreferrer"><code>strsep()</code></a> to split the
command line into a command verb and subsequent parameters. It then
compares the command verb with all supported commands in a long <code>if</code>...
<code>else if</code> sequence, like this:</p>

<pre><code>static void exec(char *cmdline)
{
    char *command = strsep(&amp;cmdline, " ");

    if (strcmp(command, "mode") == 0) {
        int pin = atoi(strsep(&amp;cmdline, " "));
        int mode = atoi(cmdline);
        pinMode(pin, mode);
    } else if (strcmp(command, "read") == 0) {
        int pin = atoi(cmdline);
        Serial.println(digitalRead(pin));
    } else if (strcmp(command, "write") == 0) {
        int pin = atoi(strsep(&amp;cmdline, " "));
        int value = atoi(cmdline);
        digitalWrite(pin, value);
    } else {
        Serial.print(F("Error: Unknown command: "));
        Serial.println(command);
    }
}
</code></pre>

<p>This one supports the three commands:</p>

<ul>
<li><code>mode &lt;pin&gt; &lt;mode&gt;</code>, meaning <code>pinMode()</code></li>
<li><code>read &lt;pin&gt;</code>, meaning <code>digitalRead()</code></li>
<li><code>write &lt;pin&gt; &lt;value&gt;</code>, meaning <code>digitalWrite()</code></li>
</ul>

<p>The full version is here: <a href="https://gist.github.com/edgar-bonet/607b387260388be77e96" rel="nofollow noreferrer">Simple Arduino command line
interpreter</a>. Compared to the version in this answer, the
main differences are:</p>

<ul>
<li>it echoes the characters it reads, and does so in a way which is
friendly to terminal emulators:

<ul>
<li>it echoes CR as CRLF</li>
<li>it handles BS (backspace) and echoes it as BS + space + BS</li>
</ul></li>
<li>it uses <code>strcmp_P()</code> instead of <code>strcmp()</code>, with the <code>PSTR()</code> macro,
in order to keep the constant strings in Flash only</li>
<li>it supports more commands, including "help".</li>
</ul>
