Skip to content

Commit

Permalink
Method renames as preparation for libpktriggercord
Browse files Browse the repository at this point in the history
copyright -> pslr_copyright
camera_close -> pslr_camera_close
camera_connect -> pslr_camera_connect
collect_settings_info -> pslr_get_settings_info
collect_status_info -> pslr_get_status_info
debug_onoff -> pslr_set_debugmode
file_formats -> pslr_user_file_formats
find_model_by_id -> pslr_find_model_by_id
find_setting_by_name -> pslr_find_setting_by_name
format_rational -> pslr_format_rational
get_file_format_t -> pslr_get_user_file_format_t
get_hw_jpeg_quality -> pslr_get_hw_jpeg_quality
get_lens_name -> pslr_get_lens_name
get_pslr_ae_metering -> pslr_get_ae_metering
get_pslr_af_mode -> pslr_get_af_mode
get_pslr_af_point_sel -> pslr_get_af_point_sel
get_pslr_af11_point_str -> pslr_get_af11_point_str
get_pslr_color_space -> pslr_get_color_space
get_pslr_custom_ev_steps_str -> pslr_get_custom_ev_steps_str
get_pslr_custom_sensitivity_steps_str -> pslr_get_custom_sensitivity_steps_str
get_pslr_drive_mode -> pslr_get_drive_mode
get_pslr_flash_mode -> pslr_get_flash_mode
get_pslr_image_format_str -> pslr_get_image_format_str
get_pslr_jpeg_image_tone -> pslr_get_jpeg_image_tone
get_pslr_raw_format_str -> pslr_get_raw_format_str
get_pslr_scene_mode_str -> pslr_get_scene_mode_str
get_pslr_white_balance_mode -> pslr_get_white_balance_mode
get_user_file_format -> pslr_get_user_file_format
pslr_camera_name -> pslr_get_camera_name
pslr_read_datetime -> pslr_get_datetime
pslr_read_dspinfo -> pslr_get_dspinfo
pslr_read_setting -> pslr_get_setting
pslr_select_af_point -> pslr_set_selected_af_point
pslr_set_ec -> plsr_set_expose_compensation
pslr_write_setting -> pslr_set_setting
shexdump -> pslr_hexdump
  • Loading branch information
blemasle authored and asalamon74 committed Feb 12, 2021
1 parent 6bc0b80 commit bdba056
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 210 deletions.
74 changes: 37 additions & 37 deletions pktriggercord-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ void save_memory(pslr_handle_t camhandle, int fd, uint32_t length) {

void print_status_info( pslr_handle_t h, pslr_status status ) {
printf("\n");
printf( "%s", collect_status_info( h, status ) );
printf( "%s", pslr_get_status_info( h, status ) );
}

void print_settings_info( pslr_handle_t h, pslr_settings settings ) {
printf("\n");
printf( "%s", collect_settings_info( h, settings ) );
printf( "%s", pslr_get_settings_info( h, settings ) );
}

void usage(char *name) {
Expand Down Expand Up @@ -307,7 +307,7 @@ char *copyright_version(char *name, char *version) {
sprintf(ret, "%s %s\n\n\%s\
License LGPLv3: GNU LGPL version 3 <http://gnu.org/licenses/lgpl.html>\n\
This is free software: you are free to change and redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law.\n", name, version, copyright() );
There is NO WARRANTY, to the extent permitted by law.\n", name, version, pslr_copyright() );
return ret;
}

Expand Down Expand Up @@ -342,17 +342,17 @@ void bulb_old(pslr_handle_t camhandle, pslr_rational_t shutter_speed, struct tim

void bulb_new(pslr_handle_t camhandle, pslr_rational_t shutter_speed) {
if (pslr_has_setting_by_name(camhandle, "bulb_timer")) {
pslr_write_setting_by_name(camhandle, "bulb_timer", 1);
pslr_set_setting_by_name(camhandle, "bulb_timer", 1);
} else if (pslr_has_setting_by_name(camhandle, "astrotracer")) {
pslr_write_setting_by_name(camhandle, "astrotracer", 1);
pslr_set_setting_by_name(camhandle, "astrotracer", 1);
} else {
fprintf(stderr, "New bulb mode is not supported for this camera model\n");
}
int bulb_sec = (int)(shutter_speed.nom / shutter_speed.denom);
if (pslr_has_setting_by_name(camhandle, "bulb_timer_sec")) {
pslr_write_setting_by_name(camhandle, "bulb_timer_sec", bulb_sec);
pslr_set_setting_by_name(camhandle, "bulb_timer_sec", bulb_sec);
} else if (pslr_has_setting_by_name(camhandle, "astrotracer_timer_sec")) {
pslr_write_setting_by_name(camhandle, "astrotracer_timer_sec", bulb_sec);
pslr_set_setting_by_name(camhandle, "astrotracer_timer_sec", bulb_sec);
} else {
fprintf(stderr, "New bulb mode is not supported for this camera model\n");
}
Expand All @@ -362,11 +362,11 @@ void bulb_new(pslr_handle_t camhandle, pslr_rational_t shutter_speed) {
void bulb_new_cleanup(pslr_handle_t camhandle) {
if (pslr_has_setting_by_name(camhandle, "bulb_timer")) {
if (!bulb_timer_before) {
pslr_write_setting_by_name(camhandle, "bulb_timer", bulb_timer_before);
pslr_set_setting_by_name(camhandle, "bulb_timer", bulb_timer_before);
}
} else if (pslr_has_setting_by_name(camhandle, "astrotracer")) {
if (!astrotracer_before) {
pslr_write_setting_by_name(camhandle, "astrotracer", astrotracer_before);
pslr_set_setting_by_name(camhandle, "astrotracer", astrotracer_before);
}
}
}
Expand Down Expand Up @@ -535,43 +535,43 @@ int main(int argc, char **argv) {
break;

case 7:
color_space = get_pslr_color_space( optarg );
color_space = pslr_get_color_space( optarg );
if ( color_space == (pslr_color_space_t)(-1) ) {
warning_message("%s: Invalid color space\n", argv[0]);
}
break;

case 8:
af_mode = get_pslr_af_mode( optarg );
af_mode = pslr_get_af_mode( optarg );
if ( af_mode == (pslr_af_mode_t)(-1) || af_mode == (pslr_af_mode_t)(0) ) {
// 0: changing MF does not work
warning_message("%s: Invalid af mode\n", argv[0]);
}
break;

case 9:
ae_metering = get_pslr_ae_metering( optarg );
ae_metering = pslr_get_ae_metering( optarg );
if ( ae_metering == (pslr_ae_metering_t)(-1) ) {
warning_message("%s: Invalid ae metering\n", argv[0]);
}
break;

case 10:
flash_mode = get_pslr_flash_mode( optarg );
flash_mode = pslr_get_flash_mode( optarg );
if ( flash_mode == (pslr_flash_mode_t)(-1) ) {
warning_message("%s: Invalid flash_mode\n", argv[0]);
}
break;

case 11:
drive_mode = get_pslr_drive_mode( optarg );
drive_mode = pslr_get_drive_mode( optarg );
if ( drive_mode == (pslr_drive_mode_t)(-1) ) {
warning_message("%s: Invalid drive_mode\n", argv[0]);
}
break;

case 12:
af_point_sel = get_pslr_af_point_sel( optarg );
af_point_sel = pslr_get_af_point_sel( optarg );
if ( af_point_sel == (pslr_af_point_sel_t)(-1) ) {
af_point_selected = atoi(optarg);
if (af_point_selected != 0) {
Expand All @@ -583,14 +583,14 @@ int main(int argc, char **argv) {
break;

case 13:
jpeg_image_tone = get_pslr_jpeg_image_tone( optarg );
jpeg_image_tone = pslr_get_jpeg_image_tone( optarg );
if ( jpeg_image_tone == -1 ) {
warning_message("%s: Invalid jpeg_image_tone\n", argv[0]);
}
break;

case 14:
white_balance_mode = get_pslr_white_balance_mode( optarg );
white_balance_mode = pslr_get_white_balance_mode( optarg );
if ( white_balance_mode == (pslr_white_balance_mode_t)(-1) ) {
warning_message("%s: Invalid white_balance_mode\n", argv[0]);
}
Expand Down Expand Up @@ -791,12 +791,12 @@ int main(int argc, char **argv) {

char buf[2100];

if ( !(camhandle = camera_connect( model, device, timeout, buf)) ) {
if ( !(camhandle = pslr_camera_connect( model, device, timeout, buf)) ) {
printf("%s", buf);
exit(-1);
}

camera_name = pslr_camera_name(camhandle);
camera_name = pslr_get_camera_name(camhandle);
printf("%s: %s Connected...\n", argv[0], camera_name);

if ( dump_memory_size > 0 ) {
Expand All @@ -808,15 +808,15 @@ int main(int argc, char **argv) {
printf("Dumping system memory to %s\n", DUMP_FILE_NAME);
save_memory(camhandle, dfd, dump_memory_size);
close(dfd);
camera_close(camhandle);
pslr_camera_close(camhandle);
exit(0);
}
}

/* if debug mode switch is on, there is a possibility someone just want to alter debug mode */
if ( modify_debug_mode == 1) {
debug_onoff(camhandle,debug_mode);
camera_close(camhandle);
pslr_set_debugmode(camhandle,debug_mode);
pslr_camera_close(camhandle);
exit(0);
}

Expand All @@ -833,7 +833,7 @@ int main(int argc, char **argv) {
if ( af_point_sel != (pslr_af_point_sel_t)(-1) ) {
pslr_set_af_point_sel( camhandle, af_point_sel );
if (af_point_selected != 0) {
pslr_select_af_point(camhandle, af_point_selected);
pslr_set_selected_af_point(camhandle, af_point_selected);
}
}

Expand Down Expand Up @@ -869,7 +869,7 @@ int main(int argc, char **argv) {
// not specified
if ( !pslr_get_model_only_limited( camhandle ) ) {
// use the default of the camera
uff = get_user_file_format( &status );
uff = pslr_get_user_file_format( &status );
} else {
// use PEF, since all the camera supports this
uff = USER_FILE_FORMAT_PEF;
Expand Down Expand Up @@ -898,7 +898,7 @@ int main(int argc, char **argv) {
}

if ( ec.denom ) {
pslr_set_ec( camhandle, ec );
plsr_set_expose_compensation( camhandle, ec );
}

if ( fec.denom ) {
Expand Down Expand Up @@ -966,20 +966,20 @@ int main(int argc, char **argv) {

if (read_datetime) {
int year=0, month=0, day=0, hour=0, min=0, sec=0;
pslr_read_datetime(camhandle, &year, &month, &day, &hour, &min, &sec);
pslr_get_datetime(camhandle, &year, &month, &day, &hour, &min, &sec);
printf("%04d/%02d/%02d %02d:%02d:%02d\n", year, month, day, hour, min, sec);
camera_close(camhandle);
pslr_camera_close(camhandle);
exit(0);
}

if (read_firmware_version || debug) {
char firmware[16];
pslr_read_dspinfo( camhandle, firmware );
pslr_get_dspinfo( camhandle, firmware );
if (!read_firmware_version) {
DPRINT("Firmware version: %s\n", firmware);
} else {
printf("Firmware version: %s\n", firmware);
camera_close(camhandle);
pslr_camera_close(camhandle);
exit(0);
}
}
Expand Down Expand Up @@ -1012,20 +1012,20 @@ int main(int argc, char **argv) {
printf("--settings is not supported for this camera model\n");
}
}
camera_close(camhandle);
pslr_camera_close(camhandle);
exit(0);
}

if ( dust ) {
pslr_dust_removal(camhandle);
camera_close(camhandle);
pslr_camera_close(camhandle);
exit(0);
}

if (frames == 0) {
// no action specified
print_status_info( camhandle, status );
camera_close(camhandle);
pslr_camera_close(camhandle);
exit(-1);
}

Expand All @@ -1036,7 +1036,7 @@ int main(int argc, char **argv) {
}

double waitsec=0;
user_file_format_t ufft = *get_file_format_t(uff);
user_file_format_t ufft = *pslr_pslr_get_user_file_format_t(uff);
int bracket_count = status.auto_bracket_picture_count;
if ( bracket_count < 1 || status.auto_bracket_mode == 0 ) {
bracket_count = 1;
Expand All @@ -1050,7 +1050,7 @@ int main(int argc, char **argv) {
DPRINT("cont: %d\n", continuous);

if (pslr_get_model_bufmask_single(camhandle) && bracket_count >1 && settings.one_push_bracketing.pslr_setting_status == PSLR_SETTING_STATUS_READ && settings.one_push_bracketing.value) {
pslr_write_setting_by_name(camhandle, "one_push_bracketing", 0);
pslr_set_setting_by_name(camhandle, "one_push_bracketing", 0);
settings.one_push_bracketing.value=false;
need_one_push_bracketing_cleanup = true;
}
Expand All @@ -1059,7 +1059,7 @@ int main(int argc, char **argv) {
gettimeofday(&current_time, NULL);
if ( bracket_count <= bracket_index ) {
if ( reconnect ) {
camera_close( camhandle );
pslr_camera_close( camhandle );
while (!(camhandle = pslr_init( model, device ))) {
sleep_sec(1);
}
Expand Down Expand Up @@ -1134,9 +1134,9 @@ int main(int argc, char **argv) {
bulb_new_cleanup(camhandle);
}
if (need_one_push_bracketing_cleanup) {
pslr_write_setting_by_name(camhandle, "one_push_bracketing", 1);
pslr_set_setting_by_name(camhandle, "one_push_bracketing", 1);
}
camera_close(camhandle);
pslr_camera_close(camhandle);

exit(0);
}
18 changes: 9 additions & 9 deletions pktriggercord-servermode.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ pslr_rational_t parse_aperture(char *aperture_str) {
return aperture;
}

void camera_close(pslr_handle_t camhandle) {
void pslr_camera_close(pslr_handle_t camhandle) {
pslr_disconnect(camhandle);
pslr_shutdown(camhandle);
}

pslr_handle_t camera_connect( char *model, char *device, int timeout, char *error_message ) {
pslr_handle_t pslr_camera_connect( char *model, char *device, int timeout, char *error_message ) {
struct timeval prev_time;
struct timeval current_time;
pslr_handle_t camhandle;
Expand Down Expand Up @@ -258,13 +258,13 @@ int servermode_socket(int servermode_timeout) {
DPRINT(":%s:\n",client_message);
if ( !strcmp(client_message, "stopserver" ) ) {
if ( camhandle ) {
camera_close(camhandle);
pslr_camera_close(camhandle);
}
write_socket_answer("0\n");
exit(0);
} else if ( !strcmp(client_message, "disconnect" ) ) {
if ( camhandle ) {
camera_close(camhandle);
pslr_camera_close(camhandle);
}
write_socket_answer("0\n");
} else if ( (arg = is_string_prefix( client_message, "echo")) != NULL ) {
Expand All @@ -277,7 +277,7 @@ int servermode_socket(int servermode_timeout) {
} else if ( !strcmp(client_message, "connect") ) {
if ( camhandle ) {
write_socket_answer("0\n");
} else if ( (camhandle = camera_connect( NULL, NULL, -1, buf )) ) {
} else if ( (camhandle = pslr_camera_connect( NULL, NULL, -1, buf )) ) {
write_socket_answer("0\n");
} else {
write_socket_answer(buf);
Expand All @@ -293,12 +293,12 @@ int servermode_socket(int servermode_timeout) {
}
} else if ( !strcmp(client_message, "get_camera_name") ) {
if ( check_camera(camhandle) ) {
sprintf(buf, "%d %s\n", 0, pslr_camera_name(camhandle));
sprintf(buf, "%d %s\n", 0, pslr_get_camera_name(camhandle));
write_socket_answer(buf);
}
} else if ( !strcmp(client_message, "get_lens_name") ) {
} else if ( !strcmp(client_message, "pslr_get_lens_name") ) {
if ( check_camera(camhandle) ) {
sprintf(buf, "%d %s\n", 0, get_lens_name(status.lens_id1, status.lens_id2));
sprintf(buf, "%d %s\n", 0, pslr_get_lens_name(status.lens_id1, status.lens_id2));
write_socket_answer(buf);
}
} else if ( !strcmp(client_message, "get_current_shutter_speed") ) {
Expand All @@ -308,7 +308,7 @@ int servermode_socket(int servermode_timeout) {
}
} else if ( !strcmp(client_message, "get_current_aperture") ) {
if ( check_camera(camhandle) ) {
sprintf(buf, "%d %s\n", 0, format_rational( status.current_aperture, "%.1f"));
sprintf(buf, "%d %s\n", 0, pslr_format_rational( status.current_aperture, "%.1f"));
write_socket_answer(buf);
}
} else if ( !strcmp(client_message, "get_current_iso") ) {
Expand Down
4 changes: 2 additions & 2 deletions pktriggercord-servermode.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

int servermode_socket(int servermode_timeout);

pslr_handle_t camera_connect( char *model, char *device, int timeout, char *error_message );
pslr_handle_t pslr_camera_connect( char *model, char *device, int timeout, char *error_message );

void camera_close(pslr_handle_t camhandle);
void pslr_camera_close(pslr_handle_t camhandle);

double timeval_diff_sec(struct timeval *t2, struct timeval *t1);
pslr_rational_t parse_shutter_speed(char *shutter_speed_str);
Expand Down
Loading

0 comments on commit bdba056

Please sign in to comment.