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
100302e4
Commit
100302e4
authored
Jul 01, 2016
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process 'get_index' command
parent
5762dc82
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
camogm_read.c
camogm_read.c
+19
-4
No files found.
camogm_read.c
View file @
100302e4
...
@@ -50,6 +50,7 @@
...
@@ -50,6 +50,7 @@
#define CMD_BUFF_LEN 1024
#define CMD_BUFF_LEN 1024
#define COMMAND_LOOP_DELAY 500000
#define COMMAND_LOOP_DELAY 500000
#define PAGE_BOUNDARY_MASK 0xffffffffffffe000
#define PAGE_BOUNDARY_MASK 0xffffffffffffe000
#define INDEX_FORMAT_STR "port number = %d; unix time = %ld; usec time = %06u; offset = 0x%010llx; file size = %u\n"
/** @brief The size of read buffer in bytes. The data will be read from disk in blocks of this size */
/** @brief The size of read buffer in bytes. The data will be read from disk in blocks of this size */
#define PHY_BLK_SZ 4096
#define PHY_BLK_SZ 4096
/** @brief Include or exclude file start and stop markers from resulting file. This must be set to 1 for JPEG files */
/** @brief Include or exclude file start and stop markers from resulting file. This must be set to 1 for JPEG files */
...
@@ -260,7 +261,7 @@ void dump_index_dir(const struct disk_idir *idir)
...
@@ -260,7 +261,7 @@ void dump_index_dir(const struct disk_idir *idir)
struct
disk_index
*
ind
=
idir
->
head
;
struct
disk_index
*
ind
=
idir
->
head
;
while
(
ind
!=
NULL
)
{
while
(
ind
!=
NULL
)
{
fprintf
(
debug_file
,
"port number = %d; unix time = %ld; usec time = %06u; offset = 0x%010llx; file size = %u
\n
"
,
fprintf
(
debug_file
,
INDEX_FORMAT_STR
,
ind
->
port
,
ind
->
rawtime
,
ind
->
usec
,
ind
->
f_offset
,
ind
->
f_size
);
ind
->
port
,
ind
->
rawtime
,
ind
->
usec
,
ind
->
f_offset
,
ind
->
f_size
);
ind
=
ind
->
next
;
ind
=
ind
->
next
;
}
}
...
@@ -890,6 +891,7 @@ void *reader(void *arg)
...
@@ -890,6 +891,7 @@ void *reader(void *arg)
int
cmd
;
int
cmd
;
char
cmd_buff
[
CMD_BUFF_LEN
]
=
{
0
};
char
cmd_buff
[
CMD_BUFF_LEN
]
=
{
0
};
char
*
cmd_ptr
;
char
*
cmd_ptr
;
char
send_buff
[
CMD_BUFF_LEN
]
=
{
0
};
bool
transfer
;
bool
transfer
;
ssize_t
cmd_len
;
ssize_t
cmd_len
;
size_t
mm_file_start
,
mm_file_size
;
size_t
mm_file_start
,
mm_file_size
;
...
@@ -927,16 +929,29 @@ void *reader(void *arg)
...
@@ -927,16 +929,29 @@ void *reader(void *arg)
D6
(
fprintf
(
debug_file
,
"Got command '%s', number %d
\n
"
,
cmd_list
[
cmd
],
cmd
));
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
if
(
index_dir
.
size
!=
0
)
{
if
(
index_dir
.
size
!=
0
)
{
fprintf
(
debug_file
,
"%s: removing disk index directory"
,
__func__
);
delete_idir
(
&
index_dir
);
delete_idir
(
&
index_dir
);
fprintf
(
debug_file
,
"... done
\n
"
);
}
}
build_index
(
state
,
&
index_dir
);
build_index
(
state
,
&
index_dir
);
D3
(
fprintf
(
debug_file
,
"%d files read from %s
\n
"
,
index_dir
.
size
,
state
->
rawdev
.
rawdev_path
));
D3
(
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
:
dump_index_dir
(
&
index_dir
);
// send the content of disk index directory over socket
if
(
index_dir
.
size
>
0
)
{
int
len
;
disk_indx
=
index_dir
.
head
;
while
(
disk_indx
!=
NULL
)
{
len
=
snprintf
(
send_buff
,
CMD_BUFF_LEN
,
INDEX_FORMAT_STR
,
disk_indx
->
port
,
disk_indx
->
rawtime
,
disk_indx
->
usec
,
disk_indx
->
f_offset
,
disk_indx
->
f_size
);
send_buff
[
len
]
=
'\0'
;
write
(
fd
,
send_buff
,
len
);
disk_indx
=
disk_indx
->
next
;
}
}
else
{
D0
(
fprintf
(
debug_file
,
"Index directory does not contain any files. Try to rebuild index "
"directory with 'build_index' command
\n
"
));
}
break
;
break
;
case
CMD_READ_DISK
:
case
CMD_READ_DISK
:
// 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
...
...
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