Yahoo refuse tous les emails du site. Si vous avez une adresse chez un autre prestataire, c'est le moment de l'utiliser ;)

En cas de soucis, n'hésitez pas à aller faire un tour sur la page de contact en bas de page.

Topic "Fichier introuvable (arduino)"

Flux RSS des posts récents dans ce topic ( Flux Atom)


Pas de photo de profil

lisa.dbs59

Membre

#1021 | Signaler ce message


Bonjour, je prend en main progressivement le shield datalogging GT1046 avec mon arduino UNO .

Je teste tout d'abord mon shield avec le code CardInfo ci-dessous : (en faisant la modif nécessaire cad chipSelect=10)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <SPI.h>
#include <SD.h>
 
// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;
const int chipSelect = 10;
 
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
 
 
  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!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card inserted?");
    Serial.println("* is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    while (1);
  } else {
    Serial.println("Wiring is correct and a card is present.");
  }
 
  // print the type of card
  Serial.println();
  Serial.print("Card 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");
    while (1);
  }
 
  Serial.print("Clusters:          ");
  Serial.println(volume.clusterCount());
  Serial.print("Blocks x Cluster:  ");
  Serial.println(volume.blocksPerCluster());
 
  Serial.print("Total Blocks:      ");
  Serial.println(volume.blocksPerCluster() * volume.clusterCount());
  Serial.println();
 
  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("Volume type is:    FAT");
  Serial.println(volume.fatType(), DEC);
 
  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize /= 2;                           // SD card blocks are always 512 bytes (2 blocks are 1KB)
  Serial.print("Volume size (Kb):  ");
  Serial.println(volumesize);
  Serial.print("Volume size (Mb):  ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Gb):  ");
  Serial.println((float)volumesize / 1024.0);
 
  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);
 
 
}
 
void loop(void) {
}

Le moniteur me renvoi ceci : moniteur série

Jusqu'ici tout vas bien, étant donné qu'il détecte bien mon fichier toto.txt que j'ai mis sur ma carte SD .

J'utilise ensuite le code suivant : (ainsi que la fonction SD.exists() )

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <SPI.h>
#include <SD.h>
 
// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;
 
const int chipSelect = 10;
 
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
 
  Serial.print("Init de la carte SD :\n");
 
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("BAD\n");
    while (1);
  } else {
    Serial.println("GOOD\n");
  }
   
  if(SD.exists("toto.txt"))
  {
    Serial.println(F("Fichier OK"));
  }
  else {
  Serial.println(F("Fichier introuvable"));
  }
   
  SD.remove("toto.txt");
 
}
 
void loop(void) {
}

Je n'ai rien modifié sur ma carte SD donc logiquement le moniteur devrait me retourner Fichier OK et cependant : moniteur Il dit que le fichier n'existe pas :( Je ne comprend pas d'où vient l'erreur, j'ai essayé différentes écritures et même d'utiliser d'autres fonctions comme SD.remove() voir si quelque-chose ce passait mais rien . J'ai également mis du contenu dans mon fichier texte, peu importe ce que j'ai essayé de faire, impossible de détecter et d'agir sur mon fichier toto.txt .

Je pense que l'erreur peu être dû au chemin cependant mon fichier se trouve directement dans la carte et non pas dans un dossier ou autre .

Quelqu'un a une solution ?

Merci d'avance :)

Derniére modification le par lisa.dbs59