Help Reading Serial Data and writing to substrings

I have a data string of approx 150 characters that is received using NSS.
What I need to accomplish is:
Check to see if the Header (the first 4 Characters) == MyHeader (“1068”)
If True then I must read the next 110 bytes of data into an Array “SerReceive”.
I must then create 3 SubStrings from “SerReceive”:
"SubString1=“SerReceive characters 5 through14” and convert these 10 chracters to ASCII Text.
"SubString2=“SerReceive characters 52 through 62” and convert these 11 chracters to ASCII Text.
"SubString3=“SerReceive characters 105 through 110”.

Once I have the 3 SubStrings, I must create “StringTx”:
“StringTx”=“SubString1” & “SubString2” & “SubString3”.

I then Transmit “StringTx” via an XBee modem.

I am a newbie to Arduino and C, having only done limited programming in VB6 and VB.Net

Any assistance would be GREATLY Appreciated.

This is the Sketch I am using, but I get an error:
error: request for member ‘substring’ in ‘outbound’, which is of non-class type ‘char [111]’

#include <NewSoftSerial.h>

NewSoftSerial MyPort(4,3, true);

char incoming; // incoming serial data
char outbound[111];
int i=0;
String Model;

void setup() {

void loop() {

i=0; // reset the array index

while (MyPort.available()) {
incoming =;
//if (incoming == ‘@’) break; // escape character is @
// if ((incoming < ‘0’) or (incoming > ‘9’)) break; // discard non-numerics
outbound*=incoming; //copy the serial byte to the array*

  • i++; // increase the array index*
    // Serial.print(i);
    // Serial.println(incoming);
  • }*
    _ outbound = 0; // terminating character ← add this line_
    * if (i !=0)*
    * Model = outbound.substring(0,4);*
    * Serial.print(Model); //if the array is not zero, there is data*

*} *

You also need to handle (or ignore) errors anywhere they can possibly occur, like during serial transmission.
Just keep that in mind.

In a perfect world however, after making sure that each data string ended with a unique delimiter, since each string is unknown length…

I’ve cut the task down as much as possible while leaving room for error handling. If you can think of more specifics to expect in the data then use those for more error checking.

The task:
Every line that starts with “1068” gets 3 sets of chars collected and printed as a single string.

[u][b]pseudocode here[/b][/u]

const byte  myH[4] = { '1', '0', '6', '8'}; // MyHeader, 1068
const byte  eol = '\r'; // I use carriage return as end of line delimiter, the sending terminal must be set accordingly

char  B; // serial read buffer
char  strOut[28]; // For 10 bytes + 11 bytes + 6 bytes plus terminating 0... because there is no perfect world
byte  inLen = 0; //  how many bytes in the current line have been read. note 1st character is #1, 0 is for none
byte  outLen = 0; // what byte to write into strOut next. note first character goes into strOut[0]
byte  ignore = 0; // if the data block does not start with 1068 then read until the next block

void setup() -- Serial and all else needing to be done

void loop() {
  if (Serial.available() < 1)  then delay(10); return; // wait 10 millisecs and run loop() again

  B =; inLen++; // read a character, increment the count

  if (B == eol) {

  if (inLen > 255)..... then there is an error, the appx 150 char line is way too long, which never happens in a perfect world

  if (ignore)     return; // line doesn't begin with 1068 so just waiting for eol and the next line

  if (inLen < 5)  {
    if (B != myH[inLen])  ignore = 1; // if the 1st 4 characters are not 1068 then ignore the rest of the line
  else if ((inLen >=5 && inLen <= 14) || (inLen >= 52 && inLen <= 62)  || (inLen >= 105 && inLen <= 110))  {
    strOut[outLen++] = B; // these are the only data you want to send back

    if (inLen == 110 && outLen != 27)..... then there is an error, the output string is too long due to a code error, which never happens in a perfect world

void end_line()
  strOut(outLen) = 0;
  inLen = outLen = ignore = 0;

Hope I got everything!

Many thanks GoForSmoke

What is the line : pseudocode here

pseudocode means fake code.

it's more like a text flowchart or guide, it is not code you can compile, it's not totally complete, it's not debugged

You can comment every line of it and use it as a guide to write your actual code IF you find it's what you want and can follow what is written.

Maybe there's something in there that gives you a different idea, then you might want to pursue that instead.