Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Open-Cube FW
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Cube
Open-Cube FW
Commits
a1fd1ccd
Commit
a1fd1ccd
authored
1 week ago
by
Václav Jelínek
Browse files
Options
Downloads
Patches
Plain Diff
Add function to check flash storage size and free space
parent
515fa8b0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/robot.py
+8
-0
8 additions, 0 deletions
lib/robot.py
with
8 additions
and
0 deletions
lib/robot.py
+
8
−
0
View file @
a1fd1ccd
import
os
from
micropython
import
const
from
machine
import
Pin
,
I2C
,
Timer
,
WDT
from
time
import
sleep
,
ticks_ms
...
...
@@ -67,6 +68,13 @@ class Robot:
self
.
wdt_feed_timer
=
Timer
(
-
1
)
self
.
wdt_feed_timer
.
init
(
period
=
WDT_FEED_TIMER_PERIOD
,
mode
=
Timer
.
PERIODIC
,
callback
=
self
.
wdt_feed
)
def
storage
(
self
):
fs_stat
=
os
.
statvfs
(
'
/
'
)
total
=
fs_stat
[
0
]
*
fs_stat
[
2
]
# Block size * Total blocks
free
=
fs_stat
[
0
]
*
fs_stat
[
3
]
# Block size * Free blocks
print
(
f
"
Total Flash:
{
total
}
bytes
"
)
print
(
f
"
Free Space:
{
free
}
bytes (
{
free
/
total
*
100
:
.
1
f
}
%)
"
)
# Function called with a timer to feed Watch Dog Timer to prevent rebooting
def
wdt_feed
(
self
,
t
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment