How to receive data from setpu{} to computer through bluetooth ?

Hi, I have a HC-06 v2.0 bluetooth ,and I downloaded the sscom32 serial console software to see the received data from arduino and transmit data to arduino.

1.I can transmit data to the arduino and receive data ONLY from loop{} ,but not from setup{}.why?

#define MotorR_I1     8 
#define MotorR_I2     9  
#define MotorL_I3    10  
#define MotorL_I4    11  
#define MotorR_ENA    5 
#define MotorL_ENB    6 


void setup()
{
  Serial.begin(9600); 
  
  pinMode(MotorR_I1,OUTPUT);
  pinMode(MotorR_I2,OUTPUT);
  pinMode(MotorL_I3,OUTPUT);
  pinMode(MotorL_I4,OUTPUT);
  pinMode(MotorR_ENA,OUTPUT);
  pinMode(MotorL_ENB,OUTPUT);
  
  analogWrite(MotorR_ENA,200);    
  analogWrite(MotorL_ENB,200);    
  delay(1000);
  Serial.println("s");// Which I want to transmit to the computer. 
}

void advance(int a)    
{
    digitalWrite(MotorR_I1,HIGH);  
    digitalWrite(MotorR_I2,LOW);
    digitalWrite(MotorL_I3,HIGH);   
    digitalWrite(MotorL_I4,LOW);
    delay(a * 100);
}

void turnR(int d)  
{
    digitalWrite(MotorR_I1,LOW);    
    digitalWrite(MotorR_I2,HIGH);
    digitalWrite(MotorL_I3,HIGH);   
    digitalWrite(MotorL_I4,LOW);
    delay(d * 100);
}

void turnL(int e)   
{
    digitalWrite(MotorR_I1,HIGH);   
    digitalWrite(MotorR_I2,LOW);
    digitalWrite(MotorL_I3,LOW);    
    digitalWrite(MotorL_I4,HIGH);
    delay(e * 100);
}    

void stopRL(int f)  
{
    digitalWrite(MotorR_I1,HIGH);   
    digitalWrite(MotorR_I2,HIGH);
    digitalWrite(MotorL_I3,HIGH);  
    digitalWrite(MotorL_I4,HIGH);
    delay(f * 100);
}

void back(int g)    
{
    digitalWrite(MotorR_I1,LOW);    
    digitalWrite(MotorR_I2,HIGH);
    digitalWrite(MotorL_I3,LOW);    
    digitalWrite(MotorL_I4,HIGH);
    delay(g * 100);     
}

void loop()
{
    
     if (Serial.available() > 0) {
    
     int cmd = Serial.read();
  switch(cmd)  
  {
    case 'S':  
      back(5);
      break;

    case 'A':  
      turnL(5);
      break;
        
    case 'D':  
      turnR(5);
      break;
      
    case 'W':  
      advance(5);
      break;
        
    case 'Q':  
        stopRL(5);
        break;
        
  }
 }
  
}

2.I noticed that after connecting successful,there are two virtual com ports: receive and transmit. If I want to use one of the functions , another com port has to be closed. but if I use real wire connect to the USB plug,I don't need to turn off any one of them , why? Is bluetooth simplex and USB duplex?

You can receive data while in the setup() function but you will need to create a repetitive process that keeps checking until all the data has arrived. It seems easier to do that in loop().

If you tell us what you are trying to achieve we can probably give better advice.

...R Serial Input Basics

I want to send a char to active the dc motors car moving foward by bluethooth. So I need to check whether the bluetooth is connected , it should print "Send any character to begin" and wait a char to be send if it is connected successfully. then I push a button to send any char to the arduino to make the car moving forward ,like this :

 void setup() {
 Serial.begin(9600);
 pinMode(InA1, OUTPUT);
 pinMode(InB1, OUTPUT);
 pinMode(PWM1, OUTPUT);

 pinMode(InA2, OUTPUT);
 pinMode(InB2, OUTPUT);
 pinMode(PWM2, OUTPUT);



    
    Serial.println("\nSend any character to begin : ");
    while (Serial.available() && Serial.read()); // empty buffer
    while (!Serial.available());                // wait for data
    while (Serial.available() && Serial.read()); // empty buffer again
  
}
void loop() {
 analogWrite(PWM1,100);
 analogWrite(PWM2,100); 
 digitalWrite(InA1, LOW);
 digitalWrite(InB1, HIGH);
 digitalWrite(InA2, LOW);
 digitalWrite(InB2, HIGH);}

The arduino can wait the char and active by sending a char ,but it doesn't show the string "\nSend any character to begin : ".

See the bug , it could transmit data from setup,but put the Serial.println after three whiles …

but why? I even push the reset button and still not work.