Loading src/camogm.c +40 −8 Original line number Original line Diff line number Diff line Loading @@ -112,7 +112,8 @@ pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER; */ */ typedef enum { typedef enum { RAW_PATH, RAW_PATH, FILE_PATH FILE_PATH, RAW_STATE } path_type; } path_type; enum sysfs_path_type { enum sysfs_path_type { Loading Loading @@ -355,8 +356,16 @@ int camogm_start(camogm_state *state) D0(fprintf(debug_file, "Raw device write initiated, but file format is not JPEG. Will not start\n")); D0(fprintf(debug_file, "Raw device write initiated, but file format is not JPEG. Will not start\n")); return CAMOGM_FRAME_OTHER; return CAMOGM_FRAME_OTHER; } } if (state->rawdev_op){ copy_state_file(state); // copy camogm.disk to named state file, fill be used when downloading data as file_start parameter D1(fprintf(debug_file, "Starting raw data recording, marked %s, state->path='%s'\n", get_state_path(state), state->path)); D1(syslog (LOG_INFO, "Starting raw data recording, marked %s", get_state_path(state))); next_state_path(state); // increment path so next time will use different one. } else { D1(fprintf(debug_file, "Starting file system recording to %s\n", state->path)); D1(syslog (LOG_INFO, "Starting file system recording to %s", state->path)); D1(fprintf(debug_file, "Starting recording\n")); } double dtime_stamp; double dtime_stamp; state->frameno = 0; state->frameno = 0; Loading Loading @@ -890,6 +899,7 @@ int camogm_stop(camogm_state *state) pthread_mutex_lock(&state->mutex); pthread_mutex_lock(&state->mutex); state->prog_state = STATE_STOPPED; state->prog_state = STATE_STOPPED; pthread_mutex_unlock(&state->mutex); pthread_mutex_unlock(&state->mutex); D1(fprintf(debug_file, "Ended recording\n")); DFLUSH; DFLUSH; return 0; return 0; } } Loading Loading @@ -1006,11 +1016,25 @@ void camogm_set_dummy_read(camogm_state *state, int d) * the file name as is. * the file name as is. * @param[in] type the type of prefix, can be one of #path_type * @param[in] type the type of prefix, can be one of #path_type */ */ void camogm_set_prefix(camogm_state *state, const char * p, path_type type) void camogm_set_prefix(camogm_state *state, const char * p, path_type type) // may use cookies to remember file { { if (type == FILE_PATH) { D1(fprintf(debug_file, "Set prefix: '%s', mode=%d\n", p, (int) type)); strncpy(state->path_prefix, p, sizeof(state->path_prefix) - 1); D1(syslog (LOG_INFO, "Set prefix: '%s', mode=%d", p, (int) type)); // RAW_STATE if (type == RAW_STATE) { // path to state files for raw recording if (state->rawdev_op) { // only for raw mode // 07.02.2023 - use the same name as a template for camogm.disk copy set_state_file_from_prefix(state, p); // will also set state->path_prefix as an absolute path } } else if (type == FILE_PATH) { // if (state->rawdev_op) { // // 07.02.2023 - use the same name as a template for camogm.disk copy // set_state_file_from_prefix(state, p); // will also set state->path_prefix as an absolute path // } else { strncpy(state->path_prefix, p, sizeof(state->path_prefix) - 1); // cut off trailing "/"? state->path_prefix[sizeof(state->path_prefix) - 1] = '\0'; state->path_prefix[sizeof(state->path_prefix) - 1] = '\0'; // } //int set_state_file_from_prefix(rawdev_buffer *rawdev, const char * prefix){ } else if (type == RAW_PATH && (strncmp(p, "/dev/", 5) == 0)) { } else if (type == RAW_PATH && (strncmp(p, "/dev/", 5) == 0)) { strncpy(state->rawdev.rawdev_path, p, sizeof(state->rawdev.rawdev_path) - 1); strncpy(state->rawdev.rawdev_path, p, sizeof(state->rawdev.rawdev_path) - 1); state->rawdev.rawdev_path[sizeof(state->rawdev.rawdev_path) - 1] = '\0'; state->rawdev.rawdev_path[sizeof(state->rawdev.rawdev_path) - 1] = '\0'; Loading Loading @@ -1539,8 +1563,11 @@ int parse_cmd(camogm_state *state, FILE* npipe) camogm_set_segment_length(state, d); camogm_set_segment_length(state, d); return 5; return 5; } else if (strcmp(cmd, "prefix") == 0) { } else if (strcmp(cmd, "prefix") == 0) { if (args) camogm_set_prefix(state, args, FILE_PATH); if (args) camogm_set_prefix(state, args, FILE_PATH); //RAW_STATE return 6; return 6; } else if (strcmp(cmd, "prefix_raw") == 0) { if (args) camogm_set_prefix(state, args, RAW_STATE); return 31; } else if (strcmp(cmd, "status") == 0) { } else if (strcmp(cmd, "status") == 0) { camogm_status(state, args, 0); camogm_status(state, args, 0); return 7; return 7; Loading Loading @@ -1680,6 +1707,8 @@ int parse_cmd(camogm_state *state, FILE* npipe) return -1; return -1; } } /** /** * @brief This function closes open files, terminates reading thread and deletes allocated memory. * @brief This function closes open files, terminates reading thread and deletes allocated memory. * @param[in] state pointer to #camogm_state structure for a particular sensor channel * @param[in] state pointer to #camogm_state structure for a particular sensor channel Loading Loading @@ -2423,9 +2452,12 @@ int main(int argc, char *argv[]) if (str_len > 0) { if (str_len > 0) { strncpy(sstate.rawdev.state_path, (const char *)state_name_str, str_len + 1); strncpy(sstate.rawdev.state_path, (const char *)state_name_str, str_len + 1); } } ret = get_state_directory(&sstate); D2(syslog (LOG_INFO, "%s:line %d : get_state_directory() -> %d @ %07d\n", \ __FILE__, __LINE__, ret, get_fpga_usec(sstate.fd_fparmsall[0], 0))); ret = listener_loop(&sstate); ret = listener_loop(&sstate); return ret; return ret; Loading src/camogm.h +5 −0 Original line number Original line Diff line number Diff line Loading @@ -228,6 +228,11 @@ typedef struct { unsigned char *disk_mmap; unsigned char *disk_mmap; int sysfs_fd; int sysfs_fd; char state_path[ELPHEL_PATH_MAX]; char state_path[ELPHEL_PATH_MAX]; // char state_directory[ELPHEL_PATH_MAX]; // copy state file (camogm.disk) to the same directory when starting record. Can be used // "<last_state_prefix>_<last_state_index> char state_prefix[ELPHEL_PATH_MAX]; // absolute int state_index; } rawdev_buffer; } rawdev_buffer; /** /** Loading Loading
src/camogm.c +40 −8 Original line number Original line Diff line number Diff line Loading @@ -112,7 +112,8 @@ pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER; */ */ typedef enum { typedef enum { RAW_PATH, RAW_PATH, FILE_PATH FILE_PATH, RAW_STATE } path_type; } path_type; enum sysfs_path_type { enum sysfs_path_type { Loading Loading @@ -355,8 +356,16 @@ int camogm_start(camogm_state *state) D0(fprintf(debug_file, "Raw device write initiated, but file format is not JPEG. Will not start\n")); D0(fprintf(debug_file, "Raw device write initiated, but file format is not JPEG. Will not start\n")); return CAMOGM_FRAME_OTHER; return CAMOGM_FRAME_OTHER; } } if (state->rawdev_op){ copy_state_file(state); // copy camogm.disk to named state file, fill be used when downloading data as file_start parameter D1(fprintf(debug_file, "Starting raw data recording, marked %s, state->path='%s'\n", get_state_path(state), state->path)); D1(syslog (LOG_INFO, "Starting raw data recording, marked %s", get_state_path(state))); next_state_path(state); // increment path so next time will use different one. } else { D1(fprintf(debug_file, "Starting file system recording to %s\n", state->path)); D1(syslog (LOG_INFO, "Starting file system recording to %s", state->path)); D1(fprintf(debug_file, "Starting recording\n")); } double dtime_stamp; double dtime_stamp; state->frameno = 0; state->frameno = 0; Loading Loading @@ -890,6 +899,7 @@ int camogm_stop(camogm_state *state) pthread_mutex_lock(&state->mutex); pthread_mutex_lock(&state->mutex); state->prog_state = STATE_STOPPED; state->prog_state = STATE_STOPPED; pthread_mutex_unlock(&state->mutex); pthread_mutex_unlock(&state->mutex); D1(fprintf(debug_file, "Ended recording\n")); DFLUSH; DFLUSH; return 0; return 0; } } Loading Loading @@ -1006,11 +1016,25 @@ void camogm_set_dummy_read(camogm_state *state, int d) * the file name as is. * the file name as is. * @param[in] type the type of prefix, can be one of #path_type * @param[in] type the type of prefix, can be one of #path_type */ */ void camogm_set_prefix(camogm_state *state, const char * p, path_type type) void camogm_set_prefix(camogm_state *state, const char * p, path_type type) // may use cookies to remember file { { if (type == FILE_PATH) { D1(fprintf(debug_file, "Set prefix: '%s', mode=%d\n", p, (int) type)); strncpy(state->path_prefix, p, sizeof(state->path_prefix) - 1); D1(syslog (LOG_INFO, "Set prefix: '%s', mode=%d", p, (int) type)); // RAW_STATE if (type == RAW_STATE) { // path to state files for raw recording if (state->rawdev_op) { // only for raw mode // 07.02.2023 - use the same name as a template for camogm.disk copy set_state_file_from_prefix(state, p); // will also set state->path_prefix as an absolute path } } else if (type == FILE_PATH) { // if (state->rawdev_op) { // // 07.02.2023 - use the same name as a template for camogm.disk copy // set_state_file_from_prefix(state, p); // will also set state->path_prefix as an absolute path // } else { strncpy(state->path_prefix, p, sizeof(state->path_prefix) - 1); // cut off trailing "/"? state->path_prefix[sizeof(state->path_prefix) - 1] = '\0'; state->path_prefix[sizeof(state->path_prefix) - 1] = '\0'; // } //int set_state_file_from_prefix(rawdev_buffer *rawdev, const char * prefix){ } else if (type == RAW_PATH && (strncmp(p, "/dev/", 5) == 0)) { } else if (type == RAW_PATH && (strncmp(p, "/dev/", 5) == 0)) { strncpy(state->rawdev.rawdev_path, p, sizeof(state->rawdev.rawdev_path) - 1); strncpy(state->rawdev.rawdev_path, p, sizeof(state->rawdev.rawdev_path) - 1); state->rawdev.rawdev_path[sizeof(state->rawdev.rawdev_path) - 1] = '\0'; state->rawdev.rawdev_path[sizeof(state->rawdev.rawdev_path) - 1] = '\0'; Loading Loading @@ -1539,8 +1563,11 @@ int parse_cmd(camogm_state *state, FILE* npipe) camogm_set_segment_length(state, d); camogm_set_segment_length(state, d); return 5; return 5; } else if (strcmp(cmd, "prefix") == 0) { } else if (strcmp(cmd, "prefix") == 0) { if (args) camogm_set_prefix(state, args, FILE_PATH); if (args) camogm_set_prefix(state, args, FILE_PATH); //RAW_STATE return 6; return 6; } else if (strcmp(cmd, "prefix_raw") == 0) { if (args) camogm_set_prefix(state, args, RAW_STATE); return 31; } else if (strcmp(cmd, "status") == 0) { } else if (strcmp(cmd, "status") == 0) { camogm_status(state, args, 0); camogm_status(state, args, 0); return 7; return 7; Loading Loading @@ -1680,6 +1707,8 @@ int parse_cmd(camogm_state *state, FILE* npipe) return -1; return -1; } } /** /** * @brief This function closes open files, terminates reading thread and deletes allocated memory. * @brief This function closes open files, terminates reading thread and deletes allocated memory. * @param[in] state pointer to #camogm_state structure for a particular sensor channel * @param[in] state pointer to #camogm_state structure for a particular sensor channel Loading Loading @@ -2423,9 +2452,12 @@ int main(int argc, char *argv[]) if (str_len > 0) { if (str_len > 0) { strncpy(sstate.rawdev.state_path, (const char *)state_name_str, str_len + 1); strncpy(sstate.rawdev.state_path, (const char *)state_name_str, str_len + 1); } } ret = get_state_directory(&sstate); D2(syslog (LOG_INFO, "%s:line %d : get_state_directory() -> %d @ %07d\n", \ __FILE__, __LINE__, ret, get_fpga_usec(sstate.fd_fparmsall[0], 0))); ret = listener_loop(&sstate); ret = listener_loop(&sstate); return ret; return ret; Loading
src/camogm.h +5 −0 Original line number Original line Diff line number Diff line Loading @@ -228,6 +228,11 @@ typedef struct { unsigned char *disk_mmap; unsigned char *disk_mmap; int sysfs_fd; int sysfs_fd; char state_path[ELPHEL_PATH_MAX]; char state_path[ELPHEL_PATH_MAX]; // char state_directory[ELPHEL_PATH_MAX]; // copy state file (camogm.disk) to the same directory when starting record. Can be used // "<last_state_prefix>_<last_state_index> char state_prefix[ELPHEL_PATH_MAX]; // absolute int state_index; } rawdev_buffer; } rawdev_buffer; /** /** Loading