Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-histograms
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-apps-histograms
Commits
7d8023fd
Commit
7d8023fd
authored
Sep 15, 2016
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
corrected mmap range
parent
49227440
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
14 deletions
+31
-14
.gitignore
.gitignore
+1
-0
Makefile
src/Makefile
+7
-2
pnghist.c
src/pnghist.c
+23
-12
No files found.
.gitignore
View file @
7d8023fd
...
...
@@ -12,3 +12,4 @@ bitbake-logs
/temp/
*.o
*.cgi
.depend
src/Makefile
View file @
7d8023fd
...
...
@@ -31,5 +31,10 @@ install: $(PROGS) $(PHPSCRIPTS) $(CONFIGS)
clean
:
rm
-rf
$(PROGS)
*
.o
*
~
#TODO: implement automatic dependencies!
#camogm.c:$(STAGING_DIR_HOST)/usr/include-uapi/elphel/x393_devices.h
depend
:
.depend
.depend
:
$(SRCS)
rm
-f
./.depend
$(CC)
$(CFLAGS)
-MM
$^
>
./.depend
;
include
.depend
src/pnghist.c
View file @
7d8023fd
...
...
@@ -86,6 +86,7 @@ int main(int argc, char *argv[])
{
int
sensor_port
=
0
;
int
subchannel
=
0
;
int
total_hist_entries
;
// =8*4 for 4 sensors
int
fd_histogram_cache
;
struct
histogram_stuct_t
*
histogram_cache
;
/// array of histogram
const
char
histogram_driver_name
[]
=
DEV393_PATH
(
DEV393_HISTOGRAM
);
...
...
@@ -173,27 +174,31 @@ int main(int argc, char *argv[])
fflush
(
stdout
);
return
-
1
;
}
// now try to mmap
histogram_cache
=
(
struct
histogram_stuct_t
*
)
mmap
(
0
,
sizeof
(
struct
histogram_stuct_t
)
*
HISTOGRAM_CACHE_NUMBER
,
PROT_READ
,
MAP_SHARED
,
fd_histogram_cache
,
0
);
if
((
int
)
histogram_cache
==
-
1
)
{
// Select sensor port and subchannel
if
((
sensor_port
<
0
)
||
(
sensor_port
>
3
)
||
(
subchannel
<
0
)
||
(
subchannel
>
3
)){
fprintf
(
stdout
,
"Pragma: no-cache
\n
"
);
fprintf
(
stdout
,
"Content-Type: text/plain
\n\n
"
);
fprintf
(
stdout
,
"
problems with mmap
: %s
\n
"
,
histogram_driver_name
);
fprintf
(
stdout
,
"
Wrong sensor port and/or subchannel number
: %s
\n
"
,
histogram_driver_name
);
fflush
(
stdout
);
return
-
1
;
}
// Select sensor port and subchannel
if
((
sensor_port
<
0
)
||
(
sensor_port
>
3
)
||
(
subchannel
<
0
)
||
(
subchannel
>
3
)){
if
(((
total_hist_entries
=
lseek
(
fd_histogram_cache
,
LSEEK_HIST_SET_CHN
+
(
sensor_port
<<
2
)
+
subchannel
,
SEEK_END
)))
<
0
){
// set port/subchannel to use
fprintf
(
stdout
,
"Pragma: no-cache
\n
"
);
fprintf
(
stdout
,
"Content-Type: text/plain
\n\n
"
);
fprintf
(
stdout
,
"Wrong sensor port and/or subchannel number
: %s
\n
"
,
histogram_driver_name
);
fprintf
(
stdout
,
"port/subchannel combination does not exist
: %s
\n
"
,
histogram_driver_name
);
fflush
(
stdout
);
return
-
1
;
}
if
(((
i
=
lseek
(
fd_histogram_cache
,
LSEEK_HIST_SET_CHN
+
(
sensor_port
<<
2
)
+
subchannel
,
SEEK_END
)))
<
0
){
// set port/subchannel to use
#ifdef THIS_DEBUG
fprintf
(
stderr
,
"LSEEK_HIST_SET_CHN port = %d chn = %d - > 0x%x
\n
"
,
sensor_port
,
subchannel
,
total_hist_entries
);
fflush
(
stderr
);
#endif
// now try to mmap
histogram_cache
=
(
struct
histogram_stuct_t
*
)
mmap
(
0
,
sizeof
(
struct
histogram_stuct_t
)
*
total_hist_entries
,
PROT_READ
,
MAP_SHARED
,
fd_histogram_cache
,
0
);
if
((
int
)
histogram_cache
==
-
1
)
{
fprintf
(
stdout
,
"Pragma: no-cache
\n
"
);
fprintf
(
stdout
,
"Content-Type: text/plain
\n\n
"
);
fprintf
(
stdout
,
"port/subchannel combination does not exist
: %s
\n
"
,
histogram_driver_name
);
fprintf
(
stdout
,
"problems with mmap
: %s
\n
"
,
histogram_driver_name
);
fflush
(
stdout
);
return
-
1
;
}
...
...
@@ -224,6 +229,12 @@ int main(int argc, char *argv[])
fflush
(
stdout
);
return
-
1
;
}
#ifdef THIS_DEBUG
fprintf
(
stderr
,
"hist_index = 0x%x
\n
"
,
hist_index
);
fflush
(
stderr
);
#endif
/// Ignore missing histograms here
// ww=(ww*autoexp.width)/100;
// wh=(wh*autoexp.height)/100;
...
...
@@ -298,7 +309,7 @@ int main(int argc, char *argv[])
for
(
i
=
0
;
i
<
1024
;
i
++
)
{
if
((
i
&
0x0ff
)
==
0
)
fprintf
(
stderr
,
"
\n
"
);
if
((
i
&
0x0f
)
==
0
)
fprintf
(
stderr
,
"
\n
0x%03x:"
,
i
);
fprintf
(
stderr
,
" %0
4
x"
,
hists
[
i
]);
fprintf
(
stderr
,
" %0
5
x"
,
hists
[
i
]);
}
fprintf
(
stderr
,
"
\n\n\n
"
);
#endif
...
...
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