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
1070f517
Commit
1070f517
authored
Jun 13, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed closing file error, more debugging
parent
8eee4caa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
8 deletions
+36
-8
camogm.c
src/camogm.c
+3
-2
camogm_align.c
src/camogm_align.c
+15
-1
camogm_align.h
src/camogm_align.h
+1
-0
camogm_jpeg.c
src/camogm_jpeg.c
+17
-5
No files found.
src/camogm.c
View file @
1070f517
...
...
@@ -2049,8 +2049,9 @@ unsigned int select_port(camogm_state *state)
}
if
((
state
->
prog_state
==
STATE_STARTING
)
||
(
state
->
prog_state
==
STATE_RUNNING
))
{
// if (lseek(state->fd_circ[port], LSEEK_CIRC_READY, SEEK_END) < 0) {
D3
(
if
((
chn
>=
0
)
&&
(
lseek
(
state
->
fd_circ
[
chn
],
LSEEK_CIRC_READY
,
SEEK_END
)
>=
0
))
\
fprintf
(
debug_file
,
"selected port: %i, min free size = %08ld @ %07d
\n
"
,
chn
,
min_sz
,
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
));
\
// fprintf(debug_file, "selected port: %i, min free size = %08ld @ %07d\n", chn, min_sz, get_fpga_usec(state->fd_fparmsall[0], 0));
D1
(
if
((
chn
>=
0
)
&&
(
lseek
(
state
->
fd_circ
[
chn
],
LSEEK_CIRC_READY
,
SEEK_END
)
>=
0
))
\
fprintf
(
debug_file
,
"selected port: %i, min free size = %08ld "
,
chn
,
min_sz
);
\
else
if
(
debug_level
>=
6
)
fprintf
(
debug_file
,
"no port is ready @ %07d
\n
"
,
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
)));
}
...
...
src/camogm_align.c
View file @
1070f517
...
...
@@ -54,7 +54,7 @@ static inline void vectcpy(struct iovec *dest, void *src, size_t len)
}
/** Set @e len bytes with @e src to buffer pointed by @e dest vector */
static
inline
void
vectset
(
struct
iovec
*
dest
,
int
src
,
size_t
len
)
static
void
vectset
(
struct
iovec
*
dest
,
int
src
,
size_t
len
)
{
unsigned
char
*
d
=
(
unsigned
char
*
)
dest
->
iov_base
;
D6
(
fprintf
(
debug_file
,
"_13c06a?_:vectset() d=%p, src=%d len=%d
\n
"
,
d
,
src
,
len
));
...
...
@@ -92,6 +92,20 @@ static inline unsigned char *vectrpos(struct iovec *vec, size_t offset)
return
(
unsigned
char
*
)
vec
->
iov_base
+
(
vec
->
iov_len
-
offset
);
}
/** extend to page-aligned */
int
vectaligntail
(
struct
iovec
*
dest
)
{
unsigned
char
*
d
=
(
unsigned
char
*
)
dest
->
iov_base
;
int
len
=
dest
->
iov_len
;
int
ceil_size
=
(
len
&
(
PAGE_PHYS
-
1
))
?
((
len
|
(
PAGE_PHYS
-
1
))
+
1
)
:
len
;
if
(
ceil_size
>
len
)
{
vectset
(
dest
,
0
,
ceil_size
-
len
);
}
return
ceil_size
;
}
/** Remap vectors pointing to various buffers with frame data to vectors used during frame alignment
* Setup state->writer_params.data_segments[seg_page] ([SEGMENT_GLUE, SEGMENT_FIRST, SEGMENT_SECOND] and
* use /setup next state->writer_params.glue_carry_vec
...
...
src/camogm_align.h
View file @
1070f517
...
...
@@ -63,6 +63,7 @@ void deinit_align_buffers(camogm_state *state);
void
reset_segments
(
camogm_state
*
state
,
int
all
,
int
page
);
size_t
remap_vectors
(
camogm_state
*
state
);
//, struct iovec *chunks);
off64_t
lba_to_offset
(
uint64_t
lba
);
int
vectaligntail
(
struct
iovec
*
dest
);
#endif
/* _CAMOGM_ALIGN_H */
src/camogm_jpeg.c
View file @
1070f517
...
...
@@ -35,7 +35,7 @@
#include "camogm_jpeg.h"
#include "camogm_read.h"
#include "camogm_align.h"
#define BUFFER_KVEC
//
#define BUFFER_KVEC
#define MAX_IMAGE_ALIGNED (4096*256)
/** State file record format. It includes device path in /dev, starting, current and ending LBAs */
#define STATE_FILE_FORMAT "%s\t%llu\t%llu\t%llu\n"
...
...
@@ -62,6 +62,15 @@ ssize_t emul_writev (int fd, const struct iovec *iovec, int count) {
ssize_t
wlen
,
tot_len
=
0
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
if
(
iovec
[
i
].
iov_len
>
0
)
{
if
(
iovec
[
i
].
iov_len
&
(
PAGE_PHYS
-
1
)){
D0
(
fprintf
(
debug_file
,
"Length not page-aligned: while trying direct writing of %d bytes from %p, data = 0x%llx, segment=%d
\n
"
,
\
iovec
[
i
].
iov_len
,
iovec
[
i
].
iov_base
,
((
uint64_t
*
)
iovec
[
i
].
iov_base
)[
0
],
i
));
D0
(
syslog
(
LOG_INFO
,
"Length not page-aligned: while trying direct writing of %d bytes from %p, data = 0x%llx, segment=%d
\n
"
,
\
iovec
[
i
].
iov_len
,
iovec
[
i
].
iov_base
,
((
uint64_t
*
)
iovec
[
i
].
iov_base
)[
0
],
i
));
debug_level
=
6
;
return
-
1
;
}
#ifdef BUFFER_KVEC
D6
(
fprintf
(
debug_file
,
"Trying direct writing of %d bytes from %p, data = 0x%llx
\n
"
,
\
iovec
[
i
].
iov_len
,
iovec
[
i
].
iov_base
,
((
uint64_t
*
)
iovec
[
i
].
iov_base
)[
0
]));
...
...
@@ -85,6 +94,8 @@ ssize_t emul_writev (int fd, const struct iovec *iovec, int count) {
wlen
=
write
(
fd
,
iovec
[
i
].
iov_base
,
iovec
[
i
].
iov_len
);
#endif
if
(
wlen
<
0
)
{
D0
(
fprintf
(
debug_file
,
"Error %d while trying direct writing of %d bytes from %p, data = 0x%llx, segment=%d
\n
"
,
\
wlen
,
iovec
[
i
].
iov_len
,
iovec
[
i
].
iov_base
,
((
uint64_t
*
)
iovec
[
i
].
iov_base
)[
0
],
i
));
return
wlen
;
}
else
if
(
wlen
<
iovec
[
i
].
iov_len
)
{
return
tot_len
+
wlen
;
...
...
@@ -446,7 +457,7 @@ int camogm_frame_jpeg(camogm_state *state)
int
camogm_end_jpeg
(
camogm_state
*
state
)
// TODO: Resolve multippage !
{
int
ret
=
0
;
int
bytes
;
int
bytes
,
ceil_size
;
ssize_t
iovlen
;
if
(
state
->
rawdev_op
)
{
...
...
@@ -458,7 +469,8 @@ int camogm_end_jpeg(camogm_state *state) // TODO: Resolve multippage !
pthread_cond_wait
(
&
state
->
writer_params
.
main_cond
,
&
state
->
writer_params
.
writer_mutex
);
bytes
=
state
->
writer_params
.
glue_carry_vec
.
iov_len
;
if
(
bytes
>
0
)
{
D6
(
fprintf
(
debug_file
,
"Write last block of data, size = %d
\n
"
,
bytes
));
ceil_size
=
vectaligntail
(
&
state
->
writer_params
.
glue_carry_vec
);
D1
(
fprintf
(
debug_file
,
"Write last block of data, size = %d, full size = %d
\n
"
,
bytes
,
ceil_size
));
// the remaining data block is placed in CHUNK_COMMON buffer, write just this buffer
iovlen
=
emul_writev
(
state
->
writer_params
.
blockdev_fd
,
&
state
->
writer_params
.
glue_carry_vec
,
...
...
@@ -593,7 +605,7 @@ void *jpeg_writer(void *thread_args)
blocks_write
=
l
/
PHY_BLOCK_SIZE
;
// here LBA, 512
if
(
state
->
writer_params
.
lba_current
+
blocks_write
<=
state
->
writer_params
.
lba_end
)
{
// almost always - single write
state
->
writer_params
.
lba_current
+=
blocks_write
;
D
3
(
dbg_us1
=
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
));
D
2
(
dbg_us1
=
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
));
D6
(
dbg_pos
=
lseek
(
state
->
writer_params
.
blockdev_fd
,
0
,
SEEK_CUR
));
D6
(
fprintf
(
debug_file
,
"_w02_: starting emul_writev@ %07d
\n
"
,
dbg_us1
));
state
->
writer_params
.
writev_run
=
true
;
...
...
@@ -601,7 +613,7 @@ void *jpeg_writer(void *thread_args)
// iovlen = emul_writev(state->writer_params.blockdev_fd, chunks_iovec[wpage], chunk_index);
iovlen
=
emul_writev
(
state
->
writer_params
.
blockdev_fd
,
write_segments
,
num_write_segments
);
state
->
writer_params
.
writev_run
=
false
;
D
3
(
dbg_us
=
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
);
fprintf
(
debug_file
,
"_w03_: finished emul_writev, pos%%block = %ld, pos= %ld @ %07d (+ %07d, +%07d)
\n
"
,
dbg_pos
%
PHY_BLOCK_SIZE
,
dbg_pos
,
dbg_us
,
(
dbg_us
-
dbg_us1
),
(
dbg_us
-
dbg_us2
)));
D
2
(
dbg_us
=
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
);
fprintf
(
debug_file
,
"_w03_: finished emul_writev, pos%%block = %ld, pos= %ld @ %07d (+ %07d, +%07d)
\n
"
,
dbg_pos
%
PHY_BLOCK_SIZE
,
dbg_pos
,
dbg_us
,
(
dbg_us
-
dbg_us1
),
(
dbg_us
-
dbg_us2
)));
D3
(
syslog
(
LOG_INFO
,
"_w03_: finished emul_writev, pos= %ld, len = %d(0x%x) @ %07d (+ %07d, +%07d)"
,
dbg_pos
,
iovlen
,
iovlen
,
dbg_us
,
(
dbg_us
-
dbg_us1
),
(
dbg_us
-
dbg_us2
)));
D3
(
dbg_us2
=
dbg_us
);
if
(
iovlen
<
l
)
{
...
...
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