Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-web-393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-web-393
Commits
883d6ed0
Commit
883d6ed0
authored
Jan 16, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tested mmap
parent
3a04d19e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
2 deletions
+45
-2
raw.py
src/python_tests/raw.py
+45
-2
No files found.
src/python_tests/raw.py
View file @
883d6ed0
...
@@ -19,6 +19,8 @@ import os
...
@@ -19,6 +19,8 @@ import os
import
sys
import
sys
import
subprocess
import
subprocess
MMAP_DATA
=
True
# globals
# globals
MEMPATH
=
"/sys/devices/soc0/elphel393-mem@0"
MEMPATH
=
"/sys/devices/soc0/elphel393-mem@0"
VMEMPATH
=
"/sys/devices/soc0/elphel393-videomem@0"
VMEMPATH
=
"/sys/devices/soc0/elphel393-videomem@0"
...
@@ -36,6 +38,7 @@ MEMSTATUS = VMEMPATH+"/membridge_status"
...
@@ -36,6 +38,7 @@ MEMSTATUS = VMEMPATH+"/membridge_status"
# or just calculate based on image sizes
# or just calculate based on image sizes
BUF_SIZE
=
4096
BUF_SIZE
=
4096
PAGE_SIZE
=
4096
# sbuf - buffer in system memory = cpu RAM
# sbuf - buffer in system memory = cpu RAM
# vbuf - buffer in fpga memory = video memory
# vbuf - buffer in fpga memory = video memory
...
@@ -57,12 +60,52 @@ def save_pixel_array(port,fname):
...
@@ -57,12 +60,52 @@ def save_pixel_array(port,fname):
subprocess
.
call
(
cmd
,
shell
=
True
)
subprocess
.
call
(
cmd
,
shell
=
True
)
print
(
"Memory dumped into "
+
fname
)
print
(
"Memory dumped into "
+
fname
)
def
mmap_pixel_array
(
port
,
size
):
with
open
(
VMDEV_PRE
+
str
(
port
),
"r+b"
)
as
fp
:
data
=
mmap
.
mmap
(
fp
.
fileno
(),
size
,
offset
=
0
)
# mmap all data
return
data
def
get_byte
(
data
,
i
):
return
struct
.
unpack_from
(
">B"
,
data
[
i
])[
0
]
def
get_byte_str
(
data
,
i
):
res
=
get_byte
(
data
,
i
)
#return str(hex(res))
return
"{:02x}"
.
format
(
res
)
#return format(get_byte(data,i),'#02x')
# MAIN
# MAIN
mmap_data
=
[]
for
i
in
range
(
2
):
for
i
in
range
(
2
):
set_sbuf_size
(
i
)
set_sbuf_size
(
i
)
set_vbuf_position
(
i
,
0
)
set_vbuf_position
(
i
,
0
)
copy_vbuf_to_sbuf
(
i
,
0
)
copy_vbuf_to_sbuf
(
i
,
0
)
if
MMAP_DATA
:
mmap_data
.
append
(
mmap_pixel_array
(
i
,
BUF_SIZE
*
PAGE_SIZE
))
# print the first 16 bytes only
print
(
" "
.
join
(
"{:02x}"
.
format
(
get_byte
(
mmap_data
[
i
],
c
))
for
c
in
range
(
16
)))
# test: hexdump -C /dev/image_raw0
else
:
save_pixel_array
(
i
,
"/tmp/port"
+
str
(
i
)
+
".raw"
)
save_pixel_array
(
i
,
"/tmp/port"
+
str
(
i
)
+
".raw"
)
print
(
"Now scp raw files to pc and run bayer2rgb
\n
"
)
if
not
MMAP_DATA
:
print
(
"Now scp raw files to pc and run bayer2rgb
\n
"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment