Psi Swarm robot library version 0.9

Fork of PsiSwarmV9 by Psi Swarm Robot

Committer:
jah128
Date:
Mon May 14 15:35:38 2018 +0000
Revision:
20:1bc6c6dc477b
Parent:
16:50686c07ad07
Updated?

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 14:2f1ad77d281e 3 * Copyright 2017 University of York
jah128 6:b340a527add9 4 *
jah128 6:b340a527add9 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
jah128 6:b340a527add9 6 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
jah128 6:b340a527add9 7 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS
jah128 6:b340a527add9 8 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jah128 6:b340a527add9 9 * See the License for the specific language governing permissions and limitations under the License.
jah128 6:b340a527add9 10 *
jah128 0:d6269d17c8cf 11 * File: basic.cpp
jah128 0:d6269d17c8cf 12 *
jah128 6:b340a527add9 13 * Dept. Electronics & Computer Science, University of York
jah128 0:d6269d17c8cf 14 * James Hilder, Alexander Horsfield, Alan Millard, Homero Elizondo, Jon Timmis
jah128 0:d6269d17c8cf 15 *
jah128 14:2f1ad77d281e 16 * PsiSwarm Library Version: 0.9
jah128 0:d6269d17c8cf 17 *
jah128 14:2f1ad77d281e 18 * June 2017
jah128 0:d6269d17c8cf 19 *
jah128 0:d6269d17c8cf 20 */
jah128 0:d6269d17c8cf 21
jah128 16:50686c07ad07 22 // TODO: This is largely unimplemented at present - will be based on AH student project
jah128 16:50686c07ad07 23
jah128 0:d6269d17c8cf 24 #include "psiswarm.h"
jah128 0:d6269d17c8cf 25
jah128 0:d6269d17c8cf 26 LocalFileSystem local("local");
jah128 0:d6269d17c8cf 27
jah128 12:878c6e9d9e60 28 void Basic::read_list_of_file_names()
jah128 0:d6269d17c8cf 29 {
jah128 0:d6269d17c8cf 30 DIR *dp;
jah128 0:d6269d17c8cf 31 struct dirent *dirp;
jah128 0:d6269d17c8cf 32 dp = opendir("/local");
jah128 0:d6269d17c8cf 33 if(dp == NULL) pc.printf("- File handling error: Failed to open directory\n");
jah128 12:878c6e9d9e60 34 psi.debug("- Reading FLASH storage for PsiBasic files\n");
jah128 0:d6269d17c8cf 35 //read all files in MBED root directory and add matching file names in current directory into filename vector
jah128 0:d6269d17c8cf 36 while((dirp = readdir(dp)) != NULL) {
jah128 0:d6269d17c8cf 37 string filename = (string) dirp->d_name;
jah128 0:d6269d17c8cf 38 if (filename.compare(filename.size()-4,4,".PSI") == 0)
jah128 0:d6269d17c8cf 39 {
jah128 0:d6269d17c8cf 40 psi_basic_file_count ++ ;
jah128 12:878c6e9d9e60 41 psi.debug("- Found file: %s\n",filename.c_str());
jah128 0:d6269d17c8cf 42 basic_filenames.push_back(filename);
jah128 0:d6269d17c8cf 43 }
jah128 0:d6269d17c8cf 44 }
jah128 0:d6269d17c8cf 45 closedir(dp);
jah128 0:d6269d17c8cf 46 }
jah128 12:878c6e9d9e60 47