Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreePilot PinDetect mbed-src
Fork of FreePilot_V2-2 by
Config.cpp
- Committer:
- maximbolduc
- Date:
- 2015-01-16
- Revision:
- 26:dc00998140af
- Child:
- 28:5905886c76ee
File content as of revision 26:dc00998140af:
#include "mbed.h" #include <string> #include "Config.h" LocalFileSystem local("local"); // Create the local filesystem under the name "local" void Config_Startup() { FILE * fp; char line[256]; //fp = fopen("/local/config.txt", "w"); //fprintf(fp, "BT,000666624C6A\r\nPA,0\r\nTC,4.5\r\nFG,30\r\nSC,2.7\r\nAP,-4"); //Rewrite text file for TESTING //fclose(fp); fp = fopen("/local/config.txt", "r"); while (fgets(line, sizeof(line), fp)) //Read through config file line by line Dispatch(line, true); //Send line to dispatcher, true indicates its coming from the config file fclose(fp); } void Dispatch(char* line, bool config /* = false */) { char* pointer; char* Data[5]; //Can have max of 5 peices of data split by commas int index = 0; //Split data at commas pointer = strtok(line, ","); while(pointer != NULL) { Data[index] = pointer; pointer = strtok(NULL, ","); index++; } //Check ID of read data and set the corresponding variable. if(strcmp(Data[0], "BT") == 0) { //Check BT adress here } else { //Unrecognized config setting detected. } }