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: FatFileSystemCpp
Diff: usbMemory.cpp
- Revision:
- 8:6e23bf867e38
- Parent:
- 7:a6b950d25e29
- Child:
- 9:280ae971e7cb
diff -r a6b950d25e29 -r 6e23bf867e38 usbMemory.cpp
--- a/usbMemory.cpp Mon Dec 12 02:02:11 2016 +0000
+++ b/usbMemory.cpp Sun Dec 18 08:29:59 2016 +0000
@@ -27,9 +27,20 @@
char buffer[50];
-void usbMemoryInitialize(void)
+/** usb check
+ * @return 0:OK 1:NG
+ */
+int usbMemoryCheck(void)
{
- msc.disk_initialize();
+ return(msc.disk_usbCheck());
+}
+
+/** usb memory initialize
+ * @return 0:OK 1:NG
+ */
+int usbMemoryInitialize(void)
+{
+ return(msc.disk_initialize());
}
/** File check
@@ -63,41 +74,56 @@
}
*fileNumberMax = numMax;
}
+ closedir(d);
return ans;
}
-
-int32_t fileSelect(char *fileName, uint32_t *numberLine)
+/** 指示したfileの行数を取得
+ * @param *fileName : 指示するfile name
+ * @param *numberLine : 取得した行数
+ * @return false:行数取得できず true:処理成功
+ */
+int32_t fileSelect(char *fileName, int32_t *numberLine)
{
uint32_t numMax = 0;
int32_t ans = false;
- DIR *d;
- struct dirent *p;
+ /*
+ DIR *d;
+ struct dirent *p;
- d = opendir("/" FSNAME);
+ d = opendir("/" FSNAME);
+ */
+ // file check
+ sprintf(buffer,"/msc/%s",fileName);
+ fp = fopen( buffer, "r");
- // file check
- sprintf(buffer,"/msc/%s",fileName);
- fp = fopen( buffer, "r");
- if ( fp != NULL ) {
- char buf[256];
- while ( NULL != fgets(buf, sizeof(buf), fp) ) {
- DEBUG_PRINT("%s", buf);
- numMax++;
- }
- *numberLine = numMax;
- fclose(fp);
- ans = true;
+ if ( fp != NULL ) {
+ char buf[256];
+ while ( NULL != fgets(buf, sizeof(buf), fp) ) {
+ DEBUG_PRINT("%s", buf);
+ numMax++;
+ }
+ *numberLine = numMax;
+ ans = true;
- } else {
- // Don't file open
- // nothing
- }
+ } else {
+ // Don't file open
+ // nothing
+ }
+
+ fclose(fp);
return ans;
}
-uint32_t fileOneLineRead(char *fileName, char *data, uint32_t dataNumber, uint32_t numberLine)
+/** 指定した行のデータを取得
+ * @param *fileNmae データを取得するfile Name
+ * @param *data : 取得した行データを格納するバッファ
+ * @param dataNumber : *dataのbyte数
+ * @param numberLine : 取得する行数
+ * @return false:失敗 true:成功
+ */
+uint32_t fileOneLineRead(char *fileName, char *data, int32_t dataNumber, int32_t numberLine)
{
// static FILE *fp;
int32_t ans = false;
@@ -114,7 +140,6 @@
if(NULL != fgets(data, dataNumber, fp)) {
DEBUG_PRINT("line = %s\r\n", data);
- fclose(fp);
ans = true;
} else {
// nothing
@@ -124,6 +149,7 @@
// nothing
}
+ fclose(fp);
return ans;
}