Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years, 3 months ago.
Problems with the mbed library
Hello
There is a problem with the mbed library. Apparently the library has been updated this morning. Since then I cannot compile when I start new projects. The compiler constantly shows errors:
This morning at (ca) 10 clock it was still working.
1. Project: mbed library update: 3 days, 4 hours ago 2. Project: mbed library update: 2 hours ago
Also the program with the old library from Friday don't compile anymore. And the new project with the updated library don't work too.
7 Answers
12 years, 3 months ago.
Publishing code can be handier, since it also includes the libraries you used. Anyway the problem seems to be the mbed library, you just need to go to an older version, todays update isnt the problem, but the one from a few days back. So revert to the version before that, and use the old MODSERIAL, and it works again. Looks like new version breaks fatfilesystem library.
At least I got it to compile that way again.
Edit: http://mbed.org/users/Sissors/code/Franziska That should work if you import it.
12 years, 3 months ago.
Easiest solution: remove mbed library from your project, go to: http://mbed.org/users/mbed_official/code/mbed//builds/, import yesterdays build if the problem is just the build.
You can also publish your code and we can have a look at it. I assume FileHandle.h will also be used in LocalFileSystem, and the example project of that one still compiles fine. But then doesnt say that much.
(btw I do read german, just dont ask me to reply in it :P)
12 years, 3 months ago.
Maybe it's not the mbed library, but how can I solve the problem with the FAT file system, and then the SD card system. (because the SD File Systems needs the FAT) FAT and SD are somehow not compatible with the mbed library. No matter which version of the library I've tried.
Anyhow, here is my code:
#include "mbed.h" #include "SDFileSystem.h" #include "MODSERIAL.h" MODSERIAL pc(USBTX, USBRX, 256); Serial RS485(p26, p25); DigitalOut DTR (p21); // SDFileSystem sd(p11, p12, p13, p14, "sd"); LocalFileSystem local("local"); FILE *fp; Timer timeout; // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Variablen // Variablen zum Berechnen der Bytes und Speichern des Telegramms int data = 0; int all_bytes = 0; int adress_byte = 0; int num_of_blocks = 0; int num_of_crc = 0; int counter = 0; // Variablen zum Ueberpruefen der Transitions int trans_1 = 0; int trans_2 = 0; int trans_3 = 0; int trans_4 = 0; // Überwachungszeitstempel int MonitoringTimestamp; // Variable fuer den switch case int state = 0; // Konstanten fuer den state-Wechsel des switch case #define WAIT_FOR_ADRESS 0 #define WAIT_FOR_BLOCKCOUNT 1 #define WAIT_FOR_DATA 2 #define WAIT_FOR_ACKNOWLEDGE 3 // Konstanten fuer die Berechnung der Anzahl der zu empfangenen Bytes #define DATA_BYTES 8 #define SEC_BYTES 4 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Funktionen void transition1() { trans_1 = 0; // Lese das erste Zeichen ein data = RS485.getc(); // Uebergangsbedingung: Adressbyte empfangen if(data != 0) { pc.printf("%x ", data); trans_1 = 1; } return; } void transition2() { trans_2 = 0; // Lese die Blockanzahl als zweites Zeichen ein num_of_blocks = RS485.getc(); // Uebergangsbedingung: Bytes empfangen if(num_of_blocks != 0) { pc.printf("%x ", num_of_blocks); trans_2 = 1; } return; } void transition3() { trans_3 = 0; // Uebergangsbedingung: Zaehler muss gleich 0 sein if(counter == 0) { trans_3 = 1; } // Lese die vergangene Zeit in Millisekunden aus und speichere Sie in einer Variable MonitoringTimestamp = timeout.read_ms(); // Wenn die vergangene Zeit 65 Millisekunden ueberschreitet, dann wechsel in WAIT_FOR_BLOCKCOUNT if(MonitoringTimestamp > 65) { pc.printf("(Nicht alle Bytes empfangen)\r\n\n"); trans_3 = 2; } return; } void transition4() { trans_4 = 0; data = RS485.getc(); // Zeilenumbruch nach der Quittung "aa" if(data == 170) { pc.printf("%x ", data); pc.printf("\r\n\n"); trans_4 = 1; } else { pc.printf("(Keine Quittung empfangen)\r\n\n"); pc.printf("%x ", data); trans_4 = 2; } return; } int action_state(int num_of_blocks) { int all_bytes = 0; // Aktion: Berechne die Anzahl der zu emfangenden Bytes, Zaehler setzen // Anzahl der CRC-Bytes berechnen if(num_of_blocks % 3 == 0) { num_of_crc = num_of_blocks / 3; } else { num_of_crc = num_of_blocks / 3 + 1; } // Anzahl aller Bytes berechnen all_bytes = (num_of_blocks * DATA_BYTES) + (num_of_crc * SEC_BYTES) - 1; return all_bytes; //Rückgabe der zu empfangenden Datenbytes } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Hauptfunktion int main() { struct tm t; // Starte den Timer timeout.start(); // Entnehme die Sekunden der RTC des mbed's zum stellen der aktuellen Uhrzeit void set_time(time_t t); /* Achtung: Baudrate für die Uebertragung zum PC hochsetzen, sonst gehen auf diesem Weg Zeichen verloren. Auf der RS485 kommen die Daten schneller rein (65000) als sie in der Standardeinstellung für die PC-Verbindung (9600) abgegeben werden können. Ausserdem wird durch die Ausgabe als Hexwert gewissermassen aus einem empfangenen Wert zwei gesendete! */ // Setze die Baudrate des PCs auf 230400 pc.baud (230400); // Setze die Baudrate von RS-485 auf 62500 Baud RS485.baud (62500); // Das Format von RS-485 ist 8 Bits, 1 Paritaetsbit und 1 Stopbit RS485.format(8,ParityForced1,1); // Um etwas empfangen zu koennen muss DTR immer gleich 0 sein DTR = 0; /* // Beziehe die SD-Karte als Datenlogger mit ein mkdir("/sd/mydir", 0777); */ while(1) { // Lese die aktuelle Zeit von der RealTimeClock ab time_t seconds = time(NULL); // in Sekunden konvertieren time_t event_seconds = mktime(&t); // Bestimme ob es etwas vom RS485 zu lesen gibt if (RS485.readable()) { // Switch Case fuer die State Machine switch (state) { case WAIT_FOR_ADRESS : // Pruefe die Uebergangsbedingung fuer den Wechsel nach WAIT_FOR_BLOCKCOUNT transition1(); if (trans_1 == 1) { // In den naechsten State wechseln state = WAIT_FOR_BLOCKCOUNT; } break; case WAIT_FOR_BLOCKCOUNT : // Pruefe die Uebergangsbedingung fuer den Wechsel nach WAIT_FOR_DATA transition2(); if (trans_2 == 1) { // Uebergangsaktion counter = action_state(num_of_blocks); // Setze den Timer auf Null timeout.reset(); // In den naechsten State wechseln state = WAIT_FOR_DATA; } break; case WAIT_FOR_DATA : // Lese alle restlichen Zeichen des Telegramms ein data = RS485.getc(); // Nach jedem Byte wird der Zaehler verringert counter--; // Pruefe die Uebergangsbedingung fuer den Wechsel nach WAIT_FOR_ACKNOWLEDGE transition3(); if (trans_3 == 1) { // Wenn der Zähler auf 0 ist State wechseln. Quittung erwartet. state = WAIT_FOR_ACKNOWLEDGE; } if(trans_3 == 2) { // Wechsel in den State WAIT_FOR_BLOCKCOUNT wenn du nicht genug Bytes empfangen hast state = WAIT_FOR_BLOCKCOUNT; } // Schreibe die einzelnen Datenbytes als Hex-Zeichen im HyperTerminal heraus pc.printf("%x ", data); // Setze den Timer auf Null timeout.reset(); break; case WAIT_FOR_ACKNOWLEDGE : // Ueberprueft ob die Quittung empfangen wurde oder nicht transition4(); // In den ersten State wechseln. Adressbyte erwartet. if(trans_4 == 1) { /* // Zeitpunkt holen bzw. den bereits geholten Wert umwandeln struct tm *t; t = localtime(&seconds); // Oeffne die Datei telegram.txt fp = fopen("/sd/mydir/telegram.txt", "a"); // Speichere den Zeitpunkt des empfangenen Telegramms in die Datei telegram.txt fprintf(fp, "Zeit: %02d:%02d:%02d, Datum: %02d.%02d.%04d, Aktion: Telegramm empfangen\r\n", t->tm_hour, t->tm_min, t->tm_sec,t->tm_mday,t->tm_mon+1,t->tm_year+1900); // Datei wird geschlossen fclose(fp); */ // Wechsel in den State WAIT_FOR_ADRESS wenn du die Quittung erfolgreich empfangen hast state = WAIT_FOR_ADRESS; } if(trans_4 == 2) { // Wechsel in den State WAIT_FOR_BLOCKCOUNT wenn du keine Quittung empfangen hast, um ein neues Telegramm zu erhalten state = WAIT_FOR_BLOCKCOUNT; } break; } } } }
12 years, 3 months ago.
I don't think it is the problem with sdcard file system. The SDFileSystem from cookbook was working fine for me with mbed library revision 21 and 22. Yesterday I just updated mbed library to the latest and i get the same error.
12 years, 3 months ago.
Found out.........
FATFileSystem with SDCard.cpp , SDFileSystem and SDHCFileSystem worls with mbed library rev 39 or less.
Another solution:
Delete existing SDCard.cpp and .h file from project, delete FAT library, import this library:- http://mbed.org/users/mbed_official/code/SDFileSystem/
I did the same and it worked :)
12 years, 3 months ago.
Is your main file a .c file?
If so the compiler will compile as C not as C++. I've only ever seen the namespace error because of that.
Try renaming .c files to .cpp