Skip to content

Commit

Permalink
LittleFS Python Nav Support (#1259)
Browse files Browse the repository at this point in the history
### Changelist 
<!-- Give a list of the changes covered in this PR. This will help both
you and the reviewer keep this PR within scope. -->
- Added a dependency to Pipenv
- Added script from Jiajun from littlefs-python github repo

### Testing Done
<!-- Outline the testing that was done to demonstrate the changes are
solid. This could be unit tests, integration tests, testing on the car,
etc. Include relevant code snippets, screenshots, etc as needed. -->

### Resolved Tickets
<!-- Link any tickets that this PR resolves. -->
  • Loading branch information
Lucien950 authored May 19, 2024
1 parent 5c6a21a commit ed9911d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ python-can = "*"
rich = "*"
PyGithub = "*"
black = "*"
littlefs-python = "*"
flask = "*"
Definitions = "*"
flask_cors = "*"
Expand Down
34 changes: 34 additions & 0 deletions scripts/windisk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from littlefs import LittleFS, UserContextWinDisk

# number = -1
# with open("2", "rb") as f:
# data = f.read(32)
# # take first 4 bytes
# new_number = int.from_bytes(data[:4], byteorder='little')
# print(new_number)
# if(number + 1 != new_number):
# print("worng number")
# number = new_number

disk_path = r"\\.\D: " # assume F drive is your storage device for littlefs

bc_16g = 30228480
bc_2g = bc_16g // 8
fs = LittleFS(
block_size=512,
block_count=1000000,
mount=False,
context=UserContextWinDisk(disk_path),
)


# fs.format()
fs.mount()

files = fs.listdir("/")
for file in files:
with fs.open(file, "rb") as fh:
with open(file, "wb+") as f:
data = fh.read()
print(data)
f.write(data)

0 comments on commit ed9911d

Please sign in to comment.