This is the final version of Mini Gateway for Automation and Security desgined for Renesas GR Peach Design Contest

Dependencies:   GR-PEACH_video GraphicsFramework HTTPServer R_BSP mbed-rpc mbed-rtos Socket lwip-eth lwip-sys lwip FATFileSystem

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
vipinranka
Date:
Wed Jan 11 11:41:30 2017 +0000
Revision:
12:9a20164dcc47
This is the final version MGAS Project for Renesas GR Peach Design Contest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vipinranka 12:9a20164dcc47 1 /* mbed Microcontroller Library
vipinranka 12:9a20164dcc47 2 * Copyright (c) 2006-2013 ARM Limited
vipinranka 12:9a20164dcc47 3 *
vipinranka 12:9a20164dcc47 4 * Licensed under the Apache License, Version 2.0 (the "License");
vipinranka 12:9a20164dcc47 5 * you may not use this file except in compliance with the License.
vipinranka 12:9a20164dcc47 6 * You may obtain a copy of the License at
vipinranka 12:9a20164dcc47 7 *
vipinranka 12:9a20164dcc47 8 * http://www.apache.org/licenses/LICENSE-2.0
vipinranka 12:9a20164dcc47 9 *
vipinranka 12:9a20164dcc47 10 * Unless required by applicable law or agreed to in writing, software
vipinranka 12:9a20164dcc47 11 * distributed under the License is distributed on an "AS IS" BASIS,
vipinranka 12:9a20164dcc47 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
vipinranka 12:9a20164dcc47 13 * See the License for the specific language governing permissions and
vipinranka 12:9a20164dcc47 14 * limitations under the License.
vipinranka 12:9a20164dcc47 15 */
vipinranka 12:9a20164dcc47 16 #ifndef MBED_LOCALFILESYSTEM_H
vipinranka 12:9a20164dcc47 17 #define MBED_LOCALFILESYSTEM_H
vipinranka 12:9a20164dcc47 18
vipinranka 12:9a20164dcc47 19 #include "platform/platform.h"
vipinranka 12:9a20164dcc47 20
vipinranka 12:9a20164dcc47 21 #if DEVICE_LOCALFILESYSTEM
vipinranka 12:9a20164dcc47 22
vipinranka 12:9a20164dcc47 23 #include "drivers/FileSystemLike.h"
vipinranka 12:9a20164dcc47 24 #include "platform/PlatformMutex.h"
vipinranka 12:9a20164dcc47 25
vipinranka 12:9a20164dcc47 26 namespace mbed {
vipinranka 12:9a20164dcc47 27 /** \addtogroup drivers */
vipinranka 12:9a20164dcc47 28 /** @{*/
vipinranka 12:9a20164dcc47 29
vipinranka 12:9a20164dcc47 30 FILEHANDLE local_file_open(const char* name, int flags);
vipinranka 12:9a20164dcc47 31
vipinranka 12:9a20164dcc47 32 class LocalFileHandle : public FileHandle {
vipinranka 12:9a20164dcc47 33
vipinranka 12:9a20164dcc47 34 public:
vipinranka 12:9a20164dcc47 35 LocalFileHandle(FILEHANDLE fh);
vipinranka 12:9a20164dcc47 36
vipinranka 12:9a20164dcc47 37 virtual int close();
vipinranka 12:9a20164dcc47 38
vipinranka 12:9a20164dcc47 39 virtual ssize_t write(const void *buffer, size_t length);
vipinranka 12:9a20164dcc47 40
vipinranka 12:9a20164dcc47 41 virtual ssize_t read(void *buffer, size_t length);
vipinranka 12:9a20164dcc47 42
vipinranka 12:9a20164dcc47 43 virtual int isatty();
vipinranka 12:9a20164dcc47 44
vipinranka 12:9a20164dcc47 45 virtual off_t lseek(off_t position, int whence);
vipinranka 12:9a20164dcc47 46
vipinranka 12:9a20164dcc47 47 virtual int fsync();
vipinranka 12:9a20164dcc47 48
vipinranka 12:9a20164dcc47 49 virtual off_t flen();
vipinranka 12:9a20164dcc47 50
vipinranka 12:9a20164dcc47 51 protected:
vipinranka 12:9a20164dcc47 52 virtual void lock();
vipinranka 12:9a20164dcc47 53 virtual void unlock();
vipinranka 12:9a20164dcc47 54 FILEHANDLE _fh;
vipinranka 12:9a20164dcc47 55 int pos;
vipinranka 12:9a20164dcc47 56 PlatformMutex _mutex;
vipinranka 12:9a20164dcc47 57 };
vipinranka 12:9a20164dcc47 58
vipinranka 12:9a20164dcc47 59 /** A filesystem for accessing the local mbed Microcontroller USB disk drive
vipinranka 12:9a20164dcc47 60 *
vipinranka 12:9a20164dcc47 61 * This allows programs to read and write files on the same disk drive that is used to program the
vipinranka 12:9a20164dcc47 62 * mbed Microcontroller. Once created, the standard C file access functions are used to open,
vipinranka 12:9a20164dcc47 63 * read and write files.
vipinranka 12:9a20164dcc47 64 *
vipinranka 12:9a20164dcc47 65 * @Note Synchronization level: Thread safe
vipinranka 12:9a20164dcc47 66 *
vipinranka 12:9a20164dcc47 67 * Example:
vipinranka 12:9a20164dcc47 68 * @code
vipinranka 12:9a20164dcc47 69 * #include "mbed.h"
vipinranka 12:9a20164dcc47 70 *
vipinranka 12:9a20164dcc47 71 * LocalFileSystem local("local"); // Create the local filesystem under the name "local"
vipinranka 12:9a20164dcc47 72 *
vipinranka 12:9a20164dcc47 73 * int main() {
vipinranka 12:9a20164dcc47 74 * FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
vipinranka 12:9a20164dcc47 75 * fprintf(fp, "Hello World!");
vipinranka 12:9a20164dcc47 76 * fclose(fp);
vipinranka 12:9a20164dcc47 77 * remove("/local/out.txt"); // Removes the file "out.txt" from the local file system
vipinranka 12:9a20164dcc47 78 *
vipinranka 12:9a20164dcc47 79 * DIR *d = opendir("/local"); // Opens the root directory of the local file system
vipinranka 12:9a20164dcc47 80 * struct dirent *p;
vipinranka 12:9a20164dcc47 81 * while((p = readdir(d)) != NULL) { // Print the names of the files in the local file system
vipinranka 12:9a20164dcc47 82 * printf("%s\n", p->d_name); // to stdout.
vipinranka 12:9a20164dcc47 83 * }
vipinranka 12:9a20164dcc47 84 * closedir(d);
vipinranka 12:9a20164dcc47 85 * }
vipinranka 12:9a20164dcc47 86 * @endcode
vipinranka 12:9a20164dcc47 87 *
vipinranka 12:9a20164dcc47 88 * @note
vipinranka 12:9a20164dcc47 89 * If the microcontroller program makes an access to the local drive, it will be marked as "removed"
vipinranka 12:9a20164dcc47 90 * on the Host computer. This means it is no longer accessible from the Host Computer.
vipinranka 12:9a20164dcc47 91 *
vipinranka 12:9a20164dcc47 92 * The drive will only re-appear when the microcontroller program exists. Note that if the program does
vipinranka 12:9a20164dcc47 93 * not exit, you will need to hold down reset on the mbed Microcontroller to be able to see the drive again!
vipinranka 12:9a20164dcc47 94 */
vipinranka 12:9a20164dcc47 95 class LocalFileSystem : public FileSystemLike {
vipinranka 12:9a20164dcc47 96 // No modifiable state
vipinranka 12:9a20164dcc47 97
vipinranka 12:9a20164dcc47 98 public:
vipinranka 12:9a20164dcc47 99 LocalFileSystem(const char* n) : FileSystemLike(n) {
vipinranka 12:9a20164dcc47 100
vipinranka 12:9a20164dcc47 101 }
vipinranka 12:9a20164dcc47 102
vipinranka 12:9a20164dcc47 103 virtual FileHandle *open(const char* name, int flags);
vipinranka 12:9a20164dcc47 104 virtual int remove(const char *filename);
vipinranka 12:9a20164dcc47 105 virtual DirHandle *opendir(const char *name);
vipinranka 12:9a20164dcc47 106 };
vipinranka 12:9a20164dcc47 107
vipinranka 12:9a20164dcc47 108 } // namespace mbed
vipinranka 12:9a20164dcc47 109
vipinranka 12:9a20164dcc47 110 #endif
vipinranka 12:9a20164dcc47 111
vipinranka 12:9a20164dcc47 112 #endif
vipinranka 12:9a20164dcc47 113
vipinranka 12:9a20164dcc47 114 /** @}*/