Commit e4468ac7 authored by Andrey Filippov's avatar Andrey Filippov

debugging fast raw recording

parent a54d1b82
...@@ -713,7 +713,7 @@ int sendImageFrame(camogm_state *state) ...@@ -713,7 +713,7 @@ int sendImageFrame(camogm_state *state)
dbg_show_packetchunks(state); dbg_show_packetchunks(state);
D6(fprintf(debug_file, "_12.5_ before CAMOGM_FORMAT_XXX @ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "_12.5_ before CAMOGM_FORMAT_XXX @ %07d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
switch (state->format) { switch (state->format) {
case CAMOGM_FORMAT_NONE: rslt = 0; break; case CAMOGM_FORMAT_NONE: rslt = 0; break;
...@@ -759,7 +759,7 @@ int sendImageFrame(camogm_state *state) ...@@ -759,7 +759,7 @@ int sendImageFrame(camogm_state *state)
// end_time.tv_sec, end_time.tv_usec, // end_time.tv_sec, end_time.tv_usec,
// state->rawdev.last_jpeg_size)); // state->rawdev.last_jpeg_size));
// D6(fprintf(debug_file, "Write speed: %d MB/s\n", mbps)); // D6(fprintf(debug_file, "Write speed: %d MB/s\n", mbps));
D6(fprintf(debug_file, "Exit sendImageFrame() OK @ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "Exit sendImageFrame() OK @ %07d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
return 0; return 0;
} }
...@@ -1405,7 +1405,9 @@ int parse_cmd(camogm_state *state, FILE* npipe) ...@@ -1405,7 +1405,9 @@ int parse_cmd(camogm_state *state, FILE* npipe)
//skip empty commands //skip empty commands
while (((cmd = getLineFromPipe(npipe))) && !cmd[0]) ; while (((cmd = getLineFromPipe(npipe))) && !cmd[0]) ;
if (!cmd) return 0; // nothing in the pipe if (!cmd) return 0; // nothing in the pipe
D2(fprintf(debug_file, "Got command (state->port_num=%d): '%s' @ %06d -> ", port, cmd, get_fpga_usec(state->fd_fparmsall[0], 0))); D2(fprintf(debug_file, "Got command (state->port_num=%d): '%s' @ %07d -> ", port, cmd, get_fpga_usec(state->fd_fparmsall[0], 0)));
D3(syslog (LOG_INFO, "Got command (state->port_num=%d): '%s' @ %07d -> ", port, cmd, get_fpga_usec(state->fd_fparmsall[0], 0)));
if (port >= 0) { if (port >= 0) {
D3(fprintf(debug_file, "Acknowledge received command for port=%d\n", port)); D3(fprintf(debug_file, "Acknowledge received command for port=%d\n", port));
// Acknowledge received command by copying frame number to per-daemon parameter // Acknowledge received command by copying frame number to per-daemon parameter
...@@ -1676,7 +1678,7 @@ int listener_loop(camogm_state *state) ...@@ -1676,7 +1678,7 @@ int listener_loop(camogm_state *state)
// enter main processing loop // enter main processing loop
while (process) { while (process) {
D6(fprintf(debug_file, "--------------- Listener loop @ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "--------------- Listener loop @ %07d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
curr_port = select_port(state); curr_port = select_port(state);
state->port_num = curr_port; state->port_num = curr_port;
// look at command queue first // look at command queue first
...@@ -1690,7 +1692,7 @@ int listener_loop(camogm_state *state) ...@@ -1690,7 +1692,7 @@ int listener_loop(camogm_state *state)
#endif #endif
cmd = parse_cmd(state, cmd_file); cmd = parse_cmd(state, cmd_file);
if (cmd) { if (cmd) {
D2(fprintf(debug_file, "DONE command @ %06d\n", get_fpga_usec(state->fd_fparmsall[0], 0))); D2(fprintf(debug_file, "DONE command @ %07d\n", get_fpga_usec(state->fd_fparmsall[0], 0)));
if (cmd < 0) D0(fprintf(debug_file, "Unrecognized command\n")); if (cmd < 0) D0(fprintf(debug_file, "Unrecognized command\n"));
#ifdef USE_POLL #ifdef USE_POLL
...@@ -1706,7 +1708,7 @@ int listener_loop(camogm_state *state) ...@@ -1706,7 +1708,7 @@ int listener_loop(camogm_state *state)
} else { } else {
rslt = -sendImageFrame(state); rslt = -sendImageFrame(state);
} }
D6(fprintf(debug_file, " ==> %d @ %06d\n",rslt,get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, " ==> %d @ %07d\n",rslt,get_fpga_usec(state->fd_fparmsall[0], 0)));
switch (rslt) { switch (rslt) {
case 0: case 0:
break; // frame sent OK, nothing to do (TODO: check file length/duration) break; // frame sent OK, nothing to do (TODO: check file length/duration)
...@@ -1714,7 +1716,7 @@ int listener_loop(camogm_state *state) ...@@ -1714,7 +1716,7 @@ int listener_loop(camogm_state *state)
// we'll wait for a frame, not to waste resources. But if the compressor is stopped this program will not respond to any commands // we'll wait for a frame, not to waste resources. But if the compressor is stopped this program will not respond to any commands
// TODO - add another wait with (short) timeout? // TODO - add another wait with (short) timeout?
wait_frame_sync(state->fd_fparmsall[curr_port]); wait_frame_sync(state->fd_fparmsall[curr_port]);
D6(fprintf(debug_file, "No compressed frame ready, waited for the next frame sync for port %d @ %06d\n",curr_port,get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "No compressed frame ready, waited for the next frame sync for port %d @ %07d\n",curr_port,get_fpga_usec(state->fd_fparmsall[0], 0)));
break; break;
// do not analyze next frame (may be non-existing), will do that next time // do not analyze next frame (may be non-existing), will do that next time
/* /*
...@@ -1728,7 +1730,7 @@ int listener_loop(camogm_state *state) ...@@ -1728,7 +1730,7 @@ int listener_loop(camogm_state *state)
D0(fprintf(debug_file, "%s:line %d got broken frame (%d) while waiting for ready. Before that fp0=0x%x\n", __FILE__, __LINE__, fp1, fp0)); D0(fprintf(debug_file, "%s:line %d got broken frame (%d) while waiting for ready. Before that fp0=0x%x\n", __FILE__, __LINE__, fp1, fp0));
rslt = CAMOGM_FRAME_BROKEN; rslt = CAMOGM_FRAME_BROKEN;
} else { } else {
D6(fprintf(debug_file, "No compressed frame ready, skipped 1 frame sync for port %d @ %06d\n",curr_port,get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "No compressed frame ready, skipped 1 frame sync for port %d @ %07d\n",curr_port,get_fpga_usec(state->fd_fparmsall[0], 0)));
break; break;
} }
} }
...@@ -1798,14 +1800,14 @@ int listener_loop(camogm_state *state) ...@@ -1798,14 +1800,14 @@ int listener_loop(camogm_state *state)
// add port number to error code to facilitate debugging // add port number to error code to facilitate debugging
state->last_error_code = rslt + 100 * state->port_num; state->last_error_code = rslt + 100 * state->port_num;
} else if (state->prog_state == STATE_READING) { } else if (state->prog_state == STATE_READING) {
D6(fprintf(debug_file, "COMMAND_LOOP_DELAY start for STATE_READING@ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "COMMAND_LOOP_DELAY start for STATE_READING@ %07d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
usleep(COMMAND_LOOP_DELAY); usleep(COMMAND_LOOP_DELAY);
D6(fprintf(debug_file, "COMMAND_LOOP_DELAY end for STATE_READING@ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "COMMAND_LOOP_DELAY end for STATE_READING@ %07d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
} else { // not running, not starting } else { // not running, not starting
state->rawdev.thread_state = STATE_RUNNING; state->rawdev.thread_state = STATE_RUNNING;
D6(fprintf(debug_file, "COMMAND_LOOP_DELAY start for STATE_RUNNING@ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "COMMAND_LOOP_DELAY start for STATE_RUNNING@ %07d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
usleep(COMMAND_LOOP_DELAY); // make it longer but interruptible by signals? usleep(COMMAND_LOOP_DELAY); // make it longer but interruptible by signals?
D6(fprintf(debug_file, "COMMAND_LOOP_DELAY end for STATE_RUNNING@ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "COMMAND_LOOP_DELAY end for STATE_RUNNING@ %07d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
} }
#ifdef USE_POLL #ifdef USE_POLL
// } // if pfd.revents & POLLIN // } // if pfd.revents & POLLIN
...@@ -2011,9 +2013,8 @@ unsigned int select_port(camogm_state *state) ...@@ -2011,9 +2013,8 @@ unsigned int select_port(camogm_state *state)
break; break;
} }
} }
if (state->prog_state == STATE_STARTING || state->prog_state == STATE_RUNNING) if (state->prog_state == STATE_STARTING || state->prog_state == STATE_RUNNING)
D3(fprintf(debug_file, "Selecting sensor port, buffer free size: ")); D6(fprintf(debug_file, "Selecting sensor port, buffer free size: "));
for (int i = 0; i < SENSOR_PORTS; i++) { for (int i = 0; i < SENSOR_PORTS; i++) {
if (is_chn_active(state, i)) { if (is_chn_active(state, i)) {
file_pos = lseek(state->fd_circ[i], 0, SEEK_CUR); file_pos = lseek(state->fd_circ[i], 0, SEEK_CUR);
...@@ -2021,7 +2022,7 @@ unsigned int select_port(camogm_state *state) ...@@ -2021,7 +2022,7 @@ unsigned int select_port(camogm_state *state)
free_sz = lseek(state->fd_circ[i], LSEEK_CIRC_FREE, SEEK_END); free_sz = lseek(state->fd_circ[i], LSEEK_CIRC_FREE, SEEK_END);
lseek(state->fd_circ[i], file_pos, SEEK_SET); lseek(state->fd_circ[i], file_pos, SEEK_SET);
if (state->prog_state == STATE_STARTING || state->prog_state == STATE_RUNNING) if (state->prog_state == STATE_STARTING || state->prog_state == STATE_RUNNING)
D3(fprintf(debug_file, "port %i = %li, ", i, free_sz)); D6(fprintf(debug_file, "port %i = %li, ", i, free_sz));
if (free_sz < CAMOGM_MIN_BUF_FRAMES * state->image_size[i]) { if (free_sz < CAMOGM_MIN_BUF_FRAMES * state->image_size[i]) {
D3(fprintf(debug_file, "port %i has too little free space (<CAMOGM_MIN_BUF_FRAMES * %d), considered BROKEN", i, state->image_size[i])); D3(fprintf(debug_file, "port %i has too little free space (<CAMOGM_MIN_BUF_FRAMES * %d), considered BROKEN", i, state->image_size[i]));
chn = -1; // i; chn = -1; // i;
...@@ -2042,11 +2043,15 @@ unsigned int select_port(camogm_state *state) ...@@ -2042,11 +2043,15 @@ unsigned int select_port(camogm_state *state)
} }
} else { } else {
if (state->prog_state == STATE_STARTING || state->prog_state == STATE_RUNNING) if (state->prog_state == STATE_STARTING || state->prog_state == STATE_RUNNING)
D3(fprintf(debug_file, "port %i is inactive, ", i)); D6(fprintf(debug_file, "port %i is inactive, ", i));
} }
} }
if (state->prog_state == STATE_STARTING || state->prog_state == STATE_RUNNING) if ((state->prog_state == STATE_STARTING) || (state->prog_state == STATE_RUNNING)) {
D3(fprintf(debug_file, "selected port: %i @ %06d\n", chn, get_fpga_usec(state->fd_fparmsall[0], 0))); // 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 = %d @ %07d\n", chn, min_sz, get_fpga_usec(state->fd_fparmsall[0], 0)); \
else if (debug_level >= 6) fprintf(debug_file,"no port is ready @ %07d\n", get_fpga_usec(state->fd_fparmsall[0], 0)));
}
return chn; return chn;
} }
...@@ -2324,7 +2329,7 @@ inline int get_fpga_usec(const int fd_fparsall, unsigned int port) ...@@ -2324,7 +2329,7 @@ inline int get_fpga_usec(const int fd_fparsall, unsigned int port)
{ {
lseek(fd_fparsall, LSEEK_GET_FPGA_TIME, SEEK_END); lseek(fd_fparsall, LSEEK_GET_FPGA_TIME, SEEK_END);
// return (int) getGPValue(port, G_MICROSECONDS); // return (int) getGPValue(port, G_MICROSECONDS);
return (int) GLOBALPARS(port, G_MICROSECONDS); return (int) GLOBALPARS(port, G_MICROSECONDS) + 1000000*(GLOBALPARS(port, G_SECONDS) % 10);
} }
/** /**
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <elphel/exifa.h> #include <elphel/exifa.h>
#include <elphel/c313a.h> #include <elphel/c313a.h>
#include <elphel/x393_devices.h> #include <elphel/x393_devices.h>
#include <syslog.h>
#define CAMOGM_FRAME_NOT_READY 1 ///< frame pointer valid, but not yet acquired #define CAMOGM_FRAME_NOT_READY 1 ///< frame pointer valid, but not yet acquired
#define CAMOGM_FRAME_INVALID 2 ///< invalid frame pointer #define CAMOGM_FRAME_INVALID 2 ///< invalid frame pointer
......
...@@ -548,7 +548,7 @@ void align_frame(camogm_state *state) ...@@ -548,7 +548,7 @@ void align_frame(camogm_state *state)
if (len >= (chunks[paged_CHUNK_DATA_1].iov_len + chunks[paged_CHUNK_TRAILER].iov_len)) { if (len >= (chunks[paged_CHUNK_DATA_1].iov_len + chunks[paged_CHUNK_TRAILER].iov_len)) {
/* current frame is not split or the second part of JPEG data is too short */ /* current frame is not split or the second part of JPEG data is too short */
data_len = len - chunks[paged_CHUNK_DATA_1].iov_len - chunks[paged_CHUNK_TRAILER].iov_len; data_len = len - chunks[paged_CHUNK_DATA_1].iov_len - chunks[paged_CHUNK_TRAILER].iov_len;
D6(fprintf(debug_file, "_algn002: data_len=%d, copy %d short JPEG @ %06d\n", data_len, chunks[paged_CHUNK_DATA_1].iov_len, get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "_algn002: data_len=%d, copy %d short JPEG @ %07d\n", data_len, chunks[paged_CHUNK_DATA_1].iov_len, get_fpga_usec(state->fd_fparmsall[0], 0)));
src = vectrpos(&chunks[paged_CHUNK_DATA_0], data_len); src = vectrpos(&chunks[paged_CHUNK_DATA_0], data_len);
vectcpy(chunk_rem, src, data_len); vectcpy(chunk_rem, src, data_len);
vectshrink(&chunks[paged_CHUNK_DATA_0], data_len); vectshrink(&chunks[paged_CHUNK_DATA_0], data_len);
...@@ -559,7 +559,7 @@ void align_frame(camogm_state *state) ...@@ -559,7 +559,7 @@ void align_frame(camogm_state *state)
} else if (len >= chunks[paged_CHUNK_TRAILER].iov_len) { } else if (len >= chunks[paged_CHUNK_TRAILER].iov_len) {
/* there is enough data in second part to align the frame */ /* there is enough data in second part to align the frame */
data_len = len - chunks[paged_CHUNK_TRAILER].iov_len; data_len = len - chunks[paged_CHUNK_TRAILER].iov_len;
D6(fprintf(debug_file, "_algn003: data_len=%d, copy %d short JPEG @ %06d\n", data_len, chunks[paged_CHUNK_DATA_1].iov_len, get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "_algn003: data_len=%d, copy %d short JPEG @ %07d\n", data_len, chunks[paged_CHUNK_DATA_1].iov_len, get_fpga_usec(state->fd_fparmsall[0], 0)));
src = vectrpos(&chunks[paged_CHUNK_DATA_1], data_len); src = vectrpos(&chunks[paged_CHUNK_DATA_1], data_len);
vectcpy(chunk_rem, src, data_len); vectcpy(chunk_rem, src, data_len);
vectshrink(&chunks[paged_CHUNK_DATA_1], data_len); vectshrink(&chunks[paged_CHUNK_DATA_1], data_len);
...@@ -571,7 +571,7 @@ void align_frame(camogm_state *state) ...@@ -571,7 +571,7 @@ void align_frame(camogm_state *state)
data_len = PHY_BLOCK_SIZE - (chunks[paged_CHUNK_TRAILER].iov_len - len); data_len = PHY_BLOCK_SIZE - (chunks[paged_CHUNK_TRAILER].iov_len - len);
if (data_len >= chunks[paged_CHUNK_DATA_1].iov_len) { if (data_len >= chunks[paged_CHUNK_DATA_1].iov_len) {
size_t cut_len = data_len - chunks[paged_CHUNK_DATA_1].iov_len; size_t cut_len = data_len - chunks[paged_CHUNK_DATA_1].iov_len;
D6(fprintf(debug_file, "_algn004: cut_len=%d, copy %d short JPEG @ %06d\n", cut_len, chunks[paged_CHUNK_DATA_1].iov_len, get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "_algn004: cut_len=%d, copy %d short JPEG @ %07d\n", cut_len, chunks[paged_CHUNK_DATA_1].iov_len, get_fpga_usec(state->fd_fparmsall[0], 0)));
src = vectrpos(&chunks[paged_CHUNK_DATA_0], cut_len); src = vectrpos(&chunks[paged_CHUNK_DATA_0], cut_len);
vectcpy(chunk_rem, src, cut_len); vectcpy(chunk_rem, src, cut_len);
vectshrink(&chunks[paged_CHUNK_DATA_0], cut_len); vectshrink(&chunks[paged_CHUNK_DATA_0], cut_len);
...@@ -580,7 +580,7 @@ void align_frame(camogm_state *state) ...@@ -580,7 +580,7 @@ void align_frame(camogm_state *state)
vectcpy(chunk_rem, chunks[paged_CHUNK_TRAILER].iov_base, chunks[paged_CHUNK_TRAILER].iov_len); vectcpy(chunk_rem, chunks[paged_CHUNK_TRAILER].iov_base, chunks[paged_CHUNK_TRAILER].iov_len);
vectshrink(&chunks[paged_CHUNK_TRAILER], chunks[paged_CHUNK_TRAILER].iov_len); vectshrink(&chunks[paged_CHUNK_TRAILER], chunks[paged_CHUNK_TRAILER].iov_len);
} else { } else {
D6(fprintf(debug_file, "_algn005: data_len=%d, @ %06d\n", data_len, get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "_algn005: data_len=%d, @ %07d\n", data_len, get_fpga_usec(state->fd_fparmsall[0], 0)));
src = vectrpos(&chunks[paged_CHUNK_DATA_1], data_len); src = vectrpos(&chunks[paged_CHUNK_DATA_1], data_len);
vectcpy(chunk_rem, src, data_len); vectcpy(chunk_rem, src, data_len);
vectshrink(&chunks[paged_CHUNK_DATA_1], data_len); vectshrink(&chunks[paged_CHUNK_DATA_1], data_len);
...@@ -594,13 +594,13 @@ void align_frame(camogm_state *state) ...@@ -594,13 +594,13 @@ void align_frame(camogm_state *state)
chunks[paged_CHUNK_ALIGN].iov_len = 0; chunks[paged_CHUNK_ALIGN].iov_len = 0;
if (chunks[paged_CHUNK_DATA_1].iov_len == 0) { if (chunks[paged_CHUNK_DATA_1].iov_len == 0) {
data_len = chunks[paged_CHUNK_DATA_0].iov_len % ALIGNMENT_SIZE; data_len = chunks[paged_CHUNK_DATA_0].iov_len % ALIGNMENT_SIZE;
D6(fprintf(debug_file, "_algn006: data_len=%d, @ %06d\n", data_len, get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "_algn006: data_len=%d, @ %07d\n", data_len, get_fpga_usec(state->fd_fparmsall[0], 0)));
src = vectrpos(&chunks[CHUNK_DATA_0], data_len); src = vectrpos(&chunks[CHUNK_DATA_0], data_len);
vectcpy(&chunks[paged_CHUNK_ALIGN], src, data_len); vectcpy(&chunks[paged_CHUNK_ALIGN], src, data_len);
vectshrink(&chunks[paged_CHUNK_DATA_0], data_len); vectshrink(&chunks[paged_CHUNK_DATA_0], data_len);
} else { } else {
data_len = chunks[paged_CHUNK_DATA_1].iov_len % ALIGNMENT_SIZE; data_len = chunks[paged_CHUNK_DATA_1].iov_len % ALIGNMENT_SIZE;
D6(fprintf(debug_file, "_algn007: data_len=%d, @ %06d\n", data_len, get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "_algn007: data_len=%d, @ %07d\n", data_len, get_fpga_usec(state->fd_fparmsall[0], 0)));
src = vectrpos(&chunks[paged_CHUNK_DATA_1], data_len); src = vectrpos(&chunks[paged_CHUNK_DATA_1], data_len);
vectcpy(&chunks[paged_CHUNK_ALIGN], src, data_len); vectcpy(&chunks[paged_CHUNK_ALIGN], src, data_len);
vectshrink(&chunks[paged_CHUNK_DATA_1], data_len); vectshrink(&chunks[paged_CHUNK_DATA_1], data_len);
...@@ -614,7 +614,7 @@ void align_frame(camogm_state *state) ...@@ -614,7 +614,7 @@ void align_frame(camogm_state *state)
dev_dbg(NULL, "ERROR: the number of bytes copied to common buffer exceeds its size\n"); dev_dbg(NULL, "ERROR: the number of bytes copied to common buffer exceeds its size\n");
} }
check_chunks(chunks, page); check_chunks(chunks, page);
D6(fprintf(debug_file, "align_frame() DONE @ %06d\n", get_fpga_usec(state->fd_fparmsall[0], 0))); D6(fprintf(debug_file, "align_frame() DONE @ %07d\n", get_fpga_usec(state->fd_fparmsall[0], 0)));
} }
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
#include <sys/types.h> #include <sys/types.h>
#include "camogm.h" #include "camogm.h"
// TODO: Change PHY_BLOCK_SIZE to 4096 as it is 4096! // TODO: Change PHY_BLOCK_SIZE to 4096 as it is 4096 - no, most SSDs are still 512
//#define PHY_BLOCK_SIZE 512 ///< Physical disk block size #define PHY_BLOCK_SIZE 512 ///< Physical disk block size - still 512 even for the OS with 4096
#define PHY_BLOCK_SIZE 4096 ///< Physical disk block size //#define PHY_BLOCK_SIZE 4096 ///< Physical disk block size
#define JPEG_MARKER_LEN 2 ///< The size in bytes of JPEG marker #define JPEG_MARKER_LEN 2 ///< The size in bytes of JPEG marker
#define JPEG_SIZE_LEN 2 ///< The size in bytes of JPEG marker length field #define JPEG_SIZE_LEN 2 ///< The size in bytes of JPEG marker length field
#define INCLUDE_REM 1 ///< Include REM buffer to total size calculation #define INCLUDE_REM 1 ///< Include REM buffer to total size calculation
......
This diff is collapsed.
...@@ -68,15 +68,25 @@ ...@@ -68,15 +68,25 @@
*! *!
*/ */
define('SSD_ROOT', '/mnt/sda1/'); define('SSD_ROOT', '/mnt/sda1/');
define('ASSUME_EXT4', 'sda1'); // comment out after testing
define('USE_SYSLOG', 1);
$cmd = $_GET['cmd']; $cmd = $_GET['cmd'];
$debug = $_GET['debug']; $debug = $_GET['debug'];
$debuglev = $_GET['debuglev']; $debuglev = $_GET['debuglev'];
$cmd_pipe = "/var/state/camogm_cmd"; $cmd_pipe = "/var/state/camogm_cmd";
$cmd_state = "/var/state/camogm.state"; $cmd_state = "/var/state/camogm.state";
$cmd_port = "3456"; $cmd_port = "3456";
$default_state = "/home/root/camogm.disk"; //$default_state = "/home/root/camogm.disk";
$state_file = "/mnt/sda1/camogm.disk"; $default_state = "/etc/elphel393/camogm.disk";
//$state_file = "/mnt/sda1/camogm.disk";
$state_file = "/etc/elphel393/camogm.disk";
$start_str = "camogm -n " . $cmd_pipe . " -p " . $cmd_port; $start_str = "camogm -n " . $cmd_pipe . " -p " . $cmd_port;
if (defined('USE_SYSLOG')) {
syslog(LOG_NOTICE, "camogm_interface.php:");
foreach ($_GET as $k => $v){
syslog(LOG_NOTICE, $k ." -> ".$v);
}
}
function check_camogm_running(){ function check_camogm_running(){
global $start_str; global $start_str;
...@@ -128,7 +138,9 @@ if ($cmd == "run_camogm") ...@@ -128,7 +138,9 @@ if ($cmd == "run_camogm")
} }
// set fast recording mode if there is at least one suitable partition or revert to legacy 'mov' mode // set fast recording mode if there is at least one suitable partition or revert to legacy 'mov' mode
if (defined('USE_SYSLOG')) syslog(LOG_NOTICE, "before get_raw_dev()");
$partitions = get_raw_dev(); $partitions = get_raw_dev();
if (defined('USE_SYSLOG')) syslog(LOG_NOTICE, "after get_raw_dev()");
if (!empty($partitions)) { if (!empty($partitions)) {
reset($partitions); reset($partitions);
$cmd_str = 'format=jpeg;' . 'rawdev_path=' . key($partitions) . ';'; $cmd_str = 'format=jpeg;' . 'rawdev_path=' . key($partitions) . ';';
...@@ -193,6 +205,9 @@ else if ($cmd == "run_status") ...@@ -193,6 +205,9 @@ else if ($cmd == "run_status")
else if ($cmd=="get_hdd_space"){ else if ($cmd=="get_hdd_space"){
if (isset($_GET['mountpoint'])) if (isset($_GET['mountpoint']))
$mountpoint = $_GET['mountpoint']; $mountpoint = $_GET['mountpoint'];
if (!$mountpoint){
$mountpoint = '/mnt/sda1';
}
else else
$mountpoint = '/mnt/sda1'; $mountpoint = '/mnt/sda1';
// make sure something is mounted on mountpoint // make sure something is mounted on mountpoint
...@@ -750,7 +765,15 @@ function get_mnt_dev() ...@@ -750,7 +765,15 @@ function get_mnt_dev()
foreach ($partitions as $partition => $size) { foreach ($partitions as $partition => $size) {
$res = array(); $res = array();
$dev = "/dev/" . $partition; $dev = "/dev/" . $partition;
if (!empty(ASSUME_EXT4)) { // avoiding I/O operations with /dev/sda
if ($partition == ASSUME_EXT4) {
$res = "ext4";
} else {
$res = "";
}
} else {
exec("blkid " . $dev, $res); exec("blkid " . $dev, $res);
}
if (!empty($res)) { if (!empty($res)) {
$devices[$i] = preg_replace('/: +.*/', "", $res[0]); $devices[$i] = preg_replace('/: +.*/', "", $res[0]);
if (preg_match('/(?<=TYPE=")[a-z0-9]+(?=")/', $res[0], $fs) == 1) if (preg_match('/(?<=TYPE=")[a-z0-9]+(?=")/', $res[0], $fs) == 1)
......
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