37 lines
916 B
Markdown
37 lines
916 B
Markdown
|
|
## Exercise 04: SD Card
|
||
|
|
|
||
|
|
This exercise loops forever. Each cycle:
|
||
|
|
|
||
|
|
1. Prints `Sleeping 10 seconds` and waits 10 seconds.
|
||
|
|
2. Detects and mounts the SD card.
|
||
|
|
3. Prints card and filesystem info (type/size/used).
|
||
|
|
4. Writes `/Exercise_04_test.txt` with:
|
||
|
|
- `This is a test`
|
||
|
|
5. Ensures nested directories exist:
|
||
|
|
- `/test/testsub1/testsubsub1`
|
||
|
|
6. Writes nested file:
|
||
|
|
- `/test/testsub1/testsubsub1/Exercise_04_test.txt`
|
||
|
|
7. If either target file already exists, prints warning, erases it, then recreates it.
|
||
|
|
8. Demonstrates permission behavior:
|
||
|
|
- Notes FAT does not provide Unix `chmod/chown`.
|
||
|
|
- Shows access behavior via `FILE_READ` vs `FILE_WRITE` modes.
|
||
|
|
|
||
|
|
## Build
|
||
|
|
|
||
|
|
```bash
|
||
|
|
source /home/jlpoole/rnsenv/bin/activate
|
||
|
|
pio run -e node_a
|
||
|
|
```
|
||
|
|
|
||
|
|
## Upload
|
||
|
|
|
||
|
|
```bash
|
||
|
|
source /home/jlpoole/rnsenv/bin/activate
|
||
|
|
pio run -e node_a -t upload --upload-port /dev/ttyACM0
|
||
|
|
```
|
||
|
|
|
||
|
|
## Monitor
|
||
|
|
|
||
|
|
```bash
|
||
|
|
screen /dev/ttyACM0 115200
|
||
|
|
```
|