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: mbed FatFileSystemCpp
Revision 4:09a962d3fe70, committed 2021-01-20
- Comitter:
- esemi00
- Date:
- Wed Jan 20 05:25:16 2021 +0000
- Parent:
- 3:95e55809ecdb
- Commit message:
- esemi00
Changed in this revision
--- a/main.cpp Mon Jul 30 13:49:56 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-#include "mbed.h"
-#include "MSCFileSystem.h"
-//#include <stat.h>
-
-#define FSNAME "msc"
-MSCFileSystem msc(FSNAME);
-
-int main()
-{
- DIR *d;
- struct dirent *p;
- //struct stat st;
- //char path[PATH_MAX];
-
- printf("\n\n================================\n");
- printf("USB Mass storage demo program for mbed LPC1768\n");
- printf("================================\n\n");
-
- d = opendir("/" FSNAME);
-
- printf("\nList of files on the flash drive:\n");
- if ( d != NULL )
- {
- while ( (p = readdir(d)) != NULL )
- {
- printf(" - %s\n", p->d_name);
- /* no <stat.h> on mbed, it seems :/
- sprintf(path, "/"FSNAME"/%s", p->d_name);
- if ( stat(path, &st) == 0 )
- {
- if ( S_ISDIR(st.st_mode) )
- printf(" <directory>\n");
- else
- printf(" %d\n", st.st_size);
- }
- else
- {
- printf(" ???\n");
- }*/
- }
- }
- else
- {
- error("Could not open directory!");
- }
- printf("\nTesting file write:\n");
- FILE *fp = fopen( "/" FSNAME "/msctest.txt", "w");
- if ( fp == NULL )
- {
- error("Could not open file for write\n");
- }
- fprintf(fp, "Hello mass storage!");
- fclose(fp);
- printf("\n - OK\n");
-
- printf("\nTesting file read:\n");
- fp = fopen( "/" FSNAME "/msctest.txt", "r");
- if ( fp == NULL )
- {
- error("Could not open file for read\n");
- }
- char buf[256];
- if ( NULL == fgets(buf, sizeof(buf), fp) )
- {
- error("Error reading from file\n");
- }
- fclose(fp);
- printf("\n - OK, read string: '%s'\n\n", buf);
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mainUSB1.cpp Wed Jan 20 05:25:16 2021 +0000
@@ -0,0 +1,36 @@
+//mainUSB1.cpp
+#include "mbed.h"
+#include "MSCFileSystem.h"
+#define FSNAME "usb"//FATファイルシステムのマウント名(任意) /マウント名 がルートディレクトリ
+
+Serial pc(USBTX,USBRX);
+MSCFileSystem msc(FSNAME); //USBフラッシュメモリを/usbにマウントして使用するため宣言
+
+int main(){
+ DIR *d;//ディレクトリ
+ struct dirent *p; //ディレクトリ内情報(ファイル名、ファイルタイプ)
+
+ d = opendir("/" FSNAME); //ルートディレクトリをオープン
+
+ pc.printf("\nList of files on the flash drive:\r\n");
+
+ if ( d != NULL ) {
+ while ( (p = readdir(d)) != NULL ) { //ルートディレクトリ内情報読み出し
+ pc.printf(" - %s\n", p->d_name); //ファイル名を表示
+ }
+ } else {
+ pc.printf("Could not open directory!\r\n");
+ }
+}
+
+
+
+
+
+
+
+
+
+//d = opendir("/" FSNAME "/web");
+
+
--- a/mbed.bld Mon Jul 30 13:49:56 2012 +0000 +++ b/mbed.bld Wed Jan 20 05:25:16 2021 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/176b8275d35d \ No newline at end of file