Very strange thing is happening in Serial Rx

Code first:

         while (Serial2.available()){
                rx=Serial2.read();
                if (startRx==1) startRx=2;
                if (rx=='>'){counter=0; startRx=1;finishRx=0;donePrint=0;Serial.print(rx);}
                if (rx=='*'){startRx=0;finishRx=1;Serial.print(rx);}
                if (startRx==2){
                      data1[counter]=rx;
                      Serial.print(data1[counter]); // Line quote 1 below
                      counter++;
                      }
                if (finishRx && !donePrint){
                      Serial.println("< Received Data");
                      Serial.println(" ");         // Print to PC what is received!
                      Serial.print(data1);         // Print to PC what is received! - Line quote 2 below
                      Serial.println(" ");         // Print to PC what is received!      
                      donePrint=1;
                      while(Serial2.available()){
                        Serial2.read();
                      }

//8194!00110 - line quote 2 outputs this
//>8194!00110@100*< Received Data ’ Line quote 1 above output this

Data in line quote 1 is what is being sent - So it seems it receives it ok! But then why in line quote 2 it misses - ‘@100
I don’t understand why this happening and would really appreciate if someone can help me correct this.

AAARRRRGGGG

...

Please post ALL of your code, not just a snippet, nobody wants to assume what is happening elsewhere in your code

(deleted)

code attached!
Thanks

rfsingh81:
code attached!
Thanks

But it's not :sob:
And if its less than 9,000 characters, just post it in code tags, most people dont want to download it

Code is more than 9000 characters so I have tried to attach it again in PDF as previous attachment wasn’t uploaded because of it being an rtf (mac) format.

code.pdf (43.8 KB)

What are we supposed to do with the PDF ?
Why not attach the actual .ino file

UKHeliBob:
What are we supposed to do with the PDF ?
Why not attach the actual .ino file

I wasn't asked for an .ino file. So I didn't attached it. However it is not a laborious process to create one and paste the code, won't take more than 5 seconds. Apologies if you don't like my reply

Unfortunately, because I do not have the proper equipment to test this, I cannot find anywhere in your code where you would possibly be able to get a '@' then a number through serial. So I have no idea how you are getting "@100" at the end...

rfsingh81:
//8194!00110 - line quote 2 outputs this
//>8194!00110@100*< Received Data ’ Line quote 1 above output this
Data in line quote 1 is what is being sent - So it seems it receives it ok! But then why in line quote 2 it misses - ‘@100

This happens because you did not put a terminating nul ‘\0’ at the end of the string. This terminator is the usual way that you indicate where the end of a string is.

Have a look at the examples in Serial Input Basics

rfsingh81:
However it is not a laborious process to create one and paste the code, won't take more than 5 seconds. Apologies if you don't like my reply

So why have you not posted it yet?
It's a lot more than 5 seconds since you posted that comment.

If you were expecting someone here to do the work that you should do it is time for a reality check. Personally I would much prefer to spend that time helping someone else.

...R

why did you remove my post Robin? I was referring to your comment as well

I just think we should spend our time helping rather than nit-picking every tiny detail, some of which is insignificant, such as whether it was posted in a pdf or ino, its just a simple copy/paste.

The copy and paste operation can easily fail in a PDF document, depending on how it was composed. It is not reliable. Try copying from the average data sheet if you don't believe me. A multi page select is also a huge pain. You would need to do that if it has any header or footer sections, such as commentary. It's also a larger file.

Ps991:
why did you remove my post Robin? I was referring to your comment as well

I just think we should spend our time helping rather than nit-picking every tiny detail, some of which is insignificant, such as whether it was posted in a pdf or ino, its just a simple copy/paste.

Robin did not / cannot remove your posts.

I did.

There were already enough posts pointing the OP towards the light, and I thought the topic needed a little trimming.
Quite a few were deleted - there’s no need for you feel you were singled-out

Understood