Problem reading value from RFLinks

I’m new to this and keep hitting my head on the wall here. I am transmitting a message from one UNO to another using 433mHZ RF link and VirtualWire. Sometimes what I receive seems bogus so I have added a check to the end of the string to verify that the information is valid. At the end of each line I put “>#<” and look for it on the receiver. The line transmitted is "No data change xxx>#<. I look for the string position that has the check value but the number returned is always 30061 and I expected 19.

Any suggestions with what I thought would be simple?

/*
  SimpleReceive
  This sketch displays text strings received using VirtualWire
  Connect the Receiver data pin to Arduino pin 11
*/
#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
int checkSum = 0;
String msg = "";

void setup()
{
  Serial.begin(9600);
  Serial.println("Device is ready");
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
  vw_rx_start(); // Start the receiver
  pinMode(3, OUTPUT);
}

void loop()
{
  //Serial.print(message);
  checkSum = 0;
  msg = "";

  if (vw_get_message(message, &messageLength)) // Non-blocking//int firstClosingBracket = stringOne.indexOf('>');
  {
    digitalWrite(3, HIGH);
    for (int i = 0; i < messageLength; i++)
    {
      msg = msg + ((char) message[i]);//message[i];
    }
    int checkSum = msg.indexOf('>#<');
    if (checkSum >> 0){
      Serial.print("Received: ");
      Serial.print(messageLength);
      Serial.print(" ");
      Serial.print(msg);
      Serial.print(" ");
      Serial.print('checkSum');
    }

    /* Serial.print(" "); usedfor test
      Serial.print(msg);
      Serial.print(" ");
      Serial.print('checksum');
    */
    Serial.println();
    digitalWrite(3, LOW);

  }
}

Two things I spot

Serial.print('checkSum');

checksum isn't a char. If you want to print the variable checksum use

Serial.print(checkSum);

To print the string "checksum" use

Serial.print("checkSum");
if (checkSum >> 0)

That statement is always true... Did you mean

if (checkSum > 0)
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message

That is NOT the size of the message. That is the MAXIMUM size, not the ACTUAL size.

String msg = "";

Completely unnecessary.

I puled the code from somewhere else then added to it. How do I get the actual message length from the other unit through virtualWire?

How do I get the actual message length from the other unit through virtualWire?

It's the second (reference) argument to vw_get_message(), so the initialization (and comment) at global scope is unnecessary (and wrong).

When I comment out the line I get an error "'messageLength' was not declared in this scope".

rrfisher:
When I comment out the line I get an error “‘messageLength’ was not declared in this scope”.

So, don’t do that. The variable needs to be defined. It does not need to be initialized and it does not need a totally incorrect comment.