Commit a7ffbc6d authored by Andrey Filippov's avatar Andrey Filippov

restored version with /mnt/sda1/camogm.disk

parent ba98b0cf
......@@ -163,8 +163,9 @@ static int get_sysfs_name(const char *dev_name, char *sys_name, size_t str_sz, i
static int get_disk_range(const char *name, struct range *rng);
static int set_disk_range(const struct range *rng);
static void get_disk_info(camogm_state *state);
#if 0
static struct timeval get_fpga_time(const int fd_fparsall, unsigned int port);
#endif
int open_files(camogm_state *state);
unsigned long getGPValue(unsigned int port, unsigned long GPNumber);
void setGValue(unsigned int port, unsigned long GNumber, unsigned long value);
......@@ -342,7 +343,6 @@ int camogm_start(camogm_state *state)
{
int timestamp_start;
int rslt;
int dummy;
int next_metadata_start, next_jpeg_len, fp;
int port = state->port_num;
int i, used_space;
......@@ -547,7 +547,7 @@ int camogm_start(camogm_state *state)
}
// and read it
lseek(state->fd_head[chn], 0, 0);
dummy=read(state->fd_head[chn], state->jpegHeader[chn], state->head_size[chn]); //?
read(state->fd_head[chn], state->jpegHeader[chn], state->head_size[chn]); //?
// Restore read pointer to the original (now there may be no frame ready there yet)
lseek(state->fd_circ[chn], state->cirbuf_rp[chn], SEEK_SET);
state->image_size[chn] = 0;
......@@ -592,14 +592,16 @@ int camogm_start(camogm_state *state)
int sendImageFrame(camogm_state *state)
{
int rslt;
#if USE_OGG_PACKET_TYPE
unsigned char frame_packet_type = PACKET_IS_SYNCPOINT;
#endif
int timestamp_start;
int * ifp_this = (int*)&(state->this_frame_params[state->port_num]);
int fp;
int fd_exif_tiff; // switching between TIFF and Exif depending on coloe mode
int port = state->port_num;
struct timeval start_time, end_time;
int i,j,k; //debug
// struct timeval start_time, end_time;
int i;//,j,k; //debug
int dbg_meta;
if (port < 0) {
D1(fprintf(debug_file, "sendImageFrame:0: port < 0!\n"));
......@@ -737,8 +739,10 @@ int sendImageFrame(camogm_state *state)
// prepare a packet to be sent (a lst of memory chunks)
state->chunk_index = 0;
#if USE_OGG_PACKET_TYPE
state->packetchunks[state->chunk_index ].bytes = 1;
state->packetchunks[state->chunk_index++].chunk = &frame_packet_type; // [0]
#endif
if (state->exif > 0) { // insert Exif/Tiff
D4(fprintf(debug_file, "_7_"));
if (state->this_frame_params[port].color == COLORMODE_RAW) { // Tiff
......@@ -1712,7 +1716,7 @@ int listener_loop(camogm_state *state)
{
FILE *cmd_file;
int rslt, ret, cmd, f_ok, i;
int fp0, fp1;
// int fp0, fp1;
int process = 1;
int curr_port = 0;
const char *pipe_name = state->pipe_name;
......@@ -2036,7 +2040,7 @@ static int get_sysfs_name(const char *dev_name, char *sys_name, size_t str_sz, i
*/
static int get_disk_range(const char *name, struct range *rng)
{
int ret = 0, dummy;
int ret = 0;
int fd;
uint64_t val;
char data[SMALL_BUFF_LEN] = {0};
......@@ -2047,7 +2051,7 @@ static int get_disk_range(const char *name, struct range *rng)
if (strlen(sysfs_name) > 0) {
fd = open(sysfs_name, O_RDONLY);
if (fd >= 0) {
dummy=read(fd, data, SMALL_BUFF_LEN);
read(fd, data, SMALL_BUFF_LEN);
if ((val = strtoull(data, NULL, 10)) != 0)
rng->from = val;
else
......@@ -2063,7 +2067,7 @@ static int get_disk_range(const char *name, struct range *rng)
if (get_sysfs_name(name, sysfs_name, ELPHEL_PATH_MAX, TYPE_SIZE) > 0) {
fd = open(sysfs_name, O_RDONLY);
if (fd >= 0) {
dummy=read(fd, data, SMALL_BUFF_LEN);
read(fd, data, SMALL_BUFF_LEN);
if ((val = strtoull(data, NULL, 10)) != 0)
rng->to = rng->from + val;
else
......@@ -2092,20 +2096,19 @@ static int set_disk_range(const struct range *rng)
int ret = 0;
char buff[SMALL_BUFF_LEN] = {0};
int len;
int dummy;
fd = open(SYSFS_AHCI_LBA_START, O_WRONLY);
if (fd < 0)
return -1;
len = snprintf(buff, SMALL_BUFF_LEN, "%llu", rng->from);
dummy=write(fd, buff, len + 1);
write(fd, buff, len + 1);
close(fd);
fd = open(SYSFS_AHCI_LBA_END, O_WRONLY);
if (fd < 0)
return -1;
len = snprintf(buff, SMALL_BUFF_LEN, "%llu", rng->to);
dummy=write(fd, buff, len + 1);
write(fd, buff, len + 1);
close(fd);
return ret;
......@@ -2492,6 +2495,7 @@ inline int is_fd_valid(int fd)
return fcntl(fd, F_GETFD) != -1 || errno != EBADF;
}
#if 0
/**
* @brief Get current FPGA time
* @return Time value in \e timeval structure
......@@ -2507,6 +2511,7 @@ struct timeval get_fpga_time(const int fd_fparsall, unsigned int port)
return tv;
}
#endif
/**
* @brief Get current FPGA microseconds of time to use for timing of the code
......
......@@ -55,7 +55,7 @@
#define CAMOGM_MIN_BUF_FRAMES 2 ///< buffer should accomodate at list this number of frames
#define FLUSH_DEBUG 1 ///< flush debug file after each print
#define USE_OGG_PACKET_TYPE 0 /// do not prepend image with packet type, such as PACKET_IS_SYNCPOINT
#ifdef NODEBUG
#define D(x)
#define D0(x)
......
......@@ -417,7 +417,6 @@ static int read_index(rawdev_buffer *rawdev, struct disk_index **indx)
unsigned char read_buff[TIFF_HDR_OFFSET] = {0};
char str_buff[SMALL_BUFF_LEN] = {0};
uint64_t save_pos = lseek64(rawdev->rawdev_fd, 0, SEEK_CUR);
int dummy;
if (indx == NULL)
return -1;
......@@ -429,16 +428,16 @@ static int read_index(rawdev_buffer *rawdev, struct disk_index **indx)
}
if (read_buff[2] == 0xff && read_buff[3] == 0xe1) {
// get IFD0 offset from TIFF header
dummy=read(rawdev->rawdev_fd, &hdr, sizeof(struct tiff_hdr));
read(rawdev->rawdev_fd, &hdr, sizeof(struct tiff_hdr));
hdr_byte_order(&hdr);
curr_pos = rawdev->file_start + TIFF_HDR_OFFSET + hdr.offset;
lseek64(rawdev->rawdev_fd, curr_pos, SEEK_SET);
// process IFD0 and SubIFD fields
do {
dummy=read(rawdev->rawdev_fd, &num_entries, sizeof(num_entries));
read(rawdev->rawdev_fd, &num_entries, sizeof(num_entries));
num_entries = __be16_to_cpu(num_entries);
for (int i = 0; i < num_entries; i++) {
dummy=read(rawdev->rawdev_fd, &ifd, sizeof(struct ifd_entry));
read(rawdev->rawdev_fd, &ifd, sizeof(struct ifd_entry));
ifd_byte_order(&ifd);
switch (ifd.tag) {
case Exif_Image_PageNumber:
......@@ -457,7 +456,7 @@ static int read_index(rawdev_buffer *rawdev, struct disk_index **indx)
}
// ensure that IFD0 finished correctly (0x00000000 in the end), set file pointer to SubIFD and
// process remaining fields
dummy=read(rawdev->rawdev_fd, &data32, sizeof(data32));
read(rawdev->rawdev_fd, &data32, sizeof(data32));
process -= (subifd_offset == 0 || data32 != 0) ? 2 : 1;
curr_pos = rawdev->file_start + TIFF_HDR_OFFSET + subifd_offset;
lseek64(rawdev->rawdev_fd, curr_pos, SEEK_SET);
......@@ -815,11 +814,9 @@ static void send_fnum(int sockfd, size_t num)
{
char buff[SMALL_BUFF_LEN] = {0};
int len;
int dummy;
len = snprintf(buff, SMALL_BUFF_LEN - 1, "Number of files: %d\n", num);
buff[len] = '\0';
dummy=write(sockfd, buff, len);
write(sockfd, buff, len);
}
/**
......@@ -1018,7 +1015,6 @@ void *reader(void *arg)
.sockfd_const = &sockfd,
.sockfd_temp = &fd
};
int dummy;
memset(&index_dir, 0, sizeof(struct disk_idir));
memset(&index_sparse, 0, sizeof(struct disk_idir));
......@@ -1069,7 +1065,7 @@ void *reader(void *arg)
len = snprintf(send_buff, CMD_BUFF_LEN - 1, INDEX_FORMAT_STR,
disk_indx->port, disk_indx->rawtime, disk_indx->usec, disk_indx->f_offset, disk_indx->f_size);
send_buff[len] = '\0';
dummy=write(fd, send_buff, len);
write(fd, send_buff, len);
disk_indx = disk_indx->next;
}
} else {
......
......@@ -68,22 +68,22 @@
*!
*/
define('SSD_ROOT', '/mnt/sda1/');
define('ASSUME_EXT4', 'sda1'); // comment out after testing
//define('USE_SYSLOG', 1);
///define('ASSUME_EXT4', 'sda1'); // comment out after testing
define('USE_SYSLOG', 0); // 1 to write to syslog
$cmd = $_GET['cmd'];
$debug = $_GET['debug'];
$debuglev = $_GET['debuglev'];
$cmd_pipe = "/var/state/camogm_cmd";
$cmd_state = "/var/state/camogm.state";
$cmd_port = "3456";
//$default_state = "/home/root/camogm.disk";
$default_state = "/etc/elphel393/camogm.disk";
//$state_file = "/mnt/sda1/camogm.disk";
$state_file = "/etc/elphel393/camogm.disk";
$default_state = "/home/root/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;
//if (defined('USE_SYSLOG')) {
if (USE_SYSLOG > 0) {
syslog(LOG_NOTICE, "camogm_interface.php:");
syslog(LOG_NOTICE, "camogm_interface.php:");
foreach ($_GET as $k => $v){
syslog(LOG_NOTICE, $k ." -> ".$v);
}
......@@ -766,7 +766,7 @@ function get_mnt_dev()
foreach ($partitions as $partition => $size) {
$res = array();
$dev = "/dev/" . $partition;
if (!empty(ASSUME_EXT4)) { // avoiding I/O operations with /dev/sda
if (defined('ASSUME_EXT4')) { // avoiding I/O operations with /dev/sda
if ($partition == ASSUME_EXT4) {
$res = "ext4";
} else {
......
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