Changeset 414 in flair-src for trunk/lib/FlairCore/src


Ignore:
Timestamp:
Mar 26, 2021, 11:31:57 AM (4 years ago)
Author:
Sanahuja Guillaume
Message:

added possibility to autodetect gcs ip when using autodetect as address parameter, see demos. This only works when ssh connected to a target (not in simulation)

Location:
trunk/lib/FlairCore/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/FrameworkManager_impl.cpp

    r313 r414  
    221221    return;
    222222  }
     223  if(address=="autodetect") {
     224    Printf("autodetecting gcs ip address based on ssh connection\n");
     225    address=AutoDetectGCS();
     226  }
    223227  this->address=address;
    224228  this->port=port;
     
    246250  gcs_watchdog = new Watchdog(this, std::bind(&FrameworkManager_impl::SetConnectionLost, this),watchdogTimeout);
    247251  gcs_watchdog->Start();
     252}
     253
     254string FrameworkManager_impl::AutoDetectGCS(void) {
     255    FILE *fp;
     256    char result[15];
     257
     258    //get only first result and remove line feed
     259    fp = popen("who | awk '{ print $7; }' | head -n 1 | tr -d '\n'", "r");
     260    if (fp == NULL) {
     261        Err("Failed to run autodetect command\n" );
     262    }
     263
     264    fgets(result, sizeof(result), fp);
     265    pclose(fp);
     266   
     267    return result;
    248268}
    249269
     
    295315// it switches back to RT in ProcessXML when mutex are locked
    296316void FrameworkManager_impl::Run(void) {
     317   
     318  if (self->ErrorOccured() == true) {
     319    return ;
     320  }
     321
     322
    297323  while (!ToBeStopped()) {
    298324    ssize_t bytesRead;
  • trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h

    r254 r414  
    9090  void SaveXmlChange(char *buf);
    9191  void SaveXml(void);
     92  std::string AutoDetectGCS(void);
    9293  size_t rcv_buf_size;
    9394  char *rcv_buf;
Note: See TracChangeset for help on using the changeset viewer.