Level2_Robot/room_seeker_core/src/room_seeker_level1.cpp
//================================================================================================//
// Send start command to rsl1 via serial port                                                  //
//   Argument con : serial console object to send start command                                   //
//   Return       : None                                                                          //
//================================================================================================//
Send start command to rsl1 via serial port
Argument con : serial console object to send start command
Return       : None
Send start command to rsl1 via serial port Argument con : serial console object to send start command Return : None
void RoomSeekerLevel1::send_start(int fd){
  char buf[256];
  int len;
  len = read(fd, buf, sizeof(buf));       
  usleep(200000);                         
  write(fd, "s", 1);                      
  write_log(fp_log, "Start command transmitted (1st try).\n");
  usleep(500000);                         
  len = read(fd, buf, sizeof(buf));       
  if(len <= 10){                          
    write(fd, "s", 1);                    
    write_log(fp_log, "Start command transmitted (2nd try).\n");
    usleep(500000);                      
    len = read(fd, buf, sizeof(buf));     
    if(len <= 10){                        
      write(fd, "s", 1);                  
      write_log(fp_log, "Start command transmitted (3rd try).\n");
      usleep(500000);                    
      len = read(fd, buf, sizeof(buf));   
      if(len <= 10){                      
        printf("xxxx : %d did not transmit call back.\n", fd);
        write(fd, "t", 1);                
      }
    }
  }
  len = read(fd, buf, sizeof(buf));       
  write_log(fp_log, "Start command echo back received.\n");
}
void RoomSeekerLevel1 :: send_start ( int fd ) { char buf [ 256 ] ; int len ; len = read ( fd , buf , sizeof ( buf ) ) ; usleep ( 200000 ) ; write ( fd , " " , 1 ) ; write_log ( fp_log , " \n " ) ; usleep ( 500000 ) ; len = read ( fd , buf , sizeof ( buf ) ) ; if ( len <= 10 ) { write ( fd , " " , 1 ) ; write_log ( fp_log , " \n " ) ; usleep ( 500000 ) ; len = read ( fd , buf , sizeof ( buf ) ) ; if ( len <= 10 ) { write ( fd , " " , 1 ) ; write_log ( fp_log , " \n " ) ; usleep ( 500000 ) ; len = read ( fd , buf , sizeof ( buf ) ) ; if ( len <= 10 ) { printf ( " \n " , fd ) ; write ( fd , " " , 1 ) ; } } } len = read ( fd , buf , sizeof ( buf ) ) ; write_log ( fp_log , " \n " ) ; }
Send start command to rsl1 via serial port
Argument con : serial console object to send start command
Return       : None
Send start command to rsl1 via serial port Argument con : serial console object to send start command Return : None
// Read buffer to empty it // Wait a while to stabilize(?) // 1st : Send start command 's' to serial port // 1st : Wait 0.5sec to receive callback // 1st : Check if the callback is sent or not // 2nd : Re-send start command if don't get callback // 2nd : Send start command 's' to serial port // 2nd : Wait 0.5sec to receive callback // 2nd : Check if the callback is sent or not // 2nd : Re-send start command if don't get callback // 3rd : Send start command 's' to serial port // 3rd : Wait 0.5sec to receive callback (3rd) // 3rd : Send start command 's' to serial port // 3rd : Re-send start command if don't get callback // 3rd : Send stop command for make sure // Empty the receive buffer