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 ...@@ -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); inline int is_chn_active(camogm_state *s, unsigned int port);
void clean_up(camogm_state *state); void clean_up(camogm_state *state);
static void camogm_err_stat(const camogm_state *state, int port, FILE *f, bool xml); 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) 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) ...@@ -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.data_ready = false;
state->writer_params.exit_thread = false; state->writer_params.exit_thread = false;
state->writer_params.state = STATE_STOPPED; 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) ...@@ -846,6 +849,12 @@ void camogm_set_ignore_fps(camogm_state *state, int d)
state->ignore_fps = d ? 1 : 0; 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. * @brief Set file name prefix or raw device file name.
* @param[in] state a pointer to a structure containing current state * @param[in] state a pointer to a structure containing current state
...@@ -1484,6 +1493,9 @@ int parse_cmd(camogm_state *state, FILE* npipe) ...@@ -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")); D0(fprintf(debug_file, "Reading thread is not running, nothing to stop\n"));
} }
return 29; 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; return -1;
......
...@@ -162,6 +162,7 @@ struct writer_params { ...@@ -162,6 +162,7 @@ struct writer_params {
uint64_t lba_end; ///< disk last LBA uint64_t lba_end; ///< disk last LBA
time_t stat_update; ///< time when status file was updated time_t stat_update; ///< time when status file was updated
bool dummy_read; ///< inable dummy read cycle (debug feature)
}; };
/** /**
* @struct camogm_state * @struct camogm_state
......
...@@ -426,17 +426,20 @@ void *jpeg_writer(void *thread_args) ...@@ -426,17 +426,20 @@ void *jpeg_writer(void *thread_args)
process = false; process = false;
} }
if (params->data_ready) { if (params->data_ready) {
/* dummy read cycle from (approximately) the beginning of previous frame */ /* dummy read cycle from (approximately) the beginning of previous frame;
ssize_t data_len; * this is a debug feature used to find disk errors */
off64_t curr_offset = lseek64(state->writer_params.blockdev_fd, 0, SEEK_CUR); if (state->writer_params.dummy_read) {
off64_t offset = lba_to_offset(state->writer_params.lba_current - state->writer_params.lba_start) - state->rawdev.last_jpeg_size; ssize_t data_len;
offset = offset / PHY_BLOCK_SIZE; off64_t curr_offset = lseek64(state->writer_params.blockdev_fd, 0, SEEK_CUR);
lseek64(state->writer_params.blockdev_fd, offset, SEEK_SET); off64_t offset = lba_to_offset(state->writer_params.lba_current - state->writer_params.lba_start) - state->rawdev.last_jpeg_size;
data_len = read(state->writer_params.blockdev_fd, dummy_buff, PHY_BLOCK_SIZE); offset = offset / PHY_BLOCK_SIZE;
if (data_len < PHY_BLOCK_SIZE) { lseek64(state->writer_params.blockdev_fd, offset, SEEK_SET);
D6(fprintf(debug_file, "Dummy read error: requested %d, read %d, %s\n", PHY_BLOCK_SIZE, data_len, strerror(errno))); 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 */ /* end of dummy read cycle */
l = 0; l = 0;
......
...@@ -609,6 +609,7 @@ else ...@@ -609,6 +609,7 @@ else
fprintf($fcmd, "prefix=%s;\n", $prefix); fprintf($fcmd, "prefix=%s;\n", $prefix);
setcookie("directory", $prefix); setcookie("directory", $prefix);
break; break;
case "set_debuglev": case "set_debuglev":
$debuglev = $_GET['debuglev']; $debuglev = $_GET['debuglev'];
fprintf($fcmd, "debuglev=%s;\n", $debuglev); fprintf($fcmd, "debuglev=%s;\n", $debuglev);
...@@ -668,20 +669,24 @@ else ...@@ -668,20 +669,24 @@ else
exec('aplay '.$soundfile); exec('aplay '.$soundfile);
break; break;
case "setmov": case "setmov":
exec('echo "format=mov;" > /var/state/camogm_cmd'); // Set quicktime *.mov as default format after startup. exec('echo "format=mov;" > '.$cmd_pipe); // 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 "save_gp=1;\n" > '.$cmd_pipe); // enable calculation of free/used buffer space
break; break;
case "setjpeg": case "setjpeg":
exec('echo "format=jpg;" > /var/state/camogm_cmd'); // Set quicktime *.mov as default format after startup. exec('echo "format=jpg;" > '.$cmd_pipe); // 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 "save_gp=1;\n" > '.$cmd_pipe); // enable calculation of free/used buffer space
break; break;
case "setrawdevpath": case "setrawdevpath":
$rawdev_path = $_GET['path']; $rawdev_path = $_GET['path'];
exec('echo "rawdev_path='.$rawdev_path.';" > /var/state/camogm_cmd'); exec('echo "rawdev_path='.$rawdev_path.';" > '.$cmd_pipe);
break; break;
case "gettime": case "gettime":
echo elphel_get_fpga_time(); echo elphel_get_fpga_time();
break; break;
case "set_dummy_read":
$dummy_read = $_GET["dummy_read"];
exec('echo "dummy_read='.$dummy_read.';" > '.$cmd_pipe);
break;
} }
if ($fcmd) if ($fcmd)
fclose($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