Skip to content

Commit

Permalink
allow using a different event port for ptpip, using
Browse files Browse the repository at this point in the history
	--port ptpip:IP[:PORT[:EVENTPORT]]

syntax

implements #63
  • Loading branch information
msmeissn committed Jun 15, 2016
1 parent aaf1d3c commit b671f34
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions camlibs/ptp2/ptpip.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ ptp_nikon_getptpipguid (unsigned char* guid) {
int
ptp_ptpip_connect (PTPParams* params, const char *address) {
char *addr, *s, *p;
int port, tries;
int port, eventport, tries;
struct sockaddr_in saddr;
uint16_t ret;

Expand All @@ -719,14 +719,23 @@ ptp_ptpip_connect (PTPParams* params, const char *address) {
}
*s = '\0';
p = strchr (s+1,':');
port = 15740;
eventport = port = 15740;
if (p) {
*p = '\0';
if (!sscanf (p+1,"%d",&port)) {
fprintf(stderr,"failed to scan for port in %s\n", p+1);
free (addr);
return GP_ERROR_BAD_PARAMETERS;
}
/* different event port ? */
p = strchr (p+1,':');
if (p) {
if (!sscanf (p+1,"%d",&eventport)) {
fprintf(stderr,"failed to scan for eventport in %s\n", p+1);
free (addr);
return GP_ERROR_BAD_PARAMETERS;
}
}
}
if (!inet_aton (s+1, &saddr.sin_addr)) {
fprintf(stderr,"failed to scan for addr in %s\n", s+1);
Expand Down Expand Up @@ -767,6 +776,7 @@ ptp_ptpip_connect (PTPParams* params, const char *address) {
}
/* seen on Ricoh Theta, camera is not immediately ready. try again two times. */
tries = 2;
saddr.sin_port = htons(eventport);
do {
if (-1 != connect (params->evtfd, (struct sockaddr*)&saddr, sizeof(struct sockaddr_in)))
break;
Expand Down

0 comments on commit b671f34

Please sign in to comment.