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
ba98b0cf
Commit
ba98b0cf
authored
Jun 28, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working version with 2 parallel write threads
parent
bff5f99c
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1087 additions
and
392 deletions
+1087
-392
camogm.c
src/camogm.c
+346
-125
camogm.h
src/camogm.h
+58
-20
camogm_align.c
src/camogm_align.c
+79
-59
camogm_align.h
src/camogm_align.h
+1
-0
camogm_jpeg.c
src/camogm_jpeg.c
+570
-177
camogm_jpeg.h
src/camogm_jpeg.h
+5
-1
camogm_read.c
src/camogm_read.c
+22
-5
camogm_interface.php
src/camogmgui/camogm_interface.php
+6
-5
No files found.
src/camogm.c
View file @
ba98b0cf
This diff is collapsed.
Click to expand it.
src/camogm.h
View file @
ba98b0cf
This diff is collapsed.
Click to expand it.
src/camogm_align.c
View file @
ba98b0cf
This diff is collapsed.
Click to expand it.
src/camogm_align.h
View file @
ba98b0cf
...
@@ -49,6 +49,7 @@ void deinit_align_buffers(camogm_state *state);
...
@@ -49,6 +49,7 @@ void deinit_align_buffers(camogm_state *state);
void
reset_segments
(
camogm_state
*
state
,
int
all
,
int
page
);
void
reset_segments
(
camogm_state
*
state
,
int
all
,
int
page
);
size_t
remap_vectors
(
camogm_state
*
state
);
//, struct iovec *chunks);
size_t
remap_vectors
(
camogm_state
*
state
);
//, struct iovec *chunks);
uint64_t
lba_to_offset
(
uint64_t
lba
);
uint64_t
lba_to_offset
(
uint64_t
lba
);
uint64_t
get_lba_next
(
const
struct
writer_params
*
params
);
int
vectaligntail
(
struct
iovec
*
dest
);
int
vectaligntail
(
struct
iovec
*
dest
);
...
...
src/camogm_jpeg.c
View file @
ba98b0cf
This diff is collapsed.
Click to expand it.
src/camogm_jpeg.h
View file @
ba98b0cf
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#ifndef _CAMOGM_JPEG_H
#ifndef _CAMOGM_JPEG_H
#define _CAMOGM_JPEG_H
#define _CAMOGM_JPEG_H
#define __USE_GNU // for O_DIRECT
//
#define __USE_GNU // for O_DIRECT
#include "camogm.h"
#include "camogm.h"
...
@@ -28,6 +28,10 @@ int camogm_end_jpeg(camogm_state *state);
...
@@ -28,6 +28,10 @@ int camogm_end_jpeg(camogm_state *state);
void
camogm_free_jpeg
(
camogm_state
*
state
);
void
camogm_free_jpeg
(
camogm_state
*
state
);
int
open_state_file
(
const
rawdev_buffer
*
rawdev
,
uint64_t
*
current_pos
);
int
open_state_file
(
const
rawdev_buffer
*
rawdev
,
uint64_t
*
current_pos
);
ssize_t
emul_writev
(
int
fd
,
const
struct
iovec
*
iovec
,
int
count
);
ssize_t
emul_writev
(
int
fd
,
const
struct
iovec
*
iovec
,
int
count
);
int
get_write_page
(
struct
writer_params
*
wparams
);
int
get_num_empty
(
struct
writer_params
*
wparams
);
int
get_num_busy
(
struct
writer_params
*
wparams
);
#endif
/* _CAMOGM_JPEG_H */
#endif
/* _CAMOGM_JPEG_H */
src/camogm_read.c
View file @
ba98b0cf
...
@@ -1023,6 +1023,9 @@ void *reader(void *arg)
...
@@ -1023,6 +1023,9 @@ void *reader(void *arg)
memset
(
&
index_sparse
,
0
,
sizeof
(
struct
disk_idir
));
memset
(
&
index_sparse
,
0
,
sizeof
(
struct
disk_idir
));
prep_socket
(
&
sockfd
,
state
->
sock_port
);
prep_socket
(
&
sockfd
,
state
->
sock_port
);
D2
(
syslog
(
LOG_INFO
,
"%s:line %d : Started reader thread ID=%ld @ %07d"
,
\
__FILE__
,
__LINE__
,
pthread_self
(),
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
)));
pthread_cleanup_push
(
exit_thread
,
&
exit_state
);
pthread_cleanup_push
(
exit_thread
,
&
exit_state
);
while
(
true
)
{
while
(
true
)
{
fd
=
accept
(
sockfd
,
NULL
,
0
);
fd
=
accept
(
sockfd
,
NULL
,
0
);
...
@@ -1041,8 +1044,13 @@ void *reader(void *arg)
...
@@ -1041,8 +1044,13 @@ void *reader(void *arg)
cmd_ptr
=
cmd_buff
;
cmd_ptr
=
cmd_buff
;
trim_command
(
cmd_ptr
,
cmd_len
);
trim_command
(
cmd_ptr
,
cmd_len
);
while
((
cmd
=
parse_command
(
&
cmd_ptr
))
!=
-
2
&&
state
->
rawdev
.
thread_state
!=
STATE_CANCEL
)
{
while
((
cmd
=
parse_command
(
&
cmd_ptr
))
!=
-
2
&&
state
->
rawdev
.
thread_state
!=
STATE_CANCEL
)
{
if
(
cmd
>=
0
)
D2
(
syslog
(
LOG_INFO
,
"%s:line %d : Got reader command '%s', number %d @ %07d"
,
\
D6
(
fprintf
(
debug_file
,
"Got command '%s', number %d
\n
"
,
cmd_list
[
cmd
],
cmd
));
__FILE__
,
__LINE__
,
cmd_list
[
cmd
],
cmd
,
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
)));
D2
(
fprintf
(
debug_file
,
"%s:line %d : Got reader command '%s', number %d @ %07d
\n
"
,
\
__FILE__
,
__LINE__
,
cmd_list
[
cmd
],
cmd
,
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
)));
// if (cmd >= 0) {
// D6(fprintf(debug_file, "Got command '%s', number %d\n", cmd_list[cmd], cmd));
// }
switch
(
cmd
)
{
switch
(
cmd
)
{
case
CMD_BUILD_INDEX
:
case
CMD_BUILD_INDEX
:
// scan raw device buffer and create disk index directory
// scan raw device buffer and create disk index directory
...
@@ -1050,7 +1058,7 @@ void *reader(void *arg)
...
@@ -1050,7 +1058,7 @@ void *reader(void *arg)
delete_idir
(
&
index_dir
);
delete_idir
(
&
index_dir
);
}
}
build_index
(
state
,
&
index_dir
);
build_index
(
state
,
&
index_dir
);
D
3
(
fprintf
(
debug_file
,
"%d files read from %s
\n
"
,
index_dir
.
size
,
state
->
rawdev
.
rawdev_path
));
D
2
(
fprintf
(
debug_file
,
"%d files read from %s
\n
"
,
index_dir
.
size
,
state
->
rawdev
.
rawdev_path
));
break
;
break
;
case
CMD_GET_INDEX
:
case
CMD_GET_INDEX
:
// send the content of disk index directory over socket
// send the content of disk index directory over socket
...
@@ -1073,6 +1081,7 @@ void *reader(void *arg)
...
@@ -1073,6 +1081,7 @@ void *reader(void *arg)
// mmap raw device buffer in MMAP_CHUNK_SIZE chunks and send them over socket
// mmap raw device buffer in MMAP_CHUNK_SIZE chunks and send them over socket
mmap_range
.
from
=
rawdev
->
start_pos
&
PAGE_BOUNDARY_MASK
;
mmap_range
.
from
=
rawdev
->
start_pos
&
PAGE_BOUNDARY_MASK
;
mmap_range
.
to
=
mmap_range
.
from
+
rawdev
->
mmap_default_size
;
mmap_range
.
to
=
mmap_range
.
from
+
rawdev
->
mmap_default_size
;
D2
(
fprintf
(
debug_file
,
"CMD_READ_DISK from = %llu, to=%llu files read from %s
\n
"
,
mmap_range
.
from
,
mmap_range
.
to
,
state
->
rawdev
.
rawdev_path
));
disk_chunks
=
(
size_t
)
ceil
((
double
)(
rawdev
->
end_pos
-
rawdev
->
start_pos
)
/
(
double
)
rawdev
->
mmap_default_size
);
disk_chunks
=
(
size_t
)
ceil
((
double
)(
rawdev
->
end_pos
-
rawdev
->
start_pos
)
/
(
double
)
rawdev
->
mmap_default_size
);
transfer
=
true
;
transfer
=
true
;
mm_file_start
=
rawdev
->
start_pos
;
mm_file_start
=
rawdev
->
start_pos
;
...
@@ -1105,6 +1114,7 @@ void *reader(void *arg)
...
@@ -1105,6 +1114,7 @@ void *reader(void *arg)
}
}
break
;
break
;
case
CMD_READ_FILE
:
case
CMD_READ_FILE
:
D2
(
fprintf
(
debug_file
,
"CMD_READ_FILE from %s
\n
"
,
state
->
rawdev
.
rawdev_path
));
// read single file by offset given
// read single file by offset given
if
(
index_dir
.
size
>
0
)
{
if
(
index_dir
.
size
>
0
)
{
struct
disk_index
indx
;
struct
disk_index
indx
;
...
@@ -1116,6 +1126,7 @@ void *reader(void *arg)
...
@@ -1116,6 +1126,7 @@ void *reader(void *arg)
break
;
break
;
case
CMD_FIND_FILE
:
{
case
CMD_FIND_FILE
:
{
// find file by time stamp
// find file by time stamp
D2
(
fprintf
(
debug_file
,
"CMD_FIND_FILE from %s
\n
"
,
state
->
rawdev
.
rawdev_path
));
struct
disk_index
indx
;
struct
disk_index
indx
;
struct
disk_index
*
indx_ptr
=
NULL
;
struct
disk_index
*
indx_ptr
=
NULL
;
if
(
get_timestamp_args
(
cmd_ptr
,
&
indx
)
>
0
)
{
if
(
get_timestamp_args
(
cmd_ptr
,
&
indx
)
>
0
)
{
...
@@ -1133,6 +1144,7 @@ void *reader(void *arg)
...
@@ -1133,6 +1144,7 @@ void *reader(void *arg)
}
}
case
CMD_NEXT_FILE
:
{
case
CMD_NEXT_FILE
:
{
// read next file after previously found file
// read next file after previously found file
D2
(
fprintf
(
debug_file
,
"CMD_NEXT_FILE from %s
\n
"
,
state
->
rawdev
.
rawdev_path
));
struct
range
rng
;
struct
range
rng
;
struct
disk_index
*
new_indx
=
NULL
;
struct
disk_index
*
new_indx
=
NULL
;
struct
disk_index
*
indx_ptr
=
NULL
;
struct
disk_index
*
indx_ptr
=
NULL
;
...
@@ -1166,11 +1178,13 @@ void *reader(void *arg)
...
@@ -1166,11 +1178,13 @@ void *reader(void *arg)
break
;
break
;
}
}
case
CMD_PREV_FILE
:
{
case
CMD_PREV_FILE
:
{
D2
(
fprintf
(
debug_file
,
"CMD_PREV_FILE from %s
\n
"
,
state
->
rawdev
.
rawdev_path
));
break
;
break
;
}
}
case
CMD_READ_ALL_FILES
:
case
CMD_READ_ALL_FILES
:
// read files from raw device buffer and send them over socket; the disk index directory
// read files from raw device buffer and send them over socket; the disk index directory
// should be built beforehand
// should be built beforehand
D2
(
fprintf
(
debug_file
,
"CMD_READ_ALL_FILES from %s
\n
"
,
state
->
rawdev
.
rawdev_path
));
if
(
index_dir
.
size
>
0
)
{
if
(
index_dir
.
size
>
0
)
{
send_fnum
(
fd
,
index_dir
.
size
);
send_fnum
(
fd
,
index_dir
.
size
);
close
(
fd
);
close
(
fd
);
...
@@ -1235,7 +1249,10 @@ void *reader(void *arg)
...
@@ -1235,7 +1249,10 @@ void *reader(void *arg)
usleep
(
COMMAND_LOOP_DELAY
);
usleep
(
COMMAND_LOOP_DELAY
);
}
}
pthread_cleanup_pop
(
0
);
pthread_cleanup_pop
(
0
);
D2
(
fprintf
(
debug_file
,
"%s:line %d : Exited reader thread ID=%ld @ %07d
\n
"
,
\
__FILE__
,
__LINE__
,
pthread_self
(),
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
)));
D2
(
syslog
(
LOG_INFO
,
"%s:line %d : Exited reader thread ID=%ld @ %07d"
,
\
__FILE__
,
__LINE__
,
pthread_self
(),
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
)));
return
(
void
*
)
0
;
return
(
void
*
)
0
;
}
}
...
@@ -1296,7 +1313,7 @@ static void build_index(camogm_state *state, struct disk_idir *idir)
...
@@ -1296,7 +1313,7 @@ static void build_index(camogm_state *state, struct disk_idir *idir)
uint64_t
include_st_marker
,
include_en_marker
;
uint64_t
include_st_marker
,
include_en_marker
;
size_t
add_stm_len
,
add_enm_len
;
size_t
add_stm_len
,
add_enm_len
;
struct
disk_index
*
node
=
NULL
;
struct
disk_index
*
node
=
NULL
;
D2
(
fprintf
(
debug_file
,
"%s:line %d: state->rawdev.rawdev_path=%s
\n
"
,
__FILE__
,
__LINE__
,
state
->
rawdev
.
rawdev_path
));
state
->
rawdev
.
rawdev_fd
=
open
(
state
->
rawdev
.
rawdev_path
,
O_RDONLY
);
state
->
rawdev
.
rawdev_fd
=
open
(
state
->
rawdev
.
rawdev_path
,
O_RDONLY
);
if
(
state
->
rawdev
.
rawdev_fd
<
0
)
{
if
(
state
->
rawdev
.
rawdev_fd
<
0
)
{
D0
(
perror
(
__func__
));
D0
(
perror
(
__func__
));
...
...
src/camogmgui/camogm_interface.php
View file @
ba98b0cf
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
*/
*/
define
(
'SSD_ROOT'
,
'/mnt/sda1/'
);
define
(
'SSD_ROOT'
,
'/mnt/sda1/'
);
define
(
'ASSUME_EXT4'
,
'sda1'
);
// comment out after testing
define
(
'ASSUME_EXT4'
,
'sda1'
);
// comment out after testing
define
(
'USE_SYSLOG'
,
1
);
//
define('USE_SYSLOG', 1);
$cmd
=
$_GET
[
'cmd'
];
$cmd
=
$_GET
[
'cmd'
];
$debug
=
$_GET
[
'debug'
];
$debug
=
$_GET
[
'debug'
];
$debuglev
=
$_GET
[
'debuglev'
];
$debuglev
=
$_GET
[
'debuglev'
];
...
@@ -81,8 +81,9 @@ $default_state = "/etc/elphel393/camogm.disk";
...
@@ -81,8 +81,9 @@ $default_state = "/etc/elphel393/camogm.disk";
//$state_file = "/mnt/sda1/camogm.disk";
//$state_file = "/mnt/sda1/camogm.disk";
$state_file
=
"/etc/elphel393/camogm.disk"
;
$state_file
=
"/etc/elphel393/camogm.disk"
;
$start_str
=
"camogm -n "
.
$cmd_pipe
.
" -p "
.
$cmd_port
;
$start_str
=
"camogm -n "
.
$cmd_pipe
.
" -p "
.
$cmd_port
;
if
(
defined
(
'USE_SYSLOG'
))
{
//if (defined('USE_SYSLOG')) {
syslog
(
LOG_NOTICE
,
"camogm_interface.php:"
);
if
(
USE_SYSLOG
>
0
)
{
syslog
(
LOG_NOTICE
,
"camogm_interface.php:"
);
foreach
(
$_GET
as
$k
=>
$v
){
foreach
(
$_GET
as
$k
=>
$v
){
syslog
(
LOG_NOTICE
,
$k
.
" -> "
.
$v
);
syslog
(
LOG_NOTICE
,
$k
.
" -> "
.
$v
);
}
}
...
@@ -138,9 +139,9 @@ if ($cmd == "run_camogm")
...
@@ -138,9 +139,9 @@ if ($cmd == "run_camogm")
}
}
// set fast recording mode if there is at least one suitable partition or revert to legacy 'mov' mode
// set fast recording mode if there is at least one suitable partition or revert to legacy 'mov' mode
if
(
defined
(
'USE_SYSLOG'
)
)
syslog
(
LOG_NOTICE
,
"before get_raw_dev()"
);
if
(
USE_SYSLOG
>
0
)
syslog
(
LOG_NOTICE
,
"before get_raw_dev()"
);
$partitions
=
get_raw_dev
();
$partitions
=
get_raw_dev
();
if
(
defined
(
'USE_SYSLOG'
)
)
syslog
(
LOG_NOTICE
,
"after get_raw_dev()"
);
if
(
USE_SYSLOG
>
0
)
syslog
(
LOG_NOTICE
,
"after get_raw_dev()"
);
if
(
!
empty
(
$partitions
))
{
if
(
!
empty
(
$partitions
))
{
reset
(
$partitions
);
reset
(
$partitions
);
$cmd_str
=
'format=jpeg;'
.
'rawdev_path='
.
key
(
$partitions
)
.
';'
;
$cmd_str
=
'format=jpeg;'
.
'rawdev_path='
.
key
(
$partitions
)
.
';'
;
...
...
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