Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
fbca4f94
Commit
fbca4f94
authored
8 years ago
by
Alex March
Committed by
Damien George
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
tests/extmod/vfs_fat_oldproto: Test old block device protocol.
parent
38a93593
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/extmod/vfs_fat_oldproto.py
+61
-0
61 additions, 0 deletions
tests/extmod/vfs_fat_oldproto.py
tests/extmod/vfs_fat_oldproto.py.exp
+4
-0
4 additions, 0 deletions
tests/extmod/vfs_fat_oldproto.py.exp
with
65 additions
and
0 deletions
tests/extmod/vfs_fat_oldproto.py
0 → 100644
+
61
−
0
View file @
fbca4f94
import
sys
import
uos
import
uerrno
try
:
uos
.
VfsFat
except
AttributeError
:
print
(
"
SKIP
"
)
sys
.
exit
()
class
RAMFS_OLD
:
SEC_SIZE
=
512
def
__init__
(
self
,
blocks
):
self
.
data
=
bytearray
(
blocks
*
self
.
SEC_SIZE
)
def
readblocks
(
self
,
n
,
buf
):
#print("readblocks(%s, %x(%d))" % (n, id(buf), len(buf)))
for
i
in
range
(
len
(
buf
)):
buf
[
i
]
=
self
.
data
[
n
*
self
.
SEC_SIZE
+
i
]
def
writeblocks
(
self
,
n
,
buf
):
#print("writeblocks(%s, %x)" % (n, id(buf)))
for
i
in
range
(
len
(
buf
)):
self
.
data
[
n
*
self
.
SEC_SIZE
+
i
]
=
buf
[
i
]
def
sync
(
self
):
pass
def
count
(
self
):
return
len
(
self
.
data
)
//
self
.
SEC_SIZE
try
:
bdev
=
RAMFS_OLD
(
48
)
except
MemoryError
:
print
(
"
SKIP
"
)
sys
.
exit
()
uos
.
vfs_mkfs
(
bdev
,
"
/ramdisk
"
)
uos
.
vfs_mount
(
bdev
,
"
/ramdisk
"
)
# file io
vfs
=
uos
.
VfsFat
(
bdev
,
"
/ramdisk
"
)
with
vfs
.
open
(
"
file.txt
"
,
"
w
"
)
as
f
:
f
.
write
(
"
hello!
"
)
print
(
vfs
.
listdir
())
with
vfs
.
open
(
"
file.txt
"
,
"
r
"
)
as
f
:
print
(
f
.
read
())
vfs
.
remove
(
"
file.txt
"
)
print
(
vfs
.
listdir
())
# umount by device
uos
.
vfs_umount
(
bdev
)
try
:
vfs
.
listdir
()
except
OSError
as
e
:
print
(
e
.
args
[
0
]
==
uerrno
.
ENODEV
)
This diff is collapsed.
Click to expand it.
tests/extmod/vfs_fat_oldproto.py.exp
0 → 100644
+
4
−
0
View file @
fbca4f94
['file.txt']
hello!
[]
True
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