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
997be073
Commit
997be073
authored
Jul 04, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugging, tested status files fro raw recording
parent
c78bbfc2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
14 deletions
+92
-14
camogm.c
src/camogm.c
+1
-1
camogm_jpeg.c
src/camogm_jpeg.c
+87
-12
camogm_jpeg.h
src/camogm_jpeg.h
+4
-1
No files found.
src/camogm.c
View file @
997be073
...
...
@@ -2454,7 +2454,7 @@ int main(int argc, char *argv[])
strncpy
(
sstate
.
rawdev
.
state_path
,
(
const
char
*
)
state_name_str
,
str_len
+
1
);
}
ret
=
get
_state_directory
(
&
sstate
);
ret
=
get
up_state_files
(
&
sstate
);
D2
(
syslog
(
LOG_INFO
,
"%s:line %d : get_state_directory() -> %d @ %07d
\n
"
,
\
__FILE__
,
__LINE__
,
ret
,
get_fpga_usec
(
sstate
.
fd_fparmsall
[
0
],
0
)));
...
...
src/camogm_jpeg.c
View file @
997be073
...
...
@@ -202,7 +202,19 @@ static int find_state(FILE *f, uint64_t *pos, const rawdev_buffer *rawdev)
return
-
3
;
}
int
get_state_directory
(
camogm_state
*
state
)
{
//rawdev_buffer *rawdev){
int
get_dir_path
(
char
*
file_path
,
char
*
directory
){
// directory should be allocated, returns w/o trailing '/'
// int dirlen;
char
*
cp
;
strncpy
(
directory
,
file_path
,
ELPHEL_PATH_MAX
);
// rawdev->state_path is always absolute
cp
=
strrchr
(
directory
,
'/'
);
if
(
!
cp
)
{
return
-
1
;
// no '/'
}
*
cp
=
0
;
// truncate at '_'
return
strlen
(
directory
);
}
int
getup_state_files
(
camogm_state
*
state
)
{
//rawdev_buffer *rawdev){
rawdev_buffer
*
rawdev
=
&
state
->
rawdev
;
int
dirlen
,
preflen
;
// length of directory path including trailing '/'
char
*
cp
;
...
...
@@ -213,20 +225,22 @@ int get_state_directory(camogm_state *state) { //rawdev_buffer *rawdev){
struct
dirent
*
dir
;
struct
stat
fstat
;
__time_t
tsec
=
0
;
strncpy
(
state_directory
,
rawdev
->
state_path
,
ELPHEL_PATH_MAX
);
#if 0
strncpy(state_directory, rawdev->state_path, ELPHEL_PATH_MAX); // rawdev->state_path is always absolute
cp=strrchr(state_directory,'/');
if (!cp) {
return -1;
}
*cp=0; // truncate
dirlen = strlen(state_directory);
#endif
dirlen
=
get_dir_path
(
rawdev
->
state_path
,
state_directory
);
preflen
=
dirlen
+
1
;
// counts '/'
strcpy
(
pathname
,
state_directory
);
cp
=
pathname
+
dirlen
;
*
cp
=
'/'
;
cp
++
;
*
cp
=
0
;
// return rawdev->state_directory;
// get latest
strcpy
(
rawdev
->
state_prefix
,
state_directory
);
...
...
@@ -275,17 +289,37 @@ int get_state_directory(camogm_state *state) { //rawdev_buffer *rawdev){
return
0
;
}
// need to modify - if prefix already appeared, and provided index <= old, increment latest old one
int
set_state_file_from_prefix
(
camogm_state
*
state
,
const
char
*
prefix
){
// prefix is relative to /dev/sda1 (where camogm.disk is)
rawdev_buffer
*
rawdev
=
&
state
->
rawdev
;
char
last_path
[
ELPHEL_PATH_MAX
];
char
*
cp
,
*
cp1
;
int
preflen
,
len
,
i
;
char
*
cp
,
*
cp1
,
*
local_pref
;
// pointer to last_path after '/'
int
preflen
,
len
,
i
,
new_index
,
old_index
;
DIR
*
d
;
struct
dirent
*
dir
;
// char pathname[ELPHEL_PATH_MAX];
char
state_directory
[
ELPHEL_PATH_MAX
];
cp
=
last_path
;
if
(
prefix
[
0
]
!=
'/'
)
{
// relative
len
=
get_dir_path
(
rawdev
->
state_path
,
last_path
);
if
(
len
<
0
)
{
D0
(
syslog
(
LOG_ERR
,
"%s:%d: State file '%s' is not absolute, should start with /dev/sda1"
,
__FILE__
,
__LINE__
,
rawdev
->
state_path
));
}
cp
=
last_path
+
len
;
*
cp
++
=
'/'
;
strncpy
(
cp
,
prefix
,
ELPHEL_PATH_MAX
-
len
-
2
);
}
else
{
strcpy
(
last_path
,
prefix
);
// may be either relative to camogm.disk directory or absolute
}
// now - always absolute
if
(
!
strcmp
(
last_path
+
(
strlen
(
last_path
)
-
strlen
(
STATE_EXT
)),
STATE_EXT
))
{
// ends with .disk
last_path
[
strlen
(
last_path
)
-
strlen
(
STATE_EXT
)]
=
'\0'
;
// truncate at .
}
rawdev
->
state_index
=
0
;
// absolute, w/o '.disk.
strcpy
(
rawdev
->
state_prefix
,
last_path
);
// use anyway, only index may be adjusted
// local_pref = last_path+
new_index
=
0
;
cp
=
strrchr
(
last_path
,
'_'
);
// find last '_'
if
(
!
cp
||
strchr
(
cp
,
'/'
)){
//'_' in the directory name
cp
=
last_path
+
strlen
(
last_path
);
// full string w/o optional extension
...
...
@@ -298,16 +332,57 @@ int set_state_file_from_prefix(camogm_state *state, const char * prefix){ // pre
break
;
}
}
D2
(
syslog
(
LOG_INFO
,
"_s030_ len=%d, cp=0x%08x, cp1=
%s
"
,
\
D2
(
syslog
(
LOG_INFO
,
"_s030_ len=%d, cp=0x%08x, cp1=
'%s'
"
,
\
len
,
(
int
)
cp
,
cp1
));
if
(
cp
)
{
sscanf
(
cp
+
1
,
"%d"
,
&
rawdev
->
state
_index
);
sscanf
(
cp
+
1
,
"%d"
,
&
new
_index
);
}
else
{
cp
=
last_path
+
strlen
(
last_path
);
}
}
*
cp
=
'\0'
;
strcpy
(
rawdev
->
state_prefix
,
last_path
);
*
cp
=
'\0'
;
// instead of the '_' or '.' in '.disk'
// last_path - prefix (absolute), new_index
// get directory from the new potential prefix (last_path)
len
=
get_dir_path
(
last_path
,
state_directory
);
if
(
len
<
0
)
{
D0
(
syslog
(
LOG_ERR
,
"%s:%d: Prefix '%s' should be absolute here"
,
__FILE__
,
__LINE__
,
last_path
));
return
-
1
;
}
local_pref
=
last_path
+
(
len
+
1
);
// right after '/', ends at former "_" or ".disk"
preflen
=
strlen
(
local_pref
);
// see if the same prefix already appeared, if yes - find the maximal index
old_index
=
-
1
;
//strcpy(rawdev->state_prefix, state_directory)
D3
(
syslog
(
LOG_INFO
,
"_s31_ new prefix='%s' new directory='%s'"
,
\
last_path
,
state_directory
));
d
=
opendir
(
state_directory
);
if
(
d
)
{
while
((
dir
=
readdir
(
d
))
!=
NULL
)
{
if
(
!
strcmp
(
STATE_EXT
,
dir
->
d_name
+
(
strlen
(
dir
->
d_name
)
-
strlen
(
STATE_EXT
))))
{
// same extension
if
(
!
strncmp
(
local_pref
,
dir
->
d_name
,
preflen
))
{
// starts same
if
((
dir
->
d_name
[
preflen
]
==
'_'
)
||
(
dir
->
d_name
[
preflen
]
==
'.'
)){
i
=
0
;
// if not get any - will be 0;
sscanf
(
dir
->
d_name
+
preflen
+
1
,
"%d"
,
&
i
);
D3
(
syslog
(
LOG_INFO
,
"_s32_ matching old file='%s' index=%d"
,
\
dir
->
d_name
,
i
));
if
(
i
>
old_index
)
{
old_index
=
i
;
}
}
}
}
}
closedir
(
d
);
}
if
(
old_index
>=
new_index
){
rawdev
->
state_index
=
old_index
+
1
;
D3
(
syslog
(
LOG_INFO
,
"_s33_ using incremented old index=%d (new was %d), prefix = '%s'"
,
\
rawdev
->
state_index
,
new_index
,
rawdev
->
state_prefix
));
}
else
{
rawdev
->
state_index
=
new_index
;
D3
(
syslog
(
LOG_INFO
,
"_s33_ using new index index=%d (old was %d), prefix = '%s'"
,
\
rawdev
->
state_index
,
old_index
,
rawdev
->
state_prefix
));
}
preflen
=
snprintf
(
state
->
path
,
ELPHEL_PATH_MAX
,
STATE_FMT
,
rawdev
->
state_prefix
,
rawdev
->
state_index
);
D2
(
syslog
(
LOG_INFO
,
"_s03_ prefix='%s', rawdev->state_prefix='%s', index=%d, preflen=%d, state->path=%s"
,
\
prefix
,
rawdev
->
state_prefix
,
rawdev
->
state_index
,
preflen
,
state
->
path
));
...
...
src/camogm_jpeg.h
View file @
997be073
...
...
@@ -31,7 +31,10 @@ 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
);
int
get_state_directory
(
camogm_state
*
state
);
// rawdev_buffer *rawdev);
int
get_dir_path
(
char
*
file_path
,
char
*
directory
);
// directory should be allocated, returns w/o trailing '/'
int
getup_state_files
(
camogm_state
*
state
);
// rawdev_buffer *rawdev);
int
set_state_file_from_prefix
(
camogm_state
*
state
,
const
char
*
prefix
);
char
*
get_state_path
(
camogm_state
*
state
);
void
next_state_path
(
camogm_state
*
state
);
...
...
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