Lets assume that electrically everything is good and maybe your scope's ground was poorly connected. Can you try this as a test and see if it gives you the result you want ( I don't have an Arduino to test):. Basically, it looks like there maybe a race condition in your code between where you are resetting the state of your preparser and where you are actually reading data. You can get into a state where you check if serial data is available in the reset code and its not, then you move on to the reading where there may now be data available. In this condition the reset code did not execute so your index and other variables are not reset correctly.
This code simplifies the retrieving of the command just for a test so see if the software is the issue. It will call serialGetCommand and block until a '>' char is received. Once it is it will return with what was sent before the '>' in the serialCommandstr buffer which can then be checked. It seems like this is what you were trying to accomplish but I may be wrong.
const int pinBuzzer = A5; // the number of pin for the buzzer unsigned long T = 0; // "T" value //max input size expected for a single incoming msg #define INPUT_SIZE 32 char serialCommandstr[INPUT_SIZE + 1]; byte serialCommandindex = 0; //index of RX buffer for itterating void setup() { delay(500); Serial.begin(115200); } // END Setup() void loop() { Serial.println("Waiting for input in the form of \"<XY>\""); Serial.println("X=[A/B], Y=[1~8]"); serialGetCommand(); if (serialCommandstr[1] == 'A') { T = (serialCommandstr[2] - 1) - char('0'); Serial.print("A, "); } Serial.print("T="); Serial.print(T); Serial.print("us..."); //Beep to indicate waveform start tone(pinBuzzer, 1319, 50); delay(51); } void serialGetCommand() { char serialCommand_singleChar = '\0'; serialCommandindex = 0; while(serialCommand_singleChar != '>') { if(Serial.available()) { serialCommand_singleChar = Serial.read(); serialCommandstr[serialCommandindex++] = serialCommand_singleChar; } } serialCommandstr[serialCommandindex] = '\0'; } ```