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
3a04d19e
Commit
3a04d19e
authored
Jan 16, 2018
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test scripts to get raw files
parent
673481b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
125 additions
and
1 deletion
+125
-1
Makefile
src/python_tests/Makefile
+3
-1
elphel_framepars.py
src/python_tests/elphel_framepars.py
+54
-0
raw.py
src/python_tests/raw.py
+68
-0
No files found.
src/python_tests/Makefile
View file @
3a04d19e
...
...
@@ -2,7 +2,9 @@ PYTHONROOT=$(DESTDIR)/usr/local/bin
OWN
=
-o
root
-g
root
INSTPYTHON
=
0755
#INSTALL = install
PYTHON_SCRIPTS
=
tests.py
PYTHON_SCRIPTS
=
tests.py
\
elphel_framepars.py
\
raw.py
all
:
@
echo
"make all in python_tests"
...
...
src/python_tests/elphel_framepars.py
0 → 100644
View file @
3a04d19e
# Read frames' parameters. For Elphel NC393 cameras
__copyright__
=
"Copyright 2018, Elphel, Inc."
__license__
=
"GPL-3.0+"
__email__
=
"oleg@elphel.com"
import
mmap
import
struct
class
Pars
:
# parameters
P_WOI_WIDTH
=
26
P_WOI_HEIGHT
=
27
# ...
P_FRAME
=
136
# constants
## frame params queue length
MAX_FRAMES
=
16
## 4 bytes per param
BYTE_MODE
=
4
## params per frame from queue
PARS_SIZE
=
1024
## all mem
MMAP_SIZE
=
MAX_FRAMES
*
BYTE_MODE
*
PARS_SIZE
# bytes
ENDIAN
=
"<"
# little, ">" for big
FRMT_BYTES
=
{
1
:
'B'
,
2
:
'H'
,
4
:
'L'
,
8
:
'Q'
}
FMT
=
ENDIAN
+
FRMT_BYTES
[
BYTE_MODE
]
def
__init__
(
self
,
filename
=
""
):
with
open
(
filename
,
"r+b"
)
as
fp
:
self
.
data
=
mmap
.
mmap
(
fp
.
fileno
(),
self
.
MMAP_SIZE
,
offset
=
0
)
# mmap all data
def
value
(
self
,
param
,
frame
):
offset
=
(
frame
%
self
.
MAX_FRAMES
)
*
self
.
PARS_SIZE
*
self
.
BYTE_MODE
offset
+=
(
param
%
self
.
PARS_SIZE
)
*
self
.
BYTE_MODE
data
=
self
.
data
[
offset
:
offset
+
self
.
BYTE_MODE
]
res
=
struct
.
unpack_from
(
self
.
FMT
,
data
)[
0
]
return
res
#MAIN
if
__name__
==
"__main__"
:
print
(
"Test"
)
a
=
Pars
(
'/dev/frameparsall0'
)
print
(
" port 0, frame #: "
+
format
(
a
.
value
(
Pars
.
P_FRAME
,
0
),
'#08x'
))
print
(
" port 0, frame width: "
+
format
(
a
.
value
(
Pars
.
P_WOI_WIDTH
,
0
),
'#08x'
))
print
(
" port 0, frame height: "
+
format
(
a
.
value
(
Pars
.
P_WOI_HEIGHT
,
0
),
'#08x'
))
src/python_tests/raw.py
0 → 100755
View file @
3a04d19e
#!/usr/bin/env python
from
__future__
import
division
from
__future__
import
print_function
# test and code samples related getting to raw pixels values
__author__
=
"Elphel"
__copyright__
=
"Copyright 2018, Elphel, Inc."
__license__
=
"GPL"
__version__
=
"3.0+"
__maintainer__
=
"Oleg K Dzhimiev"
__email__
=
"oleg@elphel.com"
__status__
=
"Development"
import
mmap
import
struct
import
os
import
sys
import
subprocess
# globals
MEMPATH
=
"/sys/devices/soc0/elphel393-mem@0"
VMEMPATH
=
"/sys/devices/soc0/elphel393-videomem@0"
BUF_PRE
=
MEMPATH
+
"/buffer_pages_raw_chn"
MEM_PRE
=
VMEMPATH
+
"/membridge_start"
VFRAME_PRE
=
VMEMPATH
+
"/video_frame_number"
VMDEV_PRE
=
"/dev/image_raw"
# not used here
MEMSTATUS
=
VMEMPATH
+
"/membridge_status"
# buffer size in 4k pages
# 4096 equals 16MB
# or just calculate based on image sizes
BUF_SIZE
=
4096
# sbuf - buffer in system memory = cpu RAM
# vbuf - buffer in fpga memory = video memory
def
set_sbuf_size
(
port
):
cmd
=
"echo "
+
str
(
BUF_SIZE
)
+
" > "
+
BUF_PRE
+
str
(
port
)
subprocess
.
call
(
cmd
,
shell
=
True
)
def
set_vbuf_position
(
port
,
pos
):
cmd
=
"echo "
+
str
(
pos
)
+
" > "
+
VFRAME_PRE
subprocess
.
call
(
cmd
,
shell
=
True
)
def
copy_vbuf_to_sbuf
(
port
,
frame_number
):
cmd
=
"echo "
+
str
(
frame_number
)
+
" > "
+
MEM_PRE
+
str
(
port
)
subprocess
.
call
(
cmd
,
shell
=
True
)
def
save_pixel_array
(
port
,
fname
):
cmd
=
"cat "
+
VMDEV_PRE
+
str
(
port
)
+
" > "
+
fname
subprocess
.
call
(
cmd
,
shell
=
True
)
print
(
"Memory dumped into "
+
fname
)
# MAIN
for
i
in
range
(
2
):
set_sbuf_size
(
i
)
set_vbuf_position
(
i
,
0
)
copy_vbuf_to_sbuf
(
i
,
0
)
save_pixel_array
(
i
,
"/tmp/port"
+
str
(
i
)
+
".raw"
)
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