当前位置: 首页>>代码示例>>C++>>正文


C++ SdFile::getWriteError方法代码示例

本文整理汇总了C++中SdFile::getWriteError方法的典型用法代码示例。如果您正苦于以下问题:C++ SdFile::getWriteError方法的具体用法?C++ SdFile::getWriteError怎么用?C++ SdFile::getWriteError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SdFile的用法示例。


在下文中一共展示了SdFile::getWriteError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: log

bool log(char* message) {
  // TODO: Test if file is open first
  
  // log time to file
  #ifdef SDCARD
  file.println(message);
  #endif

  sync(false);

  #ifdef SDCARD
  return (file.getWriteError() == false);
  #else
    return true;
  #endif
}
开发者ID:davidbuzz,项目名称:t400-firmware,代码行数:16,代码来源:sd_log.cpp

示例2: app_process_file_write

idigi_callback_status_t iDigiFileSystem::app_process_file_write(idigi_file_write_request_t * const request_data,
                                                      idigi_file_write_response_t * const response_data)
{
    idigi_callback_status_t status = idigi_callback_continue;
    SdFile *file = (SdFile *) request_data->handle;

  	file->clearWriteError();
    size_t wrote = file->write(request_data->data_ptr, request_data->size_in_bytes);

    if (file->getWriteError())
    {
        response_data->error->error_status = idigi_file_unspec_error;
        APP_DEBUG("write attempt %d, returned err (wrote: %d)\n", request_data->size_in_bytes, wrote);
        goto done;
    }

    APP_DEBUG("write attempt %d, wrote: %d\n", request_data->size_in_bytes, wrote);
    response_data->size_in_bytes = wrote;

done:
    return status;
}
开发者ID:jordanh,项目名称:idigi-arduino-connector,代码行数:22,代码来源:iDigiFileSystem.cpp

示例3: open

bool open(char* fileName) {
  // Create LDxxxx.CSV for the lowest value of x.

  #ifdef SDCARD
  uint16_t i = 0;
  do {
    fileName[2] = (i/1000) % 10 + '0';
    fileName[3] = (i/100)  % 10 + '0';
    fileName[4] = (i/10)   % 10 + '0';
    fileName[5] = i        % 10 + '0';
    i++;
  }
  while(sd.exists(fileName));


  if(!file.open(fileName, O_CREAT | O_WRITE | O_EXCL)) {
//    error_P("file open");
    return false;
  }
  file.clearWriteError();
  
  // write data header
  file.print("time (s)");

  #endif
  
  Serial.print("v");
  Serial.println(FIRMWARE_VERSION);

  Serial.print("File: ");
  Serial.println(fileName);

  // write data header
  Serial.print("time (s)");
  
  /* We are no longer using the junction temperature in our data output.
  // write data header
  file.print("time (s), ambient");
  Serial.print("time (s), ambient");
  
  switch(temperatureUnit) {
  case TEMPERATURE_UNITS_C:
    file.print(" (C)");
    Serial.print(" (C)");
    break;
  case TEMPERATURE_UNITS_F:
    file.print(" (F)");
    Serial.print(" (F)");
    break;
  case TEMPERATURE_UNITS_K:
    file.print(" (K)");
    Serial.print(" (K)");
    break;
    
  }*/

  for (uint8_t i = 0; i < SENSOR_COUNT; i++) {
    #ifdef SDCARD
    file.print(", temp_");
    file.print(i, DEC);
    #endif
    
    Serial.print(", temp_");
    Serial.print(i, DEC);
    
    switch(temperatureUnit) {
    case TEMPERATURE_UNITS_C:
      #ifdef SDCARD
      file.print(" (C)");
      #endif
      Serial.print(" (C)");
      break;
    case TEMPERATURE_UNITS_F:
      #ifdef SDCARD
      file.print(" (F)");
      #endif
      Serial.print(" (F)");
      break;
    case TEMPERATURE_UNITS_K:
      #ifdef SDCARD
      file.print(" (K)");
      #endif
      Serial.print(" (K)");
      break;
    }
  }
  #ifdef SDCARD
  file.println();
  file.flush();
  #endif
  Serial.println();

  #ifdef SDCARD
  return (file.getWriteError() == false);
  #else
    return true;
  #endif
}
开发者ID:davidbuzz,项目名称:t400-firmware,代码行数:98,代码来源:sd_log.cpp


注:本文中的SdFile::getWriteError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。