Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-camogm
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-camogm
Commits
63bf56d0
Commit
63bf56d0
authored
Jun 29, 2016
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process commands in a thread
parent
73ecbfc7
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
293 additions
and
83 deletions
+293
-83
camogm.c
camogm.c
+9
-5
camogm.h
camogm.h
+3
-0
camogm_read.c
camogm_read.c
+279
-77
camogm_read.h
camogm_read.h
+2
-1
No files found.
camogm.c
View file @
63bf56d0
...
@@ -231,6 +231,7 @@ void camogm_init(camogm_state *state, char *pipe_name)
...
@@ -231,6 +231,7 @@ void camogm_init(camogm_state *state, char *pipe_name)
state
->
rawdev
.
curr_pos_w
=
state
->
rawdev
.
start_pos
;
state
->
rawdev
.
curr_pos_w
=
state
->
rawdev
.
start_pos
;
state
->
rawdev
.
curr_pos_r
=
state
->
rawdev
.
start_pos
;
state
->
rawdev
.
curr_pos_r
=
state
->
rawdev
.
start_pos
;
state
->
active_chn
=
ALL_CHN_ACTIVE
;
state
->
active_chn
=
ALL_CHN_ACTIVE
;
state
->
rawdev
.
mmap_size
=
MMAP_CHUNK_SIZE
;
}
}
/**
/**
...
@@ -802,7 +803,7 @@ void camogm_set_prefix(camogm_state *state, const char * p, path_type type)
...
@@ -802,7 +803,7 @@ void camogm_set_prefix(camogm_state *state, const char * p, path_type type)
D0
(
fprintf
(
debug_file
,
"WARNING: raw device write initiated
\n
"
));
D0
(
fprintf
(
debug_file
,
"WARNING: raw device write initiated
\n
"
));
state
->
rawdev_op
=
1
;
state
->
rawdev_op
=
1
;
/* debug code follows */
/* debug code follows */
//
state->rawdev.end_pos = 10485760; // 10 Mib
state
->
rawdev
.
end_pos
=
10485760
;
// 10 Mib
/* end of debug code */
/* end of debug code */
}
}
}
}
...
@@ -954,6 +955,8 @@ void camogm_status(camogm_state *state, char * fn, int xml)
...
@@ -954,6 +955,8 @@ void camogm_status(camogm_state *state, char * fn, int xml)
case
STATE_READING
:
case
STATE_READING
:
_state
=
"reading"
;
_state
=
"reading"
;
break
;
break
;
default:
_state
=
"stopped"
;
}
}
_output_format
=
state
->
format
?
((
state
->
format
==
CAMOGM_FORMAT_OGM
)
?
"ogm"
:
_output_format
=
state
->
format
?
((
state
->
format
==
CAMOGM_FORMAT_OGM
)
?
"ogm"
:
((
state
->
format
==
CAMOGM_FORMAT_JPEG
)
?
"jpeg"
:
((
state
->
format
==
CAMOGM_FORMAT_JPEG
)
?
"jpeg"
:
...
@@ -1006,7 +1009,7 @@ void camogm_status(camogm_state *state, char * fn, int xml)
...
@@ -1006,7 +1009,7 @@ void camogm_status(camogm_state *state, char * fn, int xml)
" <raw_device_path>
\"
%s
\"
</raw_device_path>
\n
"
\
" <raw_device_path>
\"
%s
\"
</raw_device_path>
\n
"
\
" <raw_device_overruns>%d</raw_device_overruns>
\n
"
\
" <raw_device_overruns>%d</raw_device_overruns>
\n
"
\
" <raw_device_pos_write>0x%llx</raw_dev_pos_write>
\n
"
\
" <raw_device_pos_write>0x%llx</raw_dev_pos_write>
\n
"
\
" <raw_device_pos_read>0x%llx (%d
\
% done)</raw_device_pos_read>
\n
"
,
" <raw_device_pos_read>0x%llx (%d
%
% done)</raw_device_pos_read>
\n
"
,
_state
,
state
->
path
,
state
->
frameno
,
state
->
start_after_timestamp
,
_dur
,
_udur
,
_len
,
\
_state
,
state
->
path
,
state
->
frameno
,
state
->
start_after_timestamp
,
_dur
,
_udur
,
_len
,
\
_frames_skip
,
_sec_skip
,
\
_frames_skip
,
_sec_skip
,
\
state
->
width
,
state
->
height
,
_output_format
,
_using_exif
,
\
state
->
width
,
state
->
height
,
_output_format
,
_using_exif
,
\
...
@@ -1067,7 +1070,7 @@ void camogm_status(camogm_state *state, char * fn, int xml)
...
@@ -1067,7 +1070,7 @@ void camogm_status(camogm_state *state, char * fn, int xml)
fprintf
(
f
,
"raw device overruns
\t
%d
\n
"
,
state
->
rawdev
.
overrun
);
fprintf
(
f
,
"raw device overruns
\t
%d
\n
"
,
state
->
rawdev
.
overrun
);
fprintf
(
f
,
"raw write position
\t
0x%llx
\n
"
,
state
->
rawdev
.
curr_pos_w
);
fprintf
(
f
,
"raw write position
\t
0x%llx
\n
"
,
state
->
rawdev
.
curr_pos_w
);
fprintf
(
f
,
"raw read position
\t
0x%llx
\n
"
,
state
->
rawdev
.
curr_pos_r
);
fprintf
(
f
,
"raw read position
\t
0x%llx
\n
"
,
state
->
rawdev
.
curr_pos_r
);
fprintf
(
f
,
" percent done
\t
%d
\
%
\n
"
,
_percent_done
);
fprintf
(
f
,
" percent done
\t
%d
%
%
\n
"
,
_percent_done
);
fprintf
(
f
,
"max file duration
\t
%d sec
\n
"
,
state
->
segment_duration
);
fprintf
(
f
,
"max file duration
\t
%d sec
\n
"
,
state
->
segment_duration
);
fprintf
(
f
,
"max file length
\t
%d B
\n
"
,
state
->
segment_length
);
fprintf
(
f
,
"max file length
\t
%d B
\n
"
,
state
->
segment_length
);
fprintf
(
f
,
"max frames
\t
%d
\n
"
,
state
->
max_frames
);
fprintf
(
f
,
"max frames
\t
%d
\n
"
,
state
->
max_frames
);
...
@@ -1498,7 +1501,7 @@ int listener_loop(camogm_state *state)
...
@@ -1498,7 +1501,7 @@ int listener_loop(camogm_state *state)
state
->
rawdev
.
thread_finished
=
false
;
state
->
rawdev
.
thread_finished
=
false
;
state
->
prog_state
=
STATE_STOPPED
;
state
->
prog_state
=
STATE_STOPPED
;
pthread_join
(
state
->
rawdev
.
tid
,
&
tret
);
pthread_join
(
state
->
rawdev
.
tid
,
&
tret
);
if
((
int
)
tret
!=
0
&&
(
int
)
tret
!=
PTHREAD_CANCELED
)
{
if
((
int
)
tret
!=
0
&&
(
int
)
tret
!=
(
int
)
PTHREAD_CANCELED
)
{
D0
(
fprintf
(
debug_file
,
"Reading thread returned error %d
\n
"
,
(
int
)
tret
));
D0
(
fprintf
(
debug_file
,
"Reading thread returned error %d
\n
"
,
(
int
)
tret
));
}
else
{
}
else
{
D3
(
fprintf
(
debug_file
,
"Reading thread stopped
\n
"
));
D3
(
fprintf
(
debug_file
,
"Reading thread stopped
\n
"
));
...
@@ -1509,7 +1512,8 @@ int listener_loop(camogm_state *state)
...
@@ -1509,7 +1512,8 @@ int listener_loop(camogm_state *state)
}
else
if
(
state
->
rawdev
.
thread_state
==
STATE_STOPPED
)
{
}
else
if
(
state
->
rawdev
.
thread_state
==
STATE_STOPPED
)
{
state
->
rawdev
.
thread_state
=
STATE_RUNNING
;
state
->
rawdev
.
thread_state
=
STATE_RUNNING
;
state
->
rawdev
.
thread_finished
=
false
;
state
->
rawdev
.
thread_finished
=
false
;
if
(
pthread_create
(
&
state
->
rawdev
.
tid
,
NULL
,
build_index
,
state
)
!=
0
)
{
// if (pthread_create(&state->rawdev.tid, NULL, build_index, state) != 0) {
if
(
pthread_create
(
&
state
->
rawdev
.
tid
,
NULL
,
reader
,
state
)
!=
0
)
{
state
->
prog_state
=
STATE_STOPPED
;
state
->
prog_state
=
STATE_STOPPED
;
state
->
rawdev
.
thread_state
=
STATE_STOPPED
;
state
->
rawdev
.
thread_state
=
STATE_STOPPED
;
D0
(
fprintf
(
debug_file
,
"%s:line %d: Can not start new thread, disk index is not built
\n
"
,
__FILE__
,
__LINE__
));
D0
(
fprintf
(
debug_file
,
"%s:line %d: Can not start new thread, disk index is not built
\n
"
,
__FILE__
,
__LINE__
));
...
...
camogm.h
View file @
63bf56d0
...
@@ -60,6 +60,7 @@
...
@@ -60,6 +60,7 @@
#define RAWDEV_START_OFFSET 1024
#define RAWDEV_START_OFFSET 1024
/** @brief Maximum length of file or raw device path */
/** @brief Maximum length of file or raw device path */
#define ELPHEL_PATH_MAX 300
#define ELPHEL_PATH_MAX 300
#define MMAP_CHUNK_SIZE 134217728
/**
/**
* @enum state_flags
* @enum state_flags
...
@@ -99,6 +100,8 @@ typedef struct {
...
@@ -99,6 +100,8 @@ typedef struct {
uint64_t
start_pos
;
uint64_t
start_pos
;
uint64_t
end_pos
;
uint64_t
end_pos
;
uint64_t
curr_pos_w
;
uint64_t
curr_pos_w
;
uint64_t
*
disk_mmap
;
uint64_t
mmap_size
;
volatile
uint64_t
curr_pos_r
;
volatile
uint64_t
curr_pos_r
;
uint64_t
file_start
;
uint64_t
file_start
;
pthread_t
tid
;
pthread_t
tid
;
...
...
camogm_read.c
View file @
63bf56d0
This diff is collapsed.
Click to expand it.
camogm_read.h
View file @
63bf56d0
...
@@ -23,7 +23,7 @@ struct disk_index {
...
@@ -23,7 +23,7 @@ struct disk_index {
struct
disk_index
*
next
;
struct
disk_index
*
next
;
struct
disk_index
*
prev
;
struct
disk_index
*
prev
;
time_t
rawtime
;
time_t
rawtime
;
u
seconds_
t
usec
;
u
nsigned
in
t
usec
;
uint32_t
port
;
uint32_t
port
;
size_t
f_size
;
size_t
f_size
;
uint64_t
f_offset
;
uint64_t
f_offset
;
...
@@ -36,5 +36,6 @@ struct disk_idir {
...
@@ -36,5 +36,6 @@ struct disk_idir {
};
};
void
*
build_index
(
void
*
arg
);
void
*
build_index
(
void
*
arg
);
void
*
reader
(
void
*
arg
);
#endif
/* _CAMOGM_READ_H */
#endif
/* _CAMOGM_READ_H */
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