Hallo zusammen, ich habe mit meinem Arduino und einem SD Shield schon mal eine Verbindung aufgebaut die funktioniert aber ich möchte wenn ich eine TXT Datei lese einzelne Zeilen auslesen, beschreiben, löschen können ohne die anderen dabei zu verändern. Ist dies realisierbar? LG
Hallo, kann ich das Byte mit den Daten drin irgenwie zerschnibbeln oder durchsuchen? LG
Hallo, in einem "Byte mit den Daten" sind höchsten 8 relevante Bits. Also für die SD Kartenverwaltung benötigt man auch noch eine FAT(16) Dateisystem. Hast Du das ?
Toni Nachname schrieb: > kann ich das Byte mit den Daten drin irgenwie zerschnibbeln oder > durchsuchen? Ja sicher, auch das funktioniert. Ein Bit im Byte suchen ist ganz einfach, es gibt ja nur 8 davon.
Toni Nachname schrieb: > kann ich das Byte mit den Daten drin irgenwie zerschnibbeln oder > durchsuchen? Ja klar, aber aufpassen, dass Du nicht die SD-Karte zerschnibbelst.
Hallo zusammen,
ich habe nochmal ein bisschen rumprobiert und stehe vor einem Problem:
ICh möchte mit dem SD.exists Befehl gucken ob ein Ordner da ist aber es
kommt immer folgende Fehlermeldung:
Arduino: 1.6.2 (Windows 7), Platine: "Arduino Uno"
ReadWrite.ino: In function 'void loop()':
ReadWrite.ino:70:19: error: invalid conversion from 'const char*' to
'char' [-fpermissive]
ReadWrite.ino:71:25: error: invalid conversion from 'char' to 'char*'
[-fpermissive]
In file included from ReadWrite.ino:22:0:
C:\Program Files\Arduino\libraries\SD\src/SD.h:76:11: error:
initializing argument 1 of 'boolean SDClass::exists(char*)'
[-fpermissive]
boolean exists(char *filepath);
^
Fehler beim Kompilieren.
Dieser Report hätte mehr Informationen mit
"Ausführliche Ausgabe während der Kompilierung"
aktiviert in Datei > Einstellungen
Das ist der Quellcode:
/*
SD card read/write
This example shows how to read and write data to and from an SD card
file
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
*/
#include <SPI.h>
#include <SD.h>
#include <SoftwareSerial.h>
File myFile;
SoftwareSerial mySerial(2, 3);
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
mySerial.begin(9600);
Serial.print("Initializing 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);
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
/*
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}*/
}
void loop()
{
if (mySerial.available()){
char mysread = mySerial.read();
char readed = "/filename/";
if (SD.exists(readed))
{
Serial.print("Existiert!");
}
Serial.print(mysread);
}
}
Kann mir jemand helfen?
char readed = "/filename/"; if (SD.exists(readed)) Das ist kein char Pointer. Die Funktion erwartet aber einen!
@ Toni Nachname (ich3) >ReadWrite.ino: In function 'void loop()': In der Funktion 'void loop()' >ReadWrite.ino:70:19: error: invalid conversion from 'const char*' to >'char' [-fpermissive] ungültige Umwandlung von Zeiger auf konstantes Zeichen zu Zeichen Auch im Arduino-Wunderland braucht man ein paar solide C-Grundlagen. Dazu gehört auch die Stringverarbeitung. Und ein paar minimale Englischkenntnisse wären auch gut, not only some Brocken. An deinem Einrückungsstil solltest du auch arbeiten. Strukturierte Programmierung auf Mikrocontrollern Eher so.
1 | void loop() { |
2 | if (mySerial.available()) { |
3 | char mysread = mySerial.read(); |
4 | char my_filename[] = "/filename/"; // das ist ein char array! |
5 | if (SD.exists(my_filename)) { |
6 | Serial.print(my_filename); |
7 | Serial.println(" existiert!"); |
8 | }
|
9 | Serial.print(mysread); |
10 | }
|
11 | }
|
1 | char my_filename[] = "/filename/"; // das ist ein char array! |
und
1 | if (SD.exists(my_filename)) //<-- da wird ein Pointer uebergeben |
2 | {
|
3 | }
|
Alternativ:
1 | if (SD.exists(&my_filename[0])) //Adresse von erstem Element aus dem Char-Array |
2 | {
|
3 | }
|
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.