chdkptp - alternative ptp client - page 66 - General Discussion and Assistance - CHDK Forum

chdkptp - alternative ptp client

  • 1106 Replies
  • 559878 Views
*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #650 on: 05 / May / 2014, 16:02:55 »
Advertisements
Hello,

I've made a simple patch to rename some functions in chdkptp, so that lua can import them as libraries (eg require('chdkptp'))

This is pretty much a blind patch, as I do not have devices to test it with, but it should hopefully work

made against chdkptp r571.
Thanks for doing this, it should be quite useful. It may be a little while before I get to it because I'm in the middle of some major re-organization right now.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #651 on: 05 / May / 2014, 16:09:05 »
reyalp, can you post a working example for connecting over command line with the -d (device) syntax. I can't get it to work. The device string has several backslashes in its path which I've tried to escape but I still get errors.
The other thing to watch out for is that - is also a special character in Lua patterns, so you should escape it with %-

In r557, I added a -nopat option which disables pattern matching completely. However, as noted earlier the chdkptp trunk is undergoing some destabilizing reorganization at the moment. You might be able to apply the diffs from just that change to the last snapshot.
Don't forget what the H stands for.

*

Offline tpont

  • **
  • 81
Re: alternative ptp client
« Reply #652 on: 05 / May / 2014, 18:25:42 »
In r557, I added a -nopat option which disables pattern matching completely.
Great.

The other thing to watch out for is that - is also a special character in Lua patterns, so you should escape it with %-
edit: after posting I discovered the right syntax: If for example the list command shows this
Code: [Select]
-d=\\.\libusb0-0001--0x1111-0x1111we connecti the camera like this
Code: [Select]
chdkptp.exe -c"-d=libusb0%-0001" -i
The background to my question is that I was trying to use two cameras of the exact same model at the same time. They have the same PID. My plan was to use -d to control which process connects to which camera. But after posting I realized that the enumeration in the second part of device string (0001 in the example above) will vary between 0001 and 0002 depending on which camera is first turned on while usb connected. The only stably unique identifier for each camera, it seems, is the serial number string. But trying -s for both cameras results in errors on the second connect attempt. The best workaround I've found, when controlling chdkptp over command line from external scripts, is to make sure to power on camera A before camera B, then connect camera B using -s and finally connect camera A using -p. I guess I could also first do a list command and somehow save the results, parse which camera (serial) is currently linked to which device number and then use those device numbers to connect each camera through a specific process.
« Last Edit: 05 / May / 2014, 18:35:28 by tpont »

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #653 on: 05 / May / 2014, 22:22:20 »
But after posting I realized that the enumeration in the second part of device string (0001 in the example above) will vary between 0001 and 0002 depending on which camera is first turned on while usb connected.
Yes, this is correct. USB device names are picked when the device is connected (on both linux and windows).
Quote
The only stably unique identifier for each camera, it seems, is the serial number string. But trying -s for both cameras results in errors on the second connect attempt.
Correct again. Getting the serial number currently requires making a connection to the camera, which destroys any existing connection. I think it may be possible to get this without, but haven't had time to really investigate yet.

It should also be able to detect when a device is already opened by another process, so you could have a connect option that only applies to unclaimed cameras. The error code rework I am doing now is a step toward being able to do this.
Quote
The best workaround I've found, when controlling chdkptp over command line from external scripts, is to make sure to power on camera A before camera B, then connect camera B using -s and finally connect camera A using -p. I guess I could also first do a list command and somehow save the results, parse which camera (serial) is currently linked to which device number and then use those device numbers to connect each camera through a specific process.
Both of these are reasonable options.

The other alternative is to do everything in one instance of chdkptp, but depending on your particular application, this may lead to other difficulties.
Don't forget what the H stands for.

*

Offline tpont

  • **
  • 81
Re: alternative ptp client
« Reply #654 on: 06 / May / 2014, 14:53:01 »
The other alternative is to do everything in one instance of chdkptp, but depending on your particular application, this may lead to other difficulties.
That would slow down things for me I suspect.  I switched to the workaround that first list available cameras and their device and serial numbers
Code: [Select]
chdkptp.exe -elist > c:\temp.txtand then parse the first line of the txt file. Then I start two processes that connect using the -d values that match each camera serial. Works regardless of which camera was powered on first.
« Last Edit: 06 / May / 2014, 14:54:45 by tpont »

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #655 on: 12 / May / 2014, 01:21:09 »
I've uploaded snapshot build 592 to the files area
https://www.assembla.com/spaces/chdkptp/documents

This is a pretty substantial re-write. It seems to be working OK for me, but it's quite likely that some new bugs snuck in.

Details are in the changelog https://www.assembla.com/spaces/chdkptp/wiki/Changelog

Key points

* incompatible API and error ouput changes
* Building with Lua 5.1 is deprecated
* Tests are substantially improved

I'm not entirely finished with the error handling changes, but whats left should be less invasive.
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #656 on: 20 / May / 2014, 01:54:08 »
It appears google chrome on windows is blocking the chdkptp windows binary downloads a malicious.

I believe this is an error, and virustotal shows no detections (though it does get McAfee-GW-Edition Heuristic.LooksLike.Win32.Suspicious.N!86)

You can either trust me and use a different browser to download, or build from source, or not use chdkptp.

From what I can find by googling, google appears to have some kind of heuristic which is basically any unsigned executable they don't know about is malicious.  ::)
Don't forget what the H stands for.

*

Offline tpont

  • **
  • 81
Re: alternative ptp client
« Reply #657 on: 20 / May / 2014, 02:17:52 »
I can reproduce that in Chrome. No problem in Firefox however.  I ran the exe from chdkptp-r592-win32.zip throught the online multi antivir tool http://virusscan.jotti.org  and it found no problem. I also put the unzipped chdkptp.exe file (windows binary) in dropbox and tried opening the direct link in Chrome. Chrome then says "chdkptp.exe is not commonly downloaded and could be dangerous" with "Dismiss" as the default button state.

*

Offline reyalp

  • ******
  • 14125
Re: alternative ptp client
« Reply #658 on: 20 / May / 2014, 02:29:26 »
Yeah, I compiled hello world, uploaded the .exe and chrome blocked it.

However, I found putting the chkdptp package in a 7zip file makes chrome not flag it.  Good thing malware authors couldn't do anything like that ::)
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #659 on: 20 / May / 2014, 07:07:47 »
However, I found putting the chkdptp package in a 7zip file makes chrome not flag it.  Good thing malware authors couldn't do anything like that ::)
But will Windows open a 7zip on its own like its does zip files?
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal