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


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

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


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

示例1: syncEEPROM

void HAL::syncEEPROM() { // store to disk if changed
  millis_t time = millis();

  if (eprSyncTime && (time - eprSyncTime > 15000)) // Buffer writes only every 15 seconds to pool writes
  {
    eprSyncTime = 0;
    bool failed = false;
    if (!sd.sdactive) // not mounted
	  {
		  if (eepromFile.isOpen())
			  eepromFile.close();
        Com::printErrorF("Could not write eeprom to sd card - no sd card mounted");
        Com::println();
		  return;
	  }

	  if (!eepromFile.seekSet(0))
		  failed = true;

	  if(!failed && !eepromFile.write(virtualEeprom, EEPROM_BYTES) == EEPROM_BYTES)
      failed = true; 
    
    if(failed) {
        Com::printErrorF("Could not write eeprom to sd card");
        Com::println();
    }
  }
}
开发者ID:luc-github,项目名称:Repetier-Firmware-0.92,代码行数:28,代码来源:HAL.cpp

示例2: app_process_file_stat

idigi_callback_status_t iDigiFileSystem::app_process_file_stat(idigi_file_stat_request_t * const request_data,
                                                     idigi_file_stat_response_t * const response_data)
{
    idigi_file_stat_t *pstat = &response_data->statbuf;
    idigi_callback_status_t status = idigi_callback_continue;

    SdFile entry = DigiSD.open(request_data->path);

    if (!entry.isOpen())
    {
     	APP_DEBUG("stat cannot open: %s\n", request_data->path);
        goto done;   	
    }

    pstat->last_modified = 0;					// Last modified date unsupported:
    pstat->hash_alg = idigi_file_hash_none;	// File hash not supported
    pstat->file_size = (size_t) entry.fileSize();
    pstat->flags = 0;
    if (entry.isDir())
    	pstat->flags |= IDIGI_FILE_IS_DIR;
    else
    	pstat->flags |= IDIGI_FILE_IS_REG;

    entry.close();

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

示例3: app_process_file_opendir

idigi_callback_status_t iDigiFileSystem::app_process_file_opendir(idigi_file_path_request_t * const request_data,
                                                        idigi_file_open_response_t * const response_data)
{
    idigi_callback_status_t status = idigi_callback_continue;
    SdFile *dir = new SdFile;

    if (dir == NULL)
    {
    	response_data->error->error_status = idigi_file_out_of_memory;
    }

    *dir = DigiSD.open(request_data->path);

    if (!dir->isOpen() || !dir->isDir())
    {
    	response_data->error->error_status = idigi_file_path_not_found;
    	return status;
    }

    dir->rewind();

    response_data->handle = dir;
    APP_DEBUG("opendir for %s returned %p\n", request_data->path, (void *) dir);

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

示例4: app_process_file_open

idigi_callback_status_t iDigiFileSystem::app_process_file_open(idigi_file_open_request_t * const request_data,
                                                     idigi_file_open_response_t * const response_data)
{
	idigi_callback_status_t status = idigi_callback_continue;

	SdFile *file = new SdFile;
	uint8_t filemode = 0;

    if (request_data->oflag & IDIGI_O_RDONLY) filemode |= O_RDONLY;
    if (request_data->oflag & IDIGI_O_WRONLY) filemode |= O_WRONLY;
    if (request_data->oflag & IDIGI_O_RDWR) filemode |= O_RDWR;
    if (request_data->oflag & IDIGI_O_APPEND) filemode |= O_APPEND;
    if (request_data->oflag & IDIGI_O_CREAT) filemode |= O_CREAT;
    if (request_data->oflag & IDIGI_O_TRUNC) filemode |= O_TRUNC;

    if ((request_data->oflag & (IDIGI_O_RDONLY | IDIGI_O_WRONLY)) == 0)
    	filemode |= O_RDONLY; 

    *file = DigiSD.open(request_data->path, filemode);

    if (!file->isOpen())
    {
        response_data->error->error_status = idigi_file_path_not_found;
    	return status;
    }

    APP_DEBUG("Open %s, req flag %d, flag %d, returned %p\n", request_data->path, request_data->oflag, filemode, (void *) file);

    response_data->handle = (void *) file;
    response_data->user_context = NULL;

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

示例5: setup

void setup(void) {
  Serial.begin(BPS_115200);
  Serial.println();
  
#if WAIT_TO_START
  Serial.println("Type any character to start");
  while (!Serial.available());
#endif //WAIT_TO_START

  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  // breadboards.  use SPI_FULL_SPEED for better performance.
  if (!card.init(SPI_HALF_SPEED)) error("card.init failed");
  
  // initialize a FAT volume
  if (!volume.init(&card)) error("volume.init failed");
  
  // open root directory
  if (!root.openRoot(&volume)) error("openRoot failed");
  
  // create a new file
  char name[] = "LOGGER00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    name[6] = i/10 + '0';
    name[7] = i%10 + '0';
    if (file.open(&root, name, O_CREAT | O_EXCL | O_WRITE)) break;
  }
  if (!file.isOpen()) error ("file.create");
  Serial.print("Logging to: ");
  Serial.println(name);

  // write header
  file.writeError = 0;
  file.print("millis");
#if ECHO_TO_SERIAL 
  Serial.print("millis");
#endif //ECHO_TO_SERIAL

#if SENSOR_COUNT > 6
#error SENSOR_COUNT too large
#endif //SENSOR_COUNT

  for (uint8_t i = 0; i < SENSOR_COUNT; i++) {
    file.print(",sens");file.print(i, DEC);    
#if ECHO_TO_SERIAL
    Serial.print(",sens");Serial.print(i, DEC);
#endif //ECHO_TO_SERIAL
  }
  file.println();  
#if ECHO_TO_SERIAL
  Serial.println();
#endif  //ECHO_TO_SERIAL

  if (file.writeError || !file.sync()) {
    error("write header failed");
  }
}
开发者ID:cohabo,项目名称:my_src,代码行数:56,代码来源:main.cpp

示例6: put_handler

  boolean put_handler(AtMegaWebServer& web_server) {
	const char* length_str = web_server.get_header_value("Content-Length");
	long length = atol(length_str);
	const char *path = web_server.get_path();

	SdFile file;
	if(!file.open(path, O_CREAT | O_WRITE | O_TRUNC)){
		 // maybe the folder must be created
		char *c = strrchr(path, '/');
		if(c){
			*c = 0;
			if(sdfat.mkdir(path)){
#if DEBUG
				Serial << "put_handler make DIR: ok " << path <<'\n';
#endif
				*c = '/';
				if(!file.open(path, O_CREAT | O_WRITE | O_TRUNC)){
#if DEBUG
					Serial << "put_handler open FILE: failed " << path <<'\n';
#endif
				}
			}
			*c = '/';
		}
	}
	if(file.isOpen()){

		EthernetClient client = web_server.get_client();
		long size = 0;
		int read = 0;
		while(size < length && web_server.waitClientAvailable()){
			read = client.read((uint8_t*)buffer, sizeof(buffer));
			file.write(buffer, read);
			size += read;
		}
		file.close();
#if DEBUG
		Serial << "file written: " << size << " of: " << length << '\n';
#endif
		if(size < length){
			web_server.sendHttpResult(404);
		}else{
			web_server.sendHttpResult(200);
			web_server << path;
		}

	}else{
		web_server.sendHttpResult(422); // assuming it's a bad filename (non 8.3 name)
#if DEBUG
		Serial << F("put_handler open file failed: send 422 ") << path <<'\n';
#endif
	}
	return true;
  }
开发者ID:gonboy,项目名称:AtMegaWebServer,代码行数:54,代码来源:AtMegaWebServer.cpp

示例7: open

File SDClass::open(const char *filepath, uint8_t mode) {
  /*

     Open the supplied file path for reading or writing.

     The file content can be accessed via the `file` property of
     the `SDClass` object--this property is currently
     a standard `SdFile` object from `sdfatlib`.

     Defaults to read only.

     If `write` is true, default action (when `append` is true) is to
     append data to the end of the file.

     If `append` is false then the file will be truncated first.

     If the file does not exist and it is opened for writing the file
     will be created.

     An attempt to open a file for reading that does not exist is an
     error.

   */

  int pathidx;

  // do the interative search
  SdFile parentdir = getParentDir(filepath, &pathidx);
  // no more subdirs!

  filepath += pathidx;

  if (! filepath[0]) {
    // it was the directory itself!
    return File(parentdir, "/");
  }

  // Open the file itself
  SdFile file;

  // failed to open a subdir!
  if (!parentdir.isOpen())
    return File();

  if ( ! file.open(parentdir, filepath, mode)) {
    return File();
  }
  // close the parent
  parentdir.close();

  if (mode & (O_APPEND | O_WRITE)) 
    file.seekSet(file.fileSize());
  return File(file, filepath);
}
开发者ID:Defragster,项目名称:SD,代码行数:54,代码来源:SD.cpp

示例8: importEEPROM

void HAL::importEEPROM() {
    if (eepromFile.isOpen())
			eepromFile.close();
		if (!eepromFile.open("eeprom.bin", O_RDWR | O_CREAT | O_SYNC) ||
			eepromFile.read(virtualEeprom, EEPROM_BYTES) != EEPROM_BYTES)
		{
			Com::printFLN(Com::tOpenFailedFile, "eeprom.bin");
		} else {
      Com::printFLN("EEPROM read from sd card.");
    }
    EEPROM::readDataFromEEPROM(true);
}
开发者ID:luc-github,项目名称:Repetier-Firmware-0.92,代码行数:12,代码来源:HAL.cpp

示例9: openLog

void openLog() {
    int tries = 0;
    while (tries++ < 3 && !dataFile.open(root, logFilename, O_CREAT | O_WRITE)) {
        Serial.println(F("Unable to create log file, rotating..."));
        rotateLog();
    }
    if (!dataFile.isOpen()) {
        Serial.println(F("Unable to create log file, disabling data logger."));
        disableLogging = true;
        return;
    }
}
开发者ID:veonik,项目名称:transpond,代码行数:12,代码来源:handset.cpp

示例10: app_process_file_closedir

idigi_callback_status_t iDigiFileSystem::app_process_file_closedir(idigi_file_request_t * const request_data,
                                                         idigi_file_response_t * const response_data)
{
    SdFile *dir = (SdFile *) request_data->handle;

    APP_DEBUG("closedir %p\n", (void *) dir);

    if (dir->isOpen())
    	dir->close();
    free(dir);

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

示例11: initSDCard

bool FileSystem::initSDCard() {
    boolean status;

    if (root.isOpen())
        root.close();      // allows repeated calls

    // First, detect the card
    status = card.init(pinCS); // Audio shield has SD card SD on pin 10
    if (status) {
        Serial.println("SD card is connected :-)");
    } else {
        Serial.println("SD card is not connected or unusable :-(");
        sdCardInitialized = false;
        return sdCardInitialized;
    }

    // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
    if (!volume.init(card)) {
        Serial.println(
                "Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
        sdCardInitialized = false;
        return sdCardInitialized;
    }

    root.openRoot(volume);

    // print the type and size of the first FAT-type volume
    Serial.print("\nVolume type is FAT");
    Serial.println(volume.fatType(), DEC);
    Serial.println();

    float size = volume.blocksPerCluster() * volume.clusterCount();
    size = size * (512.0 / 1e6); // convert blocks to millions of bytes
    Serial.print("File system space is ");
    Serial.print(size);
    Serial.println(" Mbytes.");

    status = SD.begin(pinCS); // Audio shield has SD card CS on pin 10
    if (status) {
        Serial.println("SD library is able to access the filesystem");
    } else {
        Serial.println("SD library can not access the filesystem!");
        Serial.println(
                "Please report this problem, with the make & model of your SD card.");
        Serial.println(
                "  http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports");
    }
    sdCardInitialized = true;
    return sdCardInitialized;
}
开发者ID:kigster,项目名称:flix-capacitor,代码行数:50,代码来源:FileSystem.cpp

示例12:

boolean MP3Player::Play(const char* SongName)
{  
  if(!PLAY)
  {
	k=65;
	if(!myFile.isOpen())
	{
		// open the file for read
		if (!myFile.open(SongName, O_READ)) 
		{
			#if DEBUG
			sd.errorHalt("open audio file failed");
			#endif 
			return false;
		}
	}
	else
		name = SongName;

	Run_STA013();
	delayMicroseconds(500000);
	Play_Pause(1);
  
	//AMPON();  

	#if DEBUG
	Serial.println("playing");
	#endif 
   
	filesize=myFile.fileSize();
	Timer1.initialize(30);// 30 us = can check data request and send a byte to STA013 at 1/30u = 33.33kHz
							// able to play a song up to 33.33 x 8 /1024 = 260 kbps
							// recommend play song at 200kbps or lower (such as 128 kbps)for stable performance
	PLAY=true; 
	Timer1.attachInterrupt(Callback);
  }

  return true;   
}
开发者ID:CytronTechnologies,项目名称:Cytron_MP3Shield,代码行数:39,代码来源:MP3Player.cpp

示例13: app_process_file_readdir

idigi_callback_status_t iDigiFileSystem::app_process_file_readdir(idigi_file_request_t * const request_data,
                                                        idigi_file_data_response_t * const response_data)
{
    idigi_callback_status_t status = idigi_callback_continue;
    SdFile *dir = (SdFile *) request_data->handle;

    char fileName[DIGISD_MAX_FILENAME_LEN];
    SdFile entry = DigiSD.openNextFile(dir, fileName);

    if (!entry.isOpen())
    {
    	APP_DEBUG("No more directory entries\n");
        response_data->size_in_bytes = 0;
        goto done;
    }

    // read valid entry
    {
        size_t const name_len = strlen(fileName);

        APP_DEBUG("fileName is %s\n", fileName);

        if(name_len < response_data->size_in_bytes)
        {
            memcpy(response_data->data_ptr, fileName, name_len + 1);
            response_data->size_in_bytes = name_len + 1;
        }
        else
        {
            APP_DEBUG("directory entry name too long\n");
            response_data->error->error_status = idigi_file_out_of_memory;
        }
    }

    entry.close();

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

示例14: writeLog

void writeLog() {
    if (disableLogging) {
        return;
    }

    if (!dataFile.isOpen()) {
        if (!dataFile.open(root, logFilename, O_WRITE | O_APPEND)) {
#ifdef DEBUG
            Serial.println(F("Could not open file for writing"));
#endif
            disableLogging = true;
            return;
        }
    }

    // Local sensor readings
    logFileSize += dataFile.print(lastUpdate);
    logFileSize += dataFile.print(F("\t"));
    logFileSize += dataFile.print(sinceLastAck);
    logFileSize += dataFile.print(F("\t"));
    logFileSize += dataFile.print(lastVcc);
    logFileSize += dataFile.print(F("\t"));
    if (validReadingi(lastRoundtrip)) {
        logFileSize += dataFile.print(lastRoundtrip);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingi(lastRssi)) {
        logFileSize += dataFile.print(lastRssi);
    }
    logFileSize += dataFile.print(F("\t"));

    // Remote sensor readings
    if (validReadingi(m.vcc)) {
        logFileSize += dataFile.print(m.vcc);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingi(m.rssi)) {
        logFileSize += dataFile.print(m.rssi);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingi(m.vibration)) {
        logFileSize += dataFile.print(m.vibration);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.altitudeGps)) {
        logFileSize += dataFile.print(m.altitudeGps);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.altitude)) {
        logFileSize += dataFile.print(m.altitude);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.temp)) {
        logFileSize += dataFile.print(m.temp);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.temp2)) {
        logFileSize += dataFile.print(m.temp2);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.latitude)) {
        logFileSize += dataFile.print(m.latitude, 6);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.longitude)) {
        logFileSize += dataFile.print(m.longitude, 6);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.accelX)) {
        logFileSize += dataFile.print(m.accelX);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.accelY)) {
        logFileSize += dataFile.print(m.accelY);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.accelZ)) {
        logFileSize += dataFile.print(m.accelZ);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.magX)) {
        logFileSize += dataFile.print(m.magX);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.magY)) {
        logFileSize += dataFile.print(m.magY);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.magZ)) {
        logFileSize += dataFile.print(m.magZ);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.gyroX)) {
        logFileSize += dataFile.print(m.gyroX);
    }
    logFileSize += dataFile.print(F("\t"));
    if (validReadingf(m.gyroY)) {
        logFileSize += dataFile.print(m.gyroY);
    }
    logFileSize += dataFile.print(F("\t"));
//.........这里部分代码省略.........
开发者ID:veonik,项目名称:transpond,代码行数:101,代码来源:handset.cpp

示例15: setup


//.........这里部分代码省略.........
		} else {
			Serial.println("Not Connected to HMC5883L.");
		}
	#endif
	error = compass.SetScale(1.3); 				// Set the scale of the compass.
	#ifdef DEBUG_ON	
		if(error != 0) {							// If there is an error, print it out.
			Serial.println("Compass Error 1");
			Serial.println(compass.GetErrorText(error));
		} else {
			Serial.println("Compass Ok 1");
		}
	#endif
	error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous
	#ifdef DEBUG_ON	
		if(error != 0) {							// If there is an error, print it out.
			Serial.println("Compass error 2");
			Serial.println(compass.GetErrorText(error));
		} else {
			Serial.println("Compass Ok 2");
		}
	#endif	
	
	//Start up the Pressure Sensor
	dps = BMP085();
	dps.init(); 
	#ifdef DEBUG_ON
		Serial.print("BMP Mode ");
		Serial.println(dps.getMode());
	#endif	
	wdt_reset();
	// Start up the OneWire Sensors library and turn off blocking takes too long!
	sensors.begin();
	sensors.setWaitForConversion(false);
  	sensors.requestTemperaturesByAddress(outsideThermometer); // Send the command to get temperature
	
	//Initialise all of the record values
	mD.vals.tCount = 0;
	mD.vals.uslCount = 0;
	mD.vals.year = 0;
	mD.vals.month = 0;
	mD.vals.day = 0;
	mD.vals.hour = 0;
	mD.vals.minute = 0;
	mD.vals.second = 0;
	mD.vals.hundredths = 0;
	mD.vals.iLat = 0;
	mD.vals.iLong = 0;
	mD.vals.iAlt = 0;
	mD.vals.bSats = 0;
	mD.vals.iAngle = 0;
	mD.vals.iHspeed = 0;
	mD.vals.iVspeed = 0;
	mD.vals.age = 0;
	mD.vals.ihdop = 0;
	mD.vals.AcXPayload = 0;
	mD.vals.AcYPayload = 0;
	mD.vals.AcZPayload = 0;
	mD.vals.GyXPayload = 0;
	mD.vals.GyYPayload = 0;
	mD.vals.GyZPayload = 0;
	mD.vals.MgXPayload = 0;
	mD.vals.MgYPayload = 0;
	mD.vals.MgZPayload = 0;
	mD.vals.TmpPayload = 0;
	
	//Connect to the SD Card	
	if(!SD.begin(PIN_SPI_CS, SPI_HALF_SPEED)) {
		#ifdef DEBUG_ON	
			Serial.println("SD not working!!");
		#endif 
		SET_LED_Status(SET_LED_WHITE,500); 	//White LED
		SET_LED_Status(SET_LED_RED,3000); 	//Red LED 
	} else {
		#ifdef DEBUG_ON	
			Serial.println("SD OK");
		#endif 	
		dataFile.open(SD_LOG_FILE, O_CREAT | O_WRITE | O_APPEND);	    //Open Logfile
		if (!dataFile.isOpen()) {
			#ifdef DEBUG_ON	
				Serial.println("SD Data File Not Opened");
			#endif 	
			SET_LED_Status(SET_LED_WHITE,500);
			SET_LED_Status(SET_LED_RED,3000);
		}
	}

	//Cycle lights
	SET_LED_Status(SET_LED_OFF,0);  
	SET_LED_Status(SET_LED_RED,500);
	SET_LED_Status(SET_LED_GREEN,500);
	SET_LED_Status(SET_LED_BLUE,500);
	SET_LED_Status(SET_LED_OFF,0);  
	
	elapseSIM900 = millis();				//Elapse counter for data to SIM900
	elapseNTXB = millis();					//Elapse counter for data to NTXB
	NEWGPSDATA = false;
	wdt_enable(WDTO_2S);
	wdt_reset();
}
开发者ID:habjoehighalt,项目名称:AURA5,代码行数:101,代码来源:AURA5Main.cpp


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