Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
/pktriggercord-cli
*~
*.exe
libpktriggercord.dll
/pktriggercord_commandline.html
/pktriggercord-*-win
/pktriggercord-*-win.zip
/pkTriggerCord-*.src.tar.gz
/pktriggercord-*.rpm
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ before_script:
- make -C $HOME/astyle/build/gcc
- make -C $HOME/astyle/build/gcc prefix=$HOME install
script:
- if [[ -n $(make astyle | grep Formatted) ]]; then echo "Code formatting error. Please check astyle"; exit -1; fi
- if [[ -n $(make astyle | grep Formatted) ]]; then echo "Code formatting error. Please check astyle"; exit 1; fi
- make android
- make localwin
- make srczip
Expand Down
3 changes: 0 additions & 3 deletions BUGS
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ General
Taking picture restores jpeg image tone, so jpeg image tone setting
is quite useless.

Setting exposure mode has no effect ( maybe it's not a bug only it's
not allowed ).

ISO table of GUI only shows the extended iso range even is base iso
range is set.

Expand Down
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
version 0.85.01
RAD10 compilation (thx FrankBijnen)
Exposure mode conversion bugfix (thx blemasle)
Testing status reader for KP
Settings reading for K5II (thx blemasle)
remote_bulb_mode_press_press setting (thx blemasle)
Expand Down
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ MAN1DIR = $(MANDIR)/man1
LIN_CFLAGS = $(CFLAGS)
LIN_LDFLAGS = $(LDFLAGS)

MAJORVERSION=0
VERSION=0.85.01
VERSIONCODE=$(shell echo $(VERSION) | sed s/\\.//g | sed s/^0// )
# variables for RPM creation
Expand Down Expand Up @@ -40,12 +41,13 @@ LIN_GUI_CFLAGS=$(CFLAGS) $(shell pkg-config --cflags gtk+-2.0 gmodule-2.0) -DGTK
default: cli pktriggercord
all: srczip rpm win pktriggercord_commandline.html
cli: pktriggercord-cli
lib: libpktriggercord.so.$(VERSION)

MANS = pktriggercord-cli.1 pktriggercord.1
SRCOBJNAMES = pslr pslr_enum pslr_scsi pslr_lens pslr_model pktriggercord-servermode
OBJS = $(SRCOBJNAMES:=.o) $(JSONDIR)/js0n.o
WIN_DLLS_DIR=win_dlls
SOURCE_PACKAGE_FILES = Makefile Changelog COPYING INSTALL BUGS $(MANS) pentax_scsi_protocol.md pentax.rules samsung.rules $(SRCOBJNAMES:=.h) $(SRCOBJNAMES:=.c) pslr_scsi_linux.c pslr_scsi_win.c pslr_scsi_openbsd.c exiftool_pentax_lens.txt pktriggercord.c pktriggercord-cli.c pktriggercord.ui pentax_settings.json $(SPECFILE) android_scsi_sg.h src/
SOURCE_PACKAGE_FILES = Makefile Changelog COPYING INSTALL BUGS $(MANS) pentax_scsi_protocol.md pentax.rules samsung.rules $(SRCOBJNAMES:=.h) $(SRCOBJNAMES:=.c) pslr_scsi_linux.c pslr_scsi_win.c pslr_scsi_openbsd.c exiftool_pentax_lens.txt pktriggercord.c pktriggercord-cli.c pktriggercord.ui pentax_settings.json $(SPECFILE) android_scsi_sg.h rad10/ src/
TARDIR = pktriggercord-$(VERSION)
SRCZIP = pkTriggerCord-$(VERSION).src.tar.gz

Expand All @@ -56,9 +58,16 @@ WINDIR=$(TARDIR)-win

pslr.o: pslr_enum.o pslr_scsi.o pslr.c pslr.h

pktriggercord-cli: pktriggercord-cli.c $(OBJS)
pktriggercord-cli: pktriggercord-cli.c $(OBJS) libpktriggercord.o
$(CC) $(LIN_CFLAGS) $^ -DVERSION='"$(VERSION)"' -o $@ $(LIN_LDFLAGS) -L.

libpktriggercord.so: libpktriggercord.so.$(VERSION)
ldconfig -v -n .
ln -s libpktriggercord.so.$(MAJORVERSION) libpktriggercord.so

libpktriggercord.so.$(VERSION): $(OBJS) libpktriggercord.o
$(CC) $(LIN_CFLAGS) -shared -Wl,-soname,lib$(NAME).so.$(MAJORVERSION) $^ -o $@ $(LIN_LDFLAGS) -L.

pslr_scsi.o: pslr_scsi_win.c pslr_scsi_linux.c pslr_scsi_openbsd.c

$(JSONDIR)/js0n.o: $(JSONDIR)/js0n.c $(JSONDIR)/js0n.h
Expand Down Expand Up @@ -93,7 +102,7 @@ install: pktriggercord-cli pktriggercord
fi

clean:
rm -f pktriggercord pktriggercord-cli *.o $(JSONDIR)/*.o
rm -f pktriggercord pktriggercord-cli *.o $(JSONDIR)/*.o *.so* *.dll
rm -f pktriggercord.exe pktriggercord-cli.exe
rm -f *.orig

Expand Down Expand Up @@ -200,18 +209,23 @@ winexternal: $(JSONDIR)/js0n.c $(JSONDIR)/js0n.h
$(WINGCC) $(WIN_CFLAGS) -c $< -o $(JSONDIR)/js0n.o

win-cli:winobjs winexternal pktriggercord-cli.c pktriggercord_commandline.html
$(WINGCC) -mms-bitfields -DVERSION='"$(VERSION)"' pktriggercord-cli.c $(OBJS) -o pktriggercord-cli.exe $(WIN_CFLAGS) -L.
$(WINGCC) -mms-bitfields -DVERSION='"$(VERSION)"' pktriggercord-cli.c libpktriggercord.c $(OBJS) -o pktriggercord-cli.exe $(WIN_CFLAGS) -L.
mkdir -p $(WINDIR)
cp pktriggercord-cli.exe Changelog COPYING pktriggercord_commandline.html $(WINDIR)
cp $(WIN_DLLS_DIR)/*.dll $(WINDIR)

win-lib: winobjs winexternal
$(WINGCC) -mms-bitfields libpktriggercord.c $(OBJS) -shared -o libpktriggercord.dll $(WIN_CFLAGS) -L.
mkdir -p $(WINDIR)
cp libpktriggercord.dll Changelog COPYING $(WIN_DLLS_DIR)/libgcc_s_sjlj-1.dll $(WINDIR)

win-gui: winobjs
$(WINGCC) -mms-bitfields -DVERSION='"$(VERSION)"' -DPKTDATADIR=\".\" pktriggercord.c $(OBJS) -o pktriggercord.exe $(WIN_GUI_CFLAGS) $(WIN_LDFLAGS) -L.
mkdir -p $(WINDIR)
cp pktriggercord.exe pktriggercord.ui pentax_settings.json Changelog COPYING $(WINDIR)
cp $(WIN_DLLS_DIR)/*.dll $(WINDIR)

win: win-cli win-gui
win: win-cli win-gui win-lib
rm -f $(WINDIR).zip
zip -rj $(WINDIR).zip $(WINDIR)
rm -r $(WINDIR)
Expand Down
201 changes: 201 additions & 0 deletions libpktriggercord.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/*
pkTriggerCord
Remote control of Pentax DSLR cameras.
Copyright (C) 2011-2019 Andras Salamon <andras.salamon@melda.info>

based on:

pslr-shoot

Command line remote control of Pentax DSLR cameras.
Copyright (C) 2009 Ramiro Barreiro <ramiro_barreiro69@yahoo.es>
With fragments of code from PK-Remote by Pontus Lidman.
<https://sourceforge.net/projects/pkremote>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU General Public License
and GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "libpktriggercord.h"

bool debug = false;
bool warnings = false;

bool bulb_timer_before=false;
bool astrotracer_before=false;

int save_buffer(pslr_handle_t camhandle, int bufno, int fd, pslr_status *status, user_file_format filefmt, int jpeg_stars) {
pslr_buffer_type imagetype;
uint8_t buf[65536];
uint32_t length;
uint32_t current;

if (filefmt == USER_FILE_FORMAT_PEF) {
imagetype = PSLR_BUF_PEF;
} else if (filefmt == USER_FILE_FORMAT_DNG) {
imagetype = PSLR_BUF_DNG;
} else {
imagetype = pslr_get_jpeg_buffer_type( camhandle, jpeg_stars );
}

DPRINT("get buffer %d type %d res %d\n", bufno, imagetype, status->jpeg_resolution);

if (pslr_buffer_open(camhandle, bufno, imagetype, status->jpeg_resolution) != PSLR_OK) {
return 1;
}

length = pslr_buffer_get_size(camhandle);
DPRINT("Buffer length: %d\n", length);
current = 0;

while (true) {
uint32_t bytes;
bytes = pslr_buffer_read(camhandle, buf, sizeof (buf));
if (bytes == 0) {
break;
}
ssize_t r = write(fd, buf, bytes);
if (r == 0) {
DPRINT("write(buf): Nothing has been written to buf.\n");
} else if (r == -1) {
perror("write(buf)");
} else if (r < bytes) {
DPRINT("write(buf): only write %zu bytes, should be %d bytes.\n", r, bytes);
}
current += bytes;
}
pslr_buffer_close(camhandle);
return 0;
}

void save_memory(pslr_handle_t camhandle, int fd, uint32_t length) {
uint8_t buf[65536];
uint32_t current;

DPRINT("save memory %d\n", length);

current = 0;

while (current<length) {
uint32_t bytes;
int readsize=length-current>65536 ? 65536 : length-current;
bytes = pslr_fullmemory_read(camhandle, buf, current, readsize);
if (bytes == 0) {
break;
}
ssize_t r = write(fd, buf, bytes);
if (r == 0) {
DPRINT("write(buf): Nothing has been written to buf.\n");
} else if (r == -1) {
perror("write(buf)");
} else if (r < bytes) {
DPRINT("write(buf): only write %zu bytes, should be %d bytes.\n", r, bytes);
}
current += bytes;
}
}

int open_file(char* output_file, int frameNo, user_file_format_t ufft) {
int ofd;
char fileName[256];

if (!output_file) {
ofd = 1;
} else {
char *dot = strrchr(output_file, '.');
int prefix_length;
if (dot && !strcmp(dot+1, ufft.extension)) {
prefix_length = dot - output_file;
} else {
prefix_length = strlen(output_file);
}
snprintf(fileName, 256, "%.*s-%04d.%s", prefix_length, output_file, frameNo, ufft.extension);
ofd = open(fileName, FILE_ACCESS, 0664);
if (ofd == -1) {
fprintf(stderr, "Could not open %s\n", output_file);
return -1;
}
}
return ofd;
}

void warning_message( const char* message, ... ) {
if ( warnings ) {
// Write to stderr
//
va_list argp;
va_start(argp, message);
vfprintf( stderr, message, argp );
va_end(argp);
}
}

void process_wbadj( const char* argv0, const char chr, uint32_t adj, uint32_t *wbadj_mg, uint32_t *wbadj_ba ) {
if ( chr == 'M' ) {
*wbadj_mg = 7 - adj;
} else if ( chr == 'G' ) {
*wbadj_mg = 7 + adj;
} else if ( chr == 'B' ) {
*wbadj_ba = 7 - adj;
} else if ( chr == 'A' ) {
*wbadj_ba = 7 + adj;
} else {
warning_message("%s: Invalid white_balance_adjustment\n", argv0);
}
}

void bulb_old(pslr_handle_t camhandle, pslr_rational_t shutter_speed, struct timeval prev_time) {
DPRINT("bulb oldstyle\n");
struct timeval current_time;
pslr_bulb( camhandle, true );
pslr_shutter(camhandle);
gettimeofday(&current_time, NULL);
double waitsec = 1.0 * shutter_speed.nom / shutter_speed.denom - timeval_diff_sec(&current_time, &prev_time);
if ( waitsec < 0 ) {
waitsec = 0;
}
sleep_sec( waitsec );
pslr_bulb( camhandle, false );
}

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);
} else if (pslr_has_setting_by_name(camhandle, "astrotracer")) {
pslr_write_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);
} else if (pslr_has_setting_by_name(camhandle, "astrotracer_timer_sec")) {
pslr_write_setting_by_name(camhandle, "astrotracer_timer_sec", bulb_sec);
} else {
fprintf(stderr, "New bulb mode is not supported for this camera model\n");
}
pslr_shutter(camhandle);
}

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);
}
} else if (pslr_has_setting_by_name(camhandle, "astrotracer")) {
if (!astrotracer_before) {
pslr_write_setting_by_name(camhandle, "astrotracer", astrotracer_before);
}
}
}
Loading