uArm Get Polar Coordinates Help

I am having difficulty getting polar coordinates from a uArm Swift Pro.A PC is connected to the uArm Controller.

Here is a snippet :

if( digitalRead(JOY_DOWN) == LOW ){
Serial2.write(“P2221\r\n”);
while(Serial2.available() > 0 ){
pol_coord += char(Serial2.read());
delay(10);
}
Serial.print("Returned : ");
Serial.println(pol_coord);


This is what I see in the serial monitor when the JOY_DOWN pin is taken low:

Returned : ok

Returned : ok S190.4778 R89.9121 H19.2031
ok S190.2558 R89.9121 H19.1027
ok

Is this correct? Can someone explain what is happening here?

Why is the first response only ok? Actually, sometimes the the first response is null.

Why are there three lines after a successful read?

This pattern continues as long as the JOY_DOWN pin is held low. There is always a first response with no data followed by a full response.

It is necessary to set a delay time for data transmission. If the wait time is not enough, the next step will be executed before the response data come.
Here is an example for your reference

Thank you, I’ll try adding a delay this afternoon.