Commit 8efb3a01 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Add command to enable/disable dummy read

parent d7e36e5d
......@@ -160,6 +160,7 @@ inline void set_chn_state(camogm_state *s, unsigned int port, unsigned int new_s
inline int is_chn_active(camogm_state *s, unsigned int port);
void clean_up(camogm_state *state);
static void camogm_err_stat(const camogm_state *state, int port, FILE *f, bool xml);
static void camogm_set_dummy_read(camogm_state *state, int d);
void put_uint16(void *buf, u_int16_t val)
{
......@@ -268,6 +269,8 @@ void camogm_init(camogm_state *state, char *pipe_name, uint16_t port_num)
state->writer_params.data_ready = false;
state->writer_params.exit_thread = false;
state->writer_params.state = STATE_STOPPED;
camogm_set_dummy_read(state, 0);
}
/**
......@@ -846,6 +849,12 @@ void camogm_set_ignore_fps(camogm_state *state, int d)
state->ignore_fps = d ? 1 : 0;
}
void camogm_set_dummy_read(camogm_state *state, int d)
{
state->writer_params.dummy_read = d ? true : false;
D6(fprintf(debug_file, "Set dummy read flag = %d\n", state->writer_params.dummy_read));
}
/**
* @brief Set file name prefix or raw device file name.
* @param[in] state a pointer to a structure containing current state
......@@ -1484,6 +1493,9 @@ int parse_cmd(camogm_state *state, FILE* npipe)
D0(fprintf(debug_file, "Reading thread is not running, nothing to stop\n"));
}
return 29;
} else if (strcmp(cmd, "dummy_read") == 0) {
if ((args) && ((d = strtol(args, NULL, 10)) > 0)) camogm_set_dummy_read(state, d);
return 30;
}
return -1;
......
......@@ -162,6 +162,7 @@ struct writer_params {
uint64_t lba_end; ///< disk last LBA
time_t stat_update; ///< time when status file was updated
bool dummy_read; ///< inable dummy read cycle (debug feature)
};
/**
* @struct camogm_state
......
......@@ -426,17 +426,20 @@ void *jpeg_writer(void *thread_args)
process = false;
}
if (params->data_ready) {
/* dummy read cycle from (approximately) the beginning of previous frame */
ssize_t data_len;
off64_t curr_offset = lseek64(state->writer_params.blockdev_fd, 0, SEEK_CUR);
off64_t offset = lba_to_offset(state->writer_params.lba_current - state->writer_params.lba_start) - state->rawdev.last_jpeg_size;
offset = offset / PHY_BLOCK_SIZE;
lseek64(state->writer_params.blockdev_fd, offset, SEEK_SET);
data_len = read(state->writer_params.blockdev_fd, dummy_buff, PHY_BLOCK_SIZE);
if (data_len < PHY_BLOCK_SIZE) {
D6(fprintf(debug_file, "Dummy read error: requested %d, read %d, %s\n", PHY_BLOCK_SIZE, data_len, strerror(errno)));
/* dummy read cycle from (approximately) the beginning of previous frame;
* this is a debug feature used to find disk errors */
if (state->writer_params.dummy_read) {
ssize_t data_len;
off64_t curr_offset = lseek64(state->writer_params.blockdev_fd, 0, SEEK_CUR);
off64_t offset = lba_to_offset(state->writer_params.lba_current - state->writer_params.lba_start) - state->rawdev.last_jpeg_size;
offset = offset / PHY_BLOCK_SIZE;
lseek64(state->writer_params.blockdev_fd, offset, SEEK_SET);
data_len = read(state->writer_params.blockdev_fd, dummy_buff, PHY_BLOCK_SIZE);
if (data_len < PHY_BLOCK_SIZE) {
D6(fprintf(debug_file, "Dummy read error: requested %d, read %d, %s\n", PHY_BLOCK_SIZE, data_len, strerror(errno)));
}
lseek64(state->writer_params.blockdev_fd, curr_offset, SEEK_SET);
}
lseek64(state->writer_params.blockdev_fd, curr_offset, SEEK_SET);
/* end of dummy read cycle */
l = 0;
......
......@@ -609,6 +609,7 @@ else
fprintf($fcmd, "prefix=%s;\n", $prefix);
setcookie("directory", $prefix);
break;
case "set_debuglev":
$debuglev = $_GET['debuglev'];
fprintf($fcmd, "debuglev=%s;\n", $debuglev);
......@@ -668,20 +669,24 @@ else
exec('aplay '.$soundfile);
break;
case "setmov":
exec('echo "format=mov;" > /var/state/camogm_cmd'); // Set quicktime *.mov as default format after startup.
exec('echo "save_gp=1;\n" > /var/state/camogm_cmd'); // enable calculation of free/used buffer space
exec('echo "format=mov;" > '.$cmd_pipe); // Set quicktime *.mov as default format after startup.
exec('echo "save_gp=1;\n" > '.$cmd_pipe); // enable calculation of free/used buffer space
break;
case "setjpeg":
exec('echo "format=jpg;" > /var/state/camogm_cmd'); // Set quicktime *.mov as default format after startup.
exec('echo "save_gp=1;\n" > /var/state/camogm_cmd'); // enable calculation of free/used buffer space
exec('echo "format=jpg;" > '.$cmd_pipe); // Set quicktime *.mov as default format after startup.
exec('echo "save_gp=1;\n" > '.$cmd_pipe); // enable calculation of free/used buffer space
break;
case "setrawdevpath":
$rawdev_path = $_GET['path'];
exec('echo "rawdev_path='.$rawdev_path.';" > /var/state/camogm_cmd');
break;
case "setrawdevpath":
$rawdev_path = $_GET['path'];
exec('echo "rawdev_path='.$rawdev_path.';" > '.$cmd_pipe);
break;
case "gettime":
echo elphel_get_fpga_time();
break;
case "set_dummy_read":
$dummy_read = $_GET["dummy_read"];
exec('echo "dummy_read='.$dummy_read.';" > '.$cmd_pipe);
break;
}
if ($fcmd)
fclose($fcmd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment