バックナンバーはこちら。
https://www.simulationroom999.com/blog/In-vehicle-external-storage-backnumber/
はじめに
FatFs WinシミュレーションでSDカードに直接制御する話。
今回は「FatFsでファイル書き込みとWindowsでの認識」の後半でFatFsで作成したファイルをWindows側から確認できるか。
登場人物
博識フクロウのフクさん

イラストACにて公開の「kino_k」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=iKciwKA9&area=1
エンジニア歴8年の太郎くん

イラストACにて公開の「しのみ」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=uCKphAW2&area=1
実験手順

想定実験手順は以下。
今回は「FatFsでファイル書き込みとWindowsでの認識」の後半。
- FatFs改造方針を考える
- FatFs改造
- FatFsでSDカードのFAT認識
- FatFsでファイル書き込みとWindowsでの認識 ← これの2回目/全2回
- FatFsでFAT32フォーマットしてWindowsで認識

そして、全体構成


まぁ今回は難しい話は無くて、FatFsで作成したファイルを確認するだけだねー。

早速確認してみよう。
前回作ったファイル

まず、前回FatFs側で作成したファイルはこんな感じだ。
>fo 6 long_file_name_file_by_fatfs_to_sdcard.txt
rc=0 FR_OK
>fw 20000 0x64
20000 bytes written.
>fc
rc=0 FR_OK
>fl
D-HS- 2021/04/16 16:04 0 System Volume Information
----A 2021/04/16 16:05 11200 long_file_name_file.txt
----A 2021/04/20 20:18 10000 long_file_name_file_by_fatfs.txt
----A 2021/05/12 16:48 20000 long_file_name_file_by_fatfs_to_sdcard.txt
3 File(s), 41200 bytes total
1 Dir(s), 43606016 bytes free
>fo 1 long_file_name_file_by_fatfs_to_sdcard.txt
rc=0 FR_OK
>fd
00000000: 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 dddddddddddddddd
00000010: 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 dddddddddddddddd
00000020: 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 dddddddddddddddd
00000030: 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 dddddddddddddddd
00000040: 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 dddddddddddddddd
00000050: 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 dddddddddddddddd
00000060: 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 dddddddddddddddd
00000070: 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 dddddddddddddddd
>fc
rc=0 FR_OK
>

「long_file_name_file_by_fatfs_to_sdcard.txt」というファイル名で
0x64こと‘d’が20000byte分書かれていればOKってことだね。
Windows側でファイル確認

じゃ、WindowsでSDカードの中身を見てみよう。


お!
「long_file_name_file_by_fatfs_to_sdcard.txt」ってファイルが出来てる!

そして、サイズも20KBだからあってそう!

そして、「long_file_name_file_by_fatfs_to_sdcard.txt」の中身。


こんな感じで’d’が20000文字続いてる。

バッチリだ!

いや、しかし理屈上はできるってことだったけど、
実際に見ると不思議だよねー。
無理やりSDカードアクセスしたものがWindows側で確認できるなんて。

概念上は組み込み機器にささったSDカードにファイルを出力して
それをWindowsで見た。
ってのと一緒だからね。

まぁ出来て当たり前の話なのかもしれないけど、
それが結構大変そうってのが良く分かった。
まとめ

まとめだよ。
- 前回FatFsで作成したファイルの確認。
- ファイル名:long_file_name_file_by_fatfs_to_sdcard.txt
- ファイルサイズ:20000byte
- 内容:’d’を連続で20000文字
- Windows上でファイルの確認。
- 問題無くファイルを確認できた。
バックナンバーはこちら。
コメント