Library for the PsiSwarm Robot - Version 0.7

Dependents:   PsiSwarm_V7_Blank

Fork of PsiSwarmLibrary by James Hilder

Committer:
jah128
Date:
Thu Feb 04 21:48:54 2016 +0000
Revision:
0:d6269d17c8cf
Child:
2:c6986ee3c7c5
PsiSwarm Library Version 0.4 - Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jah128 0:d6269d17c8cf 1 /* University of York Robotics Laboratory PsiSwarm Library: Psi-BASIC Interpretter Code
jah128 0:d6269d17c8cf 2 *
jah128 0:d6269d17c8cf 3 * File: basic.cpp
jah128 0:d6269d17c8cf 4 *
jah128 0:d6269d17c8cf 5 * (C) Dept. Electronics & Computer Science, University of York
jah128 0:d6269d17c8cf 6 * James Hilder, Alexander Horsfield, Alan Millard, Homero Elizondo, Jon Timmis
jah128 0:d6269d17c8cf 7 *
jah128 0:d6269d17c8cf 8 * PsiSwarm Library Version: 0.4
jah128 0:d6269d17c8cf 9 *
jah128 0:d6269d17c8cf 10 * Feb 2016
jah128 0:d6269d17c8cf 11 *
jah128 0:d6269d17c8cf 12 */
jah128 0:d6269d17c8cf 13
jah128 0:d6269d17c8cf 14 #include "psiswarm.h"
jah128 0:d6269d17c8cf 15
jah128 0:d6269d17c8cf 16 LocalFileSystem local("local");
jah128 0:d6269d17c8cf 17
jah128 0:d6269d17c8cf 18 void read_list_of_file_names()
jah128 0:d6269d17c8cf 19 {
jah128 0:d6269d17c8cf 20 DIR *dp;
jah128 0:d6269d17c8cf 21 struct dirent *dirp;
jah128 0:d6269d17c8cf 22 dp = opendir("/local");
jah128 0:d6269d17c8cf 23 if(dp == NULL) pc.printf("- File handling error: Failed to open directory\n");
jah128 0:d6269d17c8cf 24 debug("- Reading FLASH storage for PsiBasic files\n");
jah128 0:d6269d17c8cf 25 //read all files in MBED root directory and add matching file names in current directory into filename vector
jah128 0:d6269d17c8cf 26 while((dirp = readdir(dp)) != NULL) {
jah128 0:d6269d17c8cf 27 string filename = (string) dirp->d_name;
jah128 0:d6269d17c8cf 28 if (filename.compare(filename.size()-4,4,".PSI") == 0)
jah128 0:d6269d17c8cf 29 {
jah128 0:d6269d17c8cf 30 psi_basic_file_count ++ ;
jah128 0:d6269d17c8cf 31 debug("- Found file: %s\n",filename.c_str());
jah128 0:d6269d17c8cf 32 basic_filenames.push_back(filename);
jah128 0:d6269d17c8cf 33 }
jah128 0:d6269d17c8cf 34 }
jah128 0:d6269d17c8cf 35 closedir(dp);
jah128 0:d6269d17c8cf 36 }
jah128 0:d6269d17c8cf 37
jah128 0:d6269d17c8cf 38 //....example call in your "main" code somewhere.....
jah128 0:d6269d17c8cf 39
jah128 0:d6269d17c8cf 40 // read file names into vector of strings
jah128 0:d6269d17c8cf 41