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.
Fork of PsiSwarmLibrary by
basic.cpp@4:dc77a25f29de, 2016-06-20 (annotated)
- Committer:
- jah128
- Date:
- Mon Jun 20 13:35:06 2016 +0000
- Revision:
- 4:dc77a25f29de
- Parent:
- 2:c6986ee3c7c5
Commit for UKESF Lab
Who changed what in which revision?
| User | Revision | Line number | New 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 | 2:c6986ee3c7c5 | 8 | * PsiSwarm Library Version: 0.41 |
| jah128 | 0:d6269d17c8cf | 9 | * |
| jah128 | 2:c6986ee3c7c5 | 10 | * March 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 |
