Changeset 133 in flair-src


Ignore:
Timestamp:
Feb 9, 2017, 11:08:31 AM (5 years ago)
Author:
Sanahuja Guillaume
Message:

modif sterror

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/ReleaseNotes

    r124 r133  
    77See also https://devel.hds.utc.fr/software/flair/wiki/hds_users
    88- added demos/OpticalFlow: stabilization using optical flow (vertical camera)
     9- resolved https://devel.hds.utc.fr/software/flair/ticket/8
    910- Uav class is now a singleton
    1011- VrpnClient class is now a singleton
  • trunk/lib/FlairCore/src/ConditionVariable_impl.cpp

    r15 r133  
    3333  status = pthread_cond_init(&m_ResumeCond, 0);
    3434#endif
    35   if (status != 0)
    36     self->Err("error creating condition variable (%s)\n", strerror(-status));
     35  if (status != 0) {
     36                char errorMsg[256];
     37    self->Err("error creating condition variable (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     38        }
    3739}
    3840
     
    4547  status = pthread_cond_destroy(&m_ResumeCond);
    4648#endif
    47   if (status != 0)
    48     self->Err("error destroying condition variable (%s)\n", strerror(-status));
     49  if (status != 0) {
     50                char errorMsg[256];
     51    self->Err("error destroying condition variable (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     52        }
    4953}
    5054
     
    5761  status = pthread_cond_wait(&m_ResumeCond, &self->Mutex::pimpl_->mutex);
    5862#endif
    59   if (status != 0)
    60     self->Err("error (%s)\n", strerror(-status));
     63  if (status != 0) {
     64                char errorMsg[256];
     65    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     66        }
    6167}
    6268
     
    7480  if (status == 0)
    7581    return true;
    76   if (status != ETIMEDOUT)
    77     self->Err("error (%s)\n", strerror(-status));
     82  if (status != ETIMEDOUT) {
     83                char errorMsg[256];
     84    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     85        }
    7886  return false;
    7987}
     
    8694  status = pthread_cond_signal(&m_ResumeCond);
    8795#endif
    88   if (status != 0)
    89     self->Err("error (%s)\n", strerror(-status));
     96        if (status != 0) {
     97                char errorMsg[256];
     98    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     99        }
    90100}
  • trunk/lib/FlairCore/src/FrameworkManager_impl.cpp

    r122 r133  
    132132  int status = rt_task_shadow(NULL, task_name.c_str(), 10, 0);
    133133  if (status != 0) {
    134     self->Err("rt_task_shadow error (%s)\n", strerror(-status));
     134                char errorMsg[256];
     135    self->Err("rt_task_shadow error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    135136  }
    136137
     
    147148  // Printf("destruction FrameworkManager_impl\n");
    148149  int status;
    149 
     150        char errorMsg[256];
     151       
    150152  SafeStop();
    151153  Join();
     
    160162    status = DeletePipe(&cmd_pipe);
    161163    if (status != 0) {
    162       Err("Error deleting pipe (%s)\n", strerror(-status));
     164      Err("Error deleting pipe (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    163165    }
    164166    status = DeletePipe(&data_pipe);
    165167    if (status != 0) {
    166       Err("Error deleting pipe (%s)\n", strerror(-status));
     168      Err("Error deleting pipe (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    167169    }
    168170
     
    170172    status = rt_heap_delete(&log_heap);
    171173    if (status != 0) {
    172       Err("rt_heap_delete error (%s)\n", strerror(-status));
     174      Err("rt_heap_delete error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    173175    }
    174176#endif
     
    561563
    562564void FrameworkManager_impl::SetupLogger(string log_path) {
    563   if (logger_defined == true) {
     565  char errorMsg[256];
     566       
     567        if (logger_defined == true) {
    564568    Warn("SetupLogger() was already called.\n");
    565569    return;
     
    570574  int status = CreatePipe(&cmd_pipe, "log_cmd");
    571575  if (status != 0) {
    572     Err("Error creating pipe (%s)\n", strerror(-status));
     576    Err("Error creating pipe (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    573577    return;
    574578  }
     
    576580  status = CreatePipe(&data_pipe, "log_data");
    577581  if (status != 0) {
    578     Err("Error creating pipe (%s)\n", strerror(-status));
     582    Err("Error creating pipe (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    579583    return;
    580584  }
     
    585589  status = rt_heap_create(&log_heap, tmp_name.c_str(), LOG_HEAP, H_FIFO);
    586590  if (status != 0) {
    587     Err("rt_heap_create error (%s)\n", strerror(-status));
     591    Err("rt_heap_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    588592    return;
    589593  }
     
    675679
    676680      if (written < 0) {
    677         Err("write pipe error (%s)\n", strerror(-written));
     681                                char errorMsg[256];
     682        Err("write pipe error (%s)\n", strerror_r(-written, errorMsg, sizeof(errorMsg)));
    678683        nb_err++;
    679684        logs.at(i).running = false;
     
    708713
    709714    if (written < 0) {
    710       Err("write pipe error (%s)\n", strerror(-written));
     715                        char errorMsg[256];
     716      Err("write pipe error (%s)\n", strerror_r(-written, errorMsg, sizeof(errorMsg)));
    711717      return;
    712718    } else if (written != sizeof(log_desc_t)) {
     
    727733  int status = rt_heap_alloc(&log_heap, sz, TM_NONBLOCK, &ptr);
    728734  if (status != 0) {
    729     Err("rt_heap_alloc error (%s)\n", strerror(-status));
     735                char errorMsg[256];
     736    Err("rt_heap_alloc error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    730737    ptr = NULL;
    731738  }
     
    741748
    742749  if (status != 0) {
    743     Err("rt_heap_free error (%s)\n", strerror(-status));
     750                char errorMsg[256];
     751    Err("rt_heap_free error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    744752  }
    745753#else
     
    758766
    759767  if (written < 0) {
    760     Err("erreur write pipe (%s)\n", strerror(-written));
     768                char errorMsg[256];
     769    Err("error write pipe (%s)\n", strerror_r(-written, errorMsg, sizeof(errorMsg)));
    761770  } else if (written != (ssize_t)size) {
    762     Err("erreur write pipe %ld/%ld\n", written, size);
     771    Err("error write pipe %ld/%ld\n", written, size);
    763772  }
    764773}
     
    776785
    777786#ifdef __XENO__
     787        char errorMsg[256];
    778788  filename = NRT_PIPE_PATH + caller->self->ObjectName() + "-log_cmd";
    779789  while (cmd_pipe < 0) {
    780790    cmd_pipe = open(filename.c_str(), O_RDWR);
    781791    if (cmd_pipe < 0 && errno != ENOENT)
    782       caller->self->Err("open rt_pipe error: %s %i\n", filename.c_str(), errno);
     792      caller->self->Err("open rt_pipe error: %s %s\n", filename.c_str(), strerror_r(errno, errorMsg, sizeof(errorMsg)));
    783793    usleep(1000);
    784794  }
     
    787797    data_pipe = open(filename.c_str(), O_RDWR);
    788798    if (data_pipe < 0 && errno != ENOENT)
    789       caller->self->Err("open rt_pipe error: %s %i\n", filename.c_str(), errno);
     799      caller->self->Err("open rt_pipe error: %s %s\n", filename.c_str(), strerror_r(errno, errorMsg, sizeof(errorMsg)));
    790800    usleep(1000);
    791801  }
  • trunk/lib/FlairCore/src/Mutex_impl.cpp

    r15 r133  
    2727#ifdef __XENO__
    2828  int status = rt_mutex_create(&mutex, NULL);
    29   if (status != 0)
    30     self->Err("rt_mutex_create error (%s)\n", strerror(-status));
     29  if (status != 0) {
     30                char errorMsg[256];
     31    self->Err("rt_mutex_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     32        }
    3133#else
    3234  // flag_locked=false;//revoir l'implementation nrt du is_locked
     
    4951Mutex_impl::~Mutex_impl() {
    5052  int status;
     53        char errorMsg[256];
     54       
    5155#ifdef __XENO__
    5256  status = rt_mutex_delete(&mutex);
     
    5559#endif
    5660  if (status != 0)
    57     self->Err("error destroying mutex (%s)\n", strerror(-status));
     61    self->Err("error destroying mutex (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    5862}
    5963
    6064void Mutex_impl::GetMutex(void) {
    6165  int status;
     66        char errorMsg[256];
     67       
    6268#ifdef __XENO__
    6369  status = rt_mutex_acquire(&mutex, TM_INFINITE);
     
    6773#endif
    6874  if (status != 0)
    69     self->Err("error (%s)\n", strerror(-status));
     75    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    7076}
    7177
    7278void Mutex_impl::ReleaseMutex(void) {
    7379  int status;
     80       
    7481#ifdef __XENO__
    7582  status = rt_mutex_release(&mutex);
     
    7885// flag_locked=false;
    7986#endif
    80   if (status != 0)
    81     self->Err("error (%s)\n", strerror(-status));
     87  if (status != 0) {
     88                char errorMsg[256];
     89    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     90        }
    8291}
    8392
     
    8897    RT_MUTEX_INFO info;
    8998    int status=rt_mutex_inquire(&mutex_rt,&info);
    90     if(status!=0) mutex->Err("erreur rt_mutex_inquire
    91 (%s)\n",strerror(-status));
     99    if(status!=0) mutex->Err("erreur rt_mutex_inquire (%s)\n",strerror_r(-status, errorMsg, sizeof(errorMsg)));
    92100    if(info.locked>0) return true;
    93101    return false;
  • trunk/lib/FlairCore/src/RTDM_I2cPort.cpp

    r15 r133  
    2121
    2222#include <rtdm/rti2c.h>
    23 #include <errno.h>
    2423#include <cstring>
    2524
     
    3736  fd = rt_dev_open(device.c_str(), 0);
    3837  if (fd < 0) {
    39     Err("rt_dev_open (%s)\n", ObjectName().c_str(), strerror(-fd));
     38                char errorMsg[256];
     39    Err("rt_dev_open (%s)\n", ObjectName().c_str(), strerror_r(-fd, errorMsg, sizeof(errorMsg)));
    4040  }
    4141
     
    5050  err = rt_dev_ioctl(fd, RTI2C_RTIOC_SET_CONFIG, &write_config);
    5151  if (err) {
     52                char errorMsg[256];
    5253    Err("rt_dev_ioctl RTI2C_RTIOC_SET_CONFIG error (%s)\n",
    53         ObjectName().c_str(), strerror(-err));
     54        ObjectName().c_str(), strerror_r(-err, errorMsg, sizeof(errorMsg)));
    5455  }
    5556}
     
    6061  int err = rt_dev_ioctl(fd, RTI2C_RTIOC_SET_SLAVE, &address);
    6162  if (err) {
    62     Err("rt_dev_ioctl RTI2C_RTIOC_SET_SLAVE error (%s)\n", strerror(-err));
     63                char errorMsg[256];
     64    Err("rt_dev_ioctl RTI2C_RTIOC_SET_SLAVE error (%s)\n", strerror_r(-err, errorMsg, sizeof(errorMsg)));
    6365  }
    6466
     
    7476  int err = rt_dev_ioctl(fd, RTI2C_RTIOC_SET_CONFIG, &write_config);
    7577  if (err) {
     78                char errorMsg[256];
    7679    Err("rt_dev_ioctl RTI2C_RTIOC_SET_CONFIG (%s)\n", ObjectName().c_str(),
    77         strerror(-err));
     80        strerror_r(-err, errorMsg, sizeof(errorMsg)));
    7881  }
    7982}
     
    8790  int err = rt_dev_ioctl(fd, RTI2C_RTIOC_SET_CONFIG, &write_config);
    8891  if (err) {
     92                char errorMsg[256];
    8993    Err("rt_dev_ioctl RTI2C_RTIOC_SET_CONFIG (%s)\n", ObjectName().c_str(),
    90         strerror(-err));
     94        strerror_r(-err, errorMsg, sizeof(errorMsg)));
    9195  }
    9296}
  • trunk/lib/FlairCore/src/RTDM_SerialPort.cpp

    r15 r133  
    2121
    2222#include <rtdm/rtserial.h>
    23 #include <errno.h>
    2423#include <cstring>
    2524
     
    4140      fd = rt_dev_open(device.c_str(), 0);
    4241  if (fd < 0) {
    43     Err("erreur rt_dev_open (%s)\n", strerror(-fd));
     42                char errorMsg[256];
     43    Err("error rt_dev_open (%s)\n", strerror_r(-fd, errorMsg, sizeof(errorMsg)));
    4444  }
    4545
     
    4747  int err = rt_dev_ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config);
    4848  if (err) {
    49     Err("erreur rt_dev_ioctl RTSER_RTIOC_SET_CONFIG (%s)\n", strerror(-err));
     49                char errorMsg[256];
     50    Err("error rt_dev_ioctl RTSER_RTIOC_SET_CONFIG (%s)\n", strerror_r(-err, errorMsg, sizeof(errorMsg)));
    5051  }
    5152}
     
    6364  int err = rt_dev_ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config);
    6465  if (err) {
    65     Err("erreur rt_dev_ioctl RTSER_RTIOC_SET_CONFIG (%s)\n", strerror(-err));
     66                char errorMsg[256];
     67    Err("error rt_dev_ioctl RTSER_RTIOC_SET_CONFIG (%s)\n", strerror_r(-err, errorMsg, sizeof(errorMsg)));
    6668  }
    6769}
     
    7779  int err = rt_dev_ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config);
    7880  if (err) {
    79     Err("erreur rt_dev_ioctl RTSER_RTIOC_SET_CONFIG (%s)\n", strerror(-err));
     81                char errorMsg[256];
     82    Err("error rt_dev_ioctl RTSER_RTIOC_SET_CONFIG (%s)\n", strerror_r(-err, errorMsg, sizeof(errorMsg)));
    8083  }
    8184}
  • trunk/lib/FlairCore/src/Semaphore_impl.cpp

    r126 r133  
    2828  this->self = self;
    2929  int status;
     30        char errorMsg[256];
     31       
    3032#ifdef __XENO__
    3133  status = rt_sem_create(&semaphore, NULL, initialValue, S_FIFO);
     
    3436#endif
    3537  if (status != 0) {
    36     self->Err("error creating semaphore (%s)\n", strerror(-status));
     38    self->Err("error creating semaphore (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    3739  }
    3840}
     
    4042Semaphore_impl::~Semaphore_impl() {
    4143  int status;
     44        char errorMsg[256];
     45       
    4246#ifdef __XENO__
    4347  status = rt_sem_delete(&semaphore);
     
    4650#endif
    4751  if (status != 0)
    48     self->Err("error destroying semaphore (%s)\n", strerror(-status));
     52    self->Err("error destroying semaphore (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    4953}
    5054
     
    7377                        self->Warn("warning : semaphore timedout\n");   
    7478                } else {
    75                     self->Err("error getting the semaphore (%s)\n", strerror(-status));
     79                                        char errorMsg[256];
     80                    self->Err("error getting the semaphore (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    7681                }
    7782    returnValue = false;
     
    8994#endif
    9095  if (status != 0) {
    91     self->Err("error releasing the semaphore (%s)\n", strerror(-status));
     96                char errorMsg[256];
     97    self->Err("error releasing the semaphore (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    9298    returnValue = false;
    9399  }
  • trunk/lib/FlairCore/src/SharedMem_impl.cpp

    r15 r133  
    3030  this->size = size;
    3131  this->self = self;
     32        char errorMsg[256];
    3233
    3334#ifdef __XENO__
     
    4041  }
    4142  if (status != 0) {
    42     self->Err("rt_heap_create error (%s)\n", strerror(-status));
     43    self->Err("rt_heap_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    4344    return;
    4445  }
     
    4748  status = rt_heap_alloc(&heap, 0, TM_NONBLOCK, &ptr);
    4849  if (status != 0) {
    49     self->Err("rt_heap_alloc error (%s)\n", strerror(-status));
     50    self->Err("rt_heap_alloc error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    5051  }
    5152  mem_segment = (char *)ptr;
     
    5960  }
    6061  if (status != 0) {
    61     self->Err("rt_mutex_create error (%s)\n", strerror(-status));
     62    self->Err("rt_mutex_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    6263    return;
    6364  }
     
    8788SharedMem_impl::~SharedMem_impl() {
    8889  int status;
     90        char errorMsg[256];
     91       
    8992#ifdef __XENO__
    9093  /* unnecessary because heap is opened in H_SINGLE mode
     
    9295  if(status!=0)
    9396  {
    94       self->Err("rt_heap_free error (%s)\n",strerror(-status));
     97      self->Err("rt_heap_free error (%s)\n",strerror_r(-status, errorMsg, sizeof(errorMsg)));
    9598  }
    9699  */
     
    99102    status = rt_heap_delete(&heap);
    100103    if (status != 0) {
    101       self->Err("rt_heap_delete error (%s)\n", strerror(-status));
     104      self->Err("rt_heap_delete error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    102105    }
    103106  }
     
    106109    status = rt_mutex_delete(&mutex);
    107110    if (status != 0) {
    108       self->Err("error destroying mutex (%s)\n", strerror(-status));
     111      self->Err("error destroying mutex (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    109112    }
    110113  }
     
    112115  status = munmap(mem_segment, size);
    113116  if (status != 0) {
    114     self->Err("Failed to unmap memory (%s)\n", strerror(-status));
     117    self->Err("Failed to unmap memory (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    115118  }
    116119
    117120  status = close(fd);
    118121  if (status != 0) {
    119     self->Err("Failed to close file (%s)\n", strerror(-status));
     122    self->Err("Failed to close file (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    120123  }
    121124
     
    124127   if(status!=0)
    125128   {
    126        self->Err("Failed to unlink memory (%s)\n",strerror(-status));
     129       self->Err("Failed to unlink memory (%s)\n",strerror_r(-status, errorMsg, sizeof(errorMsg)));
    127130   }
    128131*/
     
    131134   if(status!=0)
    132135   {
    133        self->Err("Failed to unlink semaphore (%s)\n",strerror(-status));
     136       self->Err("Failed to unlink semaphore (%s)\n",strerror_r(-status, errorMsg, sizeof(errorMsg)));
    134137   }*/
    135138
    136139  status = sem_close(sem);
    137140  if (status != 0) {
    138     self->Err("Failed to close semaphore (%s)\n", strerror(-status));
     141    self->Err("Failed to close semaphore (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    139142  }
    140143#endif
     
    144147#ifdef __XENO__
    145148  int status = rt_mutex_acquire(&mutex, TM_INFINITE);
    146   if (status != 0)
    147     self->Err("error (%s)\n", strerror(-status));
     149  if (status != 0) {
     150                char errorMsg[256];
     151    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     152        }
    148153  memcpy(mem_segment, buf, size);
    149154  status = rt_mutex_release(&mutex);
    150   if (status != 0)
    151     self->Err("error (%s)\n", strerror(-status));
     155  if (status != 0) {
     156                char errorMsg[256];
     157    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     158        }
    152159#else
    153160  sem_wait(sem);
     
    160167#ifdef __XENO__
    161168  int status = rt_mutex_acquire(&mutex, TM_INFINITE);
    162   if (status != 0)
    163     self->Err("error (%s)\n", strerror(-status));
     169  if (status != 0) {
     170                char errorMsg[256];
     171    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     172        }
    164173  memcpy(buf, mem_segment, size);
    165174  status = rt_mutex_release(&mutex);
    166   if (status != 0)
    167     self->Err("error (%s)\n", strerror(-status));
     175  if (status != 0) {
     176                char errorMsg[256];
     177    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     178        }
    168179#else
    169180  sem_wait(sem);
  • trunk/lib/FlairCore/src/Socket_impl.cpp

    r93 r133  
    103103#endif
    104104  if (status != 0) {
    105     self->Err("rt_pipe_create error (%s)\n", strerror(-status));
     105                char errorMsg[256];
     106    self->Err("rt_pipe_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    106107  }
    107108
     
    148149  pthread_join(user_thread, NULL);
    149150  int status = rt_pipe_delete(&pipe);
    150   if (status != 0)
    151     self->Err("rt_pipe_delete error (%s)\n", strerror(-status));
    152 
     151  if (status != 0) {
     152                char errorMsg[256];
     153    self->Err("rt_pipe_delete error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     154        }
    153155#endif
    154156  close(fd);
     
    158160  ssize_t written;
    159161  string to_send;
     162        char errorMsg[256];
    160163
    161164  if (broadcast == true) {
     
    170173
    171174  if (written < 0) {
    172     self->Err("rt_pipe_write error (%s)\n", strerror(-written));
     175    self->Err("rt_pipe_write error (%s)\n", strerror_r(-written, errorMsg, sizeof(errorMsg)));
    173176  } else if (written != (ssize_t)src_len) {
    174177    self->Err("rt_pipe_write error %i/%i\n", written, to_send.size());
     
    178181      sendto(fd, src, src_len, 0, (struct sockaddr *)&sock_in, sizeof(sock_in));
    179182  if(written==-1) {
    180     self->Err("sendto error (%s)\n",strerror(-errno));
     183                char errorMsg[256];
     184    self->Err("sendto error (%s)\n",strerror_r(errno, errorMsg, sizeof(errorMsg)));
    181185  } else if (written != (ssize_t)src_len) {
    182186    self->Err("sendto error %i/%i\n",written,src_len);
     
    195199
    196200  if (written < 0) {
    197     self->Err("rt_pipe_write error (%s)\n", strerror(-written));
     201                char errorMsg[256];
     202    self->Err("rt_pipe_write error (%s)\n", strerror_r(-written, errorMsg, sizeof(errorMsg)));
    198203  } else if (written != (ssize_t)message.size()) {
    199204    self->Err("rt_pipe_write error %i/%i\n", written, message.size());
     
    295300  while (pipe_fd < 0) {
    296301    pipe_fd = open(devname.c_str(), O_RDWR);
    297     if (pipe_fd < 0 && errno != ENOENT)
    298       caller->self->Err("open pipe_fd error (%s)\n", strerror(-errno));
     302    if (pipe_fd < 0 && errno != ENOENT) {
     303                        char errorMsg[256];
     304                        caller->self->Err("open pipe_fd error (%s)\n", strerror_r(errno, errorMsg, sizeof(errorMsg)));
     305                }
    299306    usleep(1000);
    300307  }
  • trunk/lib/FlairCore/src/Thread.cpp

    r15 r133  
    8787#ifdef __XENO__
    8888  int status = rt_task_sleep_until(time);
    89   if (status != 0)
     89  if (status != 0) {
     90                char errorMsg[256];
    9091    Err("%s, error rt_task_sleep_until (%s), resume time: %lld, actual time: "
    91         "%lld\n",
    92         ObjectName().c_str(), strerror(-status), time, GetTime());
     92        "%lld\n", ObjectName().c_str(), strerror_r(-status, errorMsg, sizeof(errorMsg)), time, GetTime());
     93        }
    9394// Printf("rt_task_sleep_until, resume time: %lld, actual time:
    9495// %lld\n",time,GetTime());
     
    104105#ifdef __XENO__
    105106  int status = rt_task_sleep(time * 1000 * 1000);
    106   if (status != 0)
    107     Err("erreur rt_task_sleep (%s)\n", strerror(-status));
     107  if (status != 0) {
     108                char errorMsg[256];
     109    Err("erreur rt_task_sleep (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     110        }
    108111#else
    109112  usleep(time * 1000);
     
    114117#ifdef __XENO__
    115118  int status = rt_task_sleep(time * 1000);
    116   if (status != 0)
    117     Err("erreur rt_task_sleep (%s)\n", strerror(-status));
     119  if (status != 0) {
     120                char errorMsg[256];
     121    Err("erreur rt_task_sleep (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     122        }
    118123#else
    119124  usleep(time);
  • trunk/lib/FlairCore/src/Thread_impl.cpp

    r118 r133  
    7878void Thread_impl::Start(void) {
    7979  int status;
     80        char errorMsg[256];
    8081
    8182  isRunning = true;
     
    9495#endif // RT_STACK_SIZE
    9596  if (status != 0) {
    96     self->Err("rt_task_create error (%s)\n", strerror(-status));
     97    self->Err("rt_task_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    9798  } else {
    9899    //_printf("rt_task_create ok %s\n",th_name);
     
    101102  status = rt_task_start(&task_rt, &main_rt, (void *)this);
    102103  if (status != 0) {
    103     self->Err("rt_task_start error (%s)\n", strerror(-status));
     104    self->Err("rt_task_start error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    104105  } else {
    105106    //_printf("rt_task_start ok %s\n",th_name);
     
    178179#ifdef __XENO__
    179180  int status = rt_task_set_periodic(&task_rt, TM_NOW, period * 1000);
    180   if (status != 0)
    181     self->Err("Error rt_task_set_periodic %s\n", strerror(-status));
     181  if (status != 0) {
     182                char errorMsg[256];
     183    self->Err("Error rt_task_set_periodic %s\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     184        }
    182185#else
    183186  next_time -= period;
     
    198201#ifdef __XENO__
    199202  int status = rt_task_set_periodic(&task_rt, TM_NOW, period * 1000 * 1000);
    200   if (status != 0)
    201     self->Err("Error rt_task_set_periodic %s\n", strerror(-status));
     203  if (status != 0) {
     204                char errorMsg[256];
     205    self->Err("Error rt_task_set_periodic %s\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     206        }
    202207#else
    203208  next_time -= period;
     
    218223  unsigned long overruns_r;
    219224  int status = rt_task_wait_period(&overruns_r);
    220   if (status != 0)
    221     self->Err("Error rt_task_wait_period %s\n", strerror(-status));
    222   if (status == -ETIMEDOUT)
     225  if (status != 0) {
     226                char errorMsg[256];
     227    self->Err("Error rt_task_wait_period %s\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     228        }
     229  if (status == -ETIMEDOUT) {
    223230    self->Err("overrun: %lld\n", overruns_r);
     231        }
    224232#else
    225233  self->SleepUntil(next_time);
     
    310318  int status = rt_task_inquire(NULL, &info);
    311319  if (status != 0) {
    312     self->Err("Error rt_task_inquire %s\n", strerror(-status));
     320                char errorMsg[256];
     321    self->Err("Error rt_task_inquire %s\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    313322  } else
    314323#endif
     
    348357  if (isRunning == true) {
    349358    int status;
     359                char errorMsg[256];
    350360
    351361#ifdef __XENO__
     
    355365#endif
    356366    if (status != 0)
    357       self->Err("error %s\n", strerror(-status));
     367      self->Err("error %s\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    358368    isRunning = false;
    359369  }
  • trunk/lib/FlairCore/src/Unix_I2cPort.cpp

    r15 r133  
    1717
    1818#include "Unix_I2cPort.h"
    19 #include <errno.h>
    2019#include <fcntl.h> /* File control definitions */
    2120#include <unistd.h>
  • trunk/lib/FlairCore/src/Widget_impl.cpp

    r15 r133  
    2424#ifdef __XENO__
    2525#include <native/heap.h>
    26 #else
    27 #include <errno.h>
    28 #include <cstring>
    2926#endif
    3027
     
    4542
    4643  if (status != 0) {
    47     printf("libxml2: rt_heap_free error (%s)\n", strerror(-status));
     44                char errorMsg[256];
     45    printf("libxml2: rt_heap_free error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    4846  }
    4947}
     
    5452  int status = rt_heap_alloc(&xml_heap, sz, TM_NONBLOCK, &ptr);
    5553  if (status != 0) {
    56     printf("libxml2: rt_heap_alloc error (%s)\n", strerror(-status));
     54                char errorMsg[256];
     55    printf("libxml2: rt_heap_alloc error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    5756  }
    5857  // Printf("alloc %x %i\n",ptr,sz);
     
    106105    int status = rt_heap_create(&xml_heap, tmp_name.c_str(), XML_HEAP, H_FIFO);
    107106    if (status != 0) {
    108       self->Err("rt_heap_create error (%s)\n", strerror(-status));
     107                        char errorMsg[256];
     108      self->Err("rt_heap_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    109109    }
    110110
     
    188188#ifdef __XENO__
    189189    int status;
     190                char errorMsg[256];
    190191    RT_HEAP_INFO info;
    191192    status = rt_heap_inquire(&xml_heap, &info);
    192193    if (status != 0) {
    193       self->Err("rt_heap_inquire error (%s)\n", strerror(-status));
     194      self->Err("rt_heap_inquire error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    194195    }
    195196    if (info.usedmem != 0)
     
    198199    status = rt_heap_delete(&xml_heap);
    199200    if (status != 0) {
    200       self->Err("rt_heap_delete error (%s)\n", strerror(-status));
     201      self->Err("rt_heap_delete error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    201202    }
    202203#endif
  • trunk/lib/FlairCore/src/ui_com.cpp

    r15 r133  
    7070
    7171  if (status != 0) {
    72     Err("rt_pipe_create error (%s)\n", strerror(-status));
     72                char errorMsg[256];
     73    Err("rt_pipe_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    7374    // return -1;
    7475  }
     
    125126
    126127  int status = rt_pipe_delete(&pipe);
    127   if (status != 0)
    128     Err("rt_pipe_delete error (%s)\n", strerror(-status));
     128  if (status != 0) {
     129                char errorMsg[256];
     130    Err("rt_pipe_delete error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     131        }
    129132#endif
    130133
     
    160163
    161164  if (nb_write < 0) {
    162     Err("rt_pipe_write error (%s)\n", strerror(-nb_write));
     165                char errorMsg[256];
     166    Err("rt_pipe_write error (%s)\n", strerror_r(-nb_write, errorMsg, sizeof(errorMsg)));
    163167  } else if (nb_write != size) {
    164168    Err("rt_pipe_write error %i/%i\n", nb_write, size);
     
    326330  while (pipe_fd < 0) {
    327331    pipe_fd = open(devname.c_str(), O_RDWR);
    328     if (pipe_fd < 0 && errno != ENOENT)
    329       caller->Err("open pipe_fd error (%s)\n", strerror(-errno));
     332    if (pipe_fd < 0 && errno != ENOENT) {
     333                        char errorMsg[256];
     334      caller->Err("open pipe_fd error (%s)\n", strerror_r(errno, errorMsg, sizeof(errorMsg)));
     335                }
    330336    usleep(1000);
    331337  }
Note: See TracChangeset for help on using the changeset viewer.