本文整理汇总了C++中SdFile::ls方法的典型用法代码示例。如果您正苦于以下问题:C++ SdFile::ls方法的具体用法?C++ SdFile::ls怎么用?C++ SdFile::ls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdFile
的用法示例。
在下文中一共展示了SdFile::ls方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
void setup() {
//Serial.begin(9600);
PgmPrint("Free RAM: ");
//Serial.println(FreeRam());
// initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
// breadboards. use SPI_FULL_SPEED for better performance.
pinMode(10, OUTPUT); // set the SS pin as an output (necessary!)
digitalWrite(10, HIGH); // but turn off the W5100 chip!
if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");
// initialize a FAT volume
if (!volume.init(&card)) error("vol.init failed!");
PgmPrint("Volume is FAT");
//Serial.println(volume.fatType(),DEC);
//Serial.println();
if (!root.openRoot(&volume)) error("openRoot failed");
// list file in root with date and size
PgmPrintln("Files found in root:");
root.ls(LS_DATE | LS_SIZE);
//Serial.println();
// Recursive list of all directories
PgmPrintln("Files found in all dirs:");
root.ls(LS_R);
//Serial.println();
PgmPrintln("Done");
// Debugging complete, we start the server!
Ethernet.begin(mac, ip);
server.begin();
// Start up the temperature library
sensorsa.begin();
sensorsb.begin();
sensorsc.begin();
sensorsd.begin();
setTime(0); // start the clock
time33mins = time60mins = now();
}
示例2: run
int App::run()
{
if (!card.init(SPI_HALF_SPEED, 4))
{
Serial.puts("initialization failed. Things to check:\r\n");
Serial.puts("* is a card is inserted?\r\n");
Serial.puts("* Is your wiring correct?\r\n");
Serial.puts("* did you change the chipSelect pin to match your shield or module?\r\n");
return 0;
}
else
{
Serial.puts("Wiring is correct and a card is present.\r\n");
}
Serial.puts("\r\nCard type: ");
switch(card.type())
{
case SD_CARD_TYPE_SD1:
Serial.puts("SD1\r\n");
break;
case SD_CARD_TYPE_SD2:
Serial.puts("SD2\r\n");
break;
case SD_CARD_TYPE_SDHC:
Serial.puts("SDHC\r\n");
break;
default:
Serial.puts("Unknown\r\n");
}
if (!volume.init(card))
{
Serial.puts("Could not find FAT16/FAT32 partition.\r\n");
Serial.puts("Make sure you've formatted the card\r\n");
return 0;
}
uint32_t volumesize;
Serial.printf("\r\nVolume type is FAT%u\r\n", volume.fatType());
volumesize = volume.blocksPerCluster();
volumesize *= volume.clusterCount();
volumesize *= 512;
Serial.printf("Volume size (bytes): %u\r\n", volumesize);
volumesize /= 1024;
Serial.printf("Volume size (Kbytes): %u\r\n");
volumesize /= 1024;
Serial.printf("Volume size (Mbytes): %u\r\n");
Serial.puts("\r\nFiles found on the card (name, date and size in bytes): \r\n");
root.openRoot(volume);
root.ls(LS_R | LS_DATE | LS_SIZE, 0, Serial);
while (true) { }
return 0;
}
示例3: setup
void setup() {
Serial.begin(9600);
pinMode(greenLEDandBEEP, OUTPUT);
pinMode(redLEDpin, OUTPUT);
PgmPrint("Free RAM: ");
Serial.println(FreeRam());
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);
if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");
if (!volume.init(&card)) error("vol.init failed!");
PgmPrint("Volume is FAT");
Serial.println(volume.fatType(),DEC);
Serial.println();
if (!root.openRoot(&volume)) error("openRoot failed");
PgmPrintln("Files found in root:");
root.ls(LS_DATE | LS_SIZE);
Serial.println();
PgmPrintln("Files found in all dirs:");
root.ls(LS_R);
Serial.println();
PgmPrintln("Done");
Ethernet.begin(mac, ip);
server.begin();
}
示例4: printCardInfo
void printCardInfo() {
Serial.print(F("Data logging is "));
if (disableLogging) {
Serial.println(F("DISABLED"));
} else {
Serial.println(F("ENABLED"));
}
Serial.println();
Serial.print("\nCard type: ");
switch (card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
break;
default:
Serial.println("Unknown");
}
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
unsigned long volumesize;
volumesize = volume.blocksPerCluster();
volumesize *= volume.clusterCount();
volumesize /= 2;
volumesize /= 1024;
Serial.print("Volume size: ");
Serial.print(volumesize, DEC);
Serial.println("MB");
Serial.println("name\tdate\tsize");
root.ls(LS_R | LS_DATE | LS_SIZE);
Serial.println();
}
示例5: setup
void setup()
{
Serial.begin(BPS_115200);
PgmPrintln("Type any character to start");
while (!Serial.available());
Serial.print("\nInitializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
//pinMode(10, OUTPUT); // change this to 53 on a mega
// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card is inserted?");
Serial.println("* Is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
return;
} else {
Serial.println("Wiring is correct and a card is present.");
}
// print the type of card
Serial.print("\nCard type: ");
switch(card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
break;
default:
Serial.println("Unknown");
}
// 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");
return;
}
// print the type and size of the first FAT-type volume
uint32_t volumesize;
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
Serial.println();
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volumesize *= 512; // SD card blocks are always 512 bytes
Serial.print("Volume size (bytes): ");
Serial.println(volumesize);
Serial.print("Volume size (Kbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.print("Volume size (Mbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.println("\nFiles found on the card (name, date and size in bytes): ");
root.openRoot(volume);
// list all files in the card with date and size
root.ls(LS_R | LS_DATE | LS_SIZE);
}
示例6: handleConsoleInput
void handleConsoleInput() {
uint8_t retval;
uint8_t index=0;
uint8_t ch='0';
SdFile finger;
switch (console.keyValue()) {
case _DIR_:
console.printf("SOD:\r\n");
root.ls(LS_DATE | LS_SIZE);
console.printf("EOD:\r\n");
break;
case _LSV_:
console.printf("LSV:" BOM_VERSION "\r\n");
break;
case _TYP_:
typeFile(console.arguments());
break;
case _NSC_:
console.printf("SOD:\r\n");
retval=networkScan();
console.printf("EOD:\r\n");
console.printf("\nDBG: found=%d\r\n",retval);
break;
case _NJN_:
//console.printf("SOD:\r\n");
retval=networkJoin(console.arguments());
//console.printf("EOD:\r\n");
console.printf("\nDBG: joined=%s\r\n",retval?"TRUE":"FALSE");
break;
case _NPW_:
//console.printf("SOD:\r\n");
retval=networkSetPassword(console.arguments());
//console.printf("EOD:\r\n");
console.printf("\nDBG: pwd set=%s\r\n",retval?"TRUE":"FALSE");
break;
case _NST_:
retval=networkStatus();
console.printf("NST: %s\r\n",retval?"CONNECTED":"NOT CONNECTED");
break;
case _FMT_: // there really should be some REALLY do you mean this here but.....
root.openRoot(&volume);
if (finger.open(&root, ".", O_WRITE|O_READ)) {
console.printf("\nDBG: Opened / \r\n");
finger.rmRfStar();
} else {
console.printf("\nDBG: FAIL \r\n");
}
break;
case _TPT_:
toPachube(1, console.arguments());
break;
case _TX2_:
radio.printf("%s",console.arguments());
index=0;
// delay(1000);
while (radio.available()) {
inBuffer[index++]=ch=radio.read();
if( index>= 99 || ((ch== '\n') || ch !='\r')) {
inBuffer[index]='\0';
console.puts(inBuffer);
index=0;
delay(100);
}
}
inBuffer[index]='\0';
console.puts(inBuffer);
console.puts((char *) "\r\n");
break;
// set to one to test output for.
#if 1
case _TS1_: toPachube(0, console.arguments()); break;
case _TS2_: toPachube(1, console.arguments()); break;
case _TS3_: toPachube(2, console.arguments()); break;
case _TS4_: toPachube(3, console.arguments()); break;
case _TS5_: toPachube(4, console.arguments()); break;
case _FAN_: toPachube(5, console.arguments()); break;
case _CHL_: toPachube(6, console.arguments()); break;
case _STC_: toPachube(7, console.arguments()); break;
#endif
case _PKY_:
strncpy(pachubeKey, console.arguments(), MAX_PATCHUBE_KEY_LENGHT-1);
stripcrlf(pachubeKey);
break;
case _PFD_:
strncpy(pachubeFeed, console.arguments(), MAX_PATCHUBE_FEED_LENGHT-1);
stripcrlf(pachubeFeed);
break;
case _SGT_ :
readSettings();
break;
case _SSV_ :
writeSettings();
break;
default:
console.printf("DBG: forwarding (%s) to device\r\n",console.key());
device.puts(console.line());
//.........这里部分代码省略.........
示例7: setup
void setup()
{
Serial.begin(115200);
while (!Serial.available());
Serial.print("\nInitializing SD card...");
// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
// Initialize HARDWARE SPI with user defined chipSelect
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
// Initialize SOFTWARE SPI (uncomment and comment out above line to use)
// if (!card.init(mosiPin, misoPin, clockPin, chipSelect)) {
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card is inserted?");
Serial.println("* Is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
return;
} else {
Serial.println("Wiring is correct and a card is present.");
}
// print the type of card
Serial.print("\nCard type: ");
switch(card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
break;
default:
Serial.println("Unknown");
}
// 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");
return;
}
// print the type and size of the first FAT-type volume
uint32_t volumesize;
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
Serial.println();
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volumesize *= 512; // SD card blocks are always 512 bytes
Serial.print("Volume size (bytes): ");
Serial.println(volumesize);
Serial.print("Volume size (Kbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.print("Volume size (Mbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.println("\nFiles found on the card (name, date and size in bytes): ");
root.openRoot(volume);
// list all files in the card with date and size
root.ls(LS_R | LS_DATE | LS_SIZE);
}