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

chdkptp - alternative ptp client

  • 1106 Replies
  • 552168 Views
Re: alternative ptp client
« Reply #760 on: 22 / January / 2015, 16:33:04 »
Advertisements
reyalp, gonna go with your shim idea, using the Magick.NET dll. I should have a working test project within' a couple of days, but not with onion skinning. That will come a little later. The only thing I need to figure out is the chdkptp commands for zooming. Gonna control it with the mouse wheel.

The code will be posted here once it's ready.



*

Offline reyalp

  • ******
  • 14119
Re: alternative ptp client
« Reply #761 on: 22 / January / 2015, 16:52:46 »
The only thing I need to figure out is the chdkptp commands for zooming.
There are no specific CLI commands for zooming, this is done by sending lua script with the = or . commands. Essentially any CHDK scripting function can be used this way http://chdk.wikia.com/wiki/CHDK_Scripting_Cross_Reference_Page

There are two ways to control zoom in CHDK script

1) The set_zoom functions:  http://chdk.wikia.com/wiki/CHDK_scripting#set_zoom_.2F_set_zoom_rel_.2F_get_zoom_.2F_set_zoom_speed
These let you set a specific zoom step. However, on some cameras it may cause problems like incorrect distortion correction on jpegs, or crashes.
2) Simulated key presses using press/release, click or post_logical_event functions. These should work on every camera, but you may have trouble getting the exact zoom position you want, especially if your camera has a lot of steps. It may also be slow if you use a lot of clicks.
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #762 on: 25 / January / 2015, 16:22:06 »
reyalp, first I want to thank you for all your help, but I think I discovered a bug with chdkptp. A command that works without problems via the command prompt window, lvdumpimg -count=1 -vp=foo.ppm -bm=foo.pam, doesn't work if the same command is sent from my app:
Code: [Select]
proc.StandardInput.WriteLine("lvdumpimg -count=1 -vp=foo.ppm -bm=foo.pam")

At first I thought the command wasn't being read because it was sent right after the "rec" command from a timer, but delaying the command with a stopwatch do until loop didn't solve the problem. I then moved the command to a button to test it from there, discovering that it doesn't work at all if it's sent from my app.
Code: [Select]
Private Sub Convert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load       
        proc.StartInfo.FileName = "C:\Users\Web\Desktop\chdkptp\chdkptp.exe"
        proc.StartInfo.Arguments = String.Format(" -i -c ")
        proc.StartInfo.UseShellExecute = False
        proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
        proc.StartInfo.RedirectStandardInput = True
        proc.StartInfo.RedirectStandardOutput = True
        proc.StartInfo.CreateNoWindow = True
        proc.Start()
        proc.StandardInput.WriteLine("rec")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click   
proc.StandardInput.WriteLine("lvdumpimg -count=1 -vp=foo.ppm -bm=foo.pam")
End Sub
Making a connection to my camera, setting to record, and sending lua commands for zooming via my app to chdkptp works perfectly. Am I missing something in order to send the lvdumping command from my app, or is this a bug?
« Last Edit: 25 / January / 2015, 16:31:44 by JeremyLavine »

*

Offline reyalp

  • ******
  • 14119
Re: alternative ptp client
« Reply #763 on: 25 / January / 2015, 17:17:52 »
Making a connection to my camera, setting to record, and sending lua commands for zooming via my app to chdkptp works perfectly. Am I missing something in order to send the lvdumping command from my app, or is this a bug?
What exactly happens when it "doesn't work"? Does it just hang? Does it produce any output? Can you send more commands after you send the lvdumpimg command?

You can see in the chdkptp source for yourself that all input for CLI commands is handled the same way (see cli.lua cli:run) As far as the input handling is concerned, there is no difference between "rec" and "lvdumpimg". It just reads text terminated by a newline, using standard Lua IO (or GNU readline if you've compiled chkdptp with readline support, but that defaults to off under windows)

This doesn't mean there isn't a bug, but it probably isn't specific to lvdumpimg. I would expect it has something to do with piping from VB, but I know very little about that.

The obvious difference is that the lvdumpimg command is longer than the other ones you are sending.

One thing you could try is sending increasingly long commands and see if it stops at some point.
e.g.
proc.StandardInput.WriteLine("exec print('a')")
proc.StandardInput.WriteLine("exec print('aaaa')") 
...
The prints will cause chdkptp to print on standard output if the command works.

You can also add debugging prints to various points in the chdkptp code: Does it reach cli:execute? Does it reach the lvdumpimg command?

If vb does any kind of output buffering when you use proc.StandardInput.WriteLine that would be an obvious thing to check.

edit:
Another possibility is if you aren't reading the standard output from chdkptp, it will could block once some buffer fills up. Again, I have no idea how this works specifically with VB.
« Last Edit: 25 / January / 2015, 17:20:45 by reyalp »
Don't forget what the H stands for.


Re: alternative ptp client
« Reply #764 on: 25 / January / 2015, 18:23:56 »
chdkptp doesn't hang. I can still call commands successfully after the failed lvdumping.
Code: [Select]
Dim proc As New Process
Dim sr As StreamReader

Private Sub Convert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load   
        proc.StartInfo.FileName = "C:\Users\Web\Desktop\chdkptp\chdkptp"
        proc.StartInfo.Arguments = String.Format("-i -c")
        proc.StartInfo.UseShellExecute = False
        proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
        proc.StartInfo.RedirectStandardInput = True
        proc.StartInfo.RedirectStandardOutput = True
        proc.StartInfo.CreateNoWindow = True
        proc.Start()
     
        proc.StandardInput.WriteLine("rec")
        System.Threading.Thread.Sleep(3500)
        proc.StandardInput.WriteLine("lua set_zoom(25)")
    End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        proc.StandardInput.WriteLine("lvdumpimg -count=1 -vp=foo.ppm -bm=foo.pam")
 
        System.Threading.Thread.Sleep(3500)
        proc.StandardInput.WriteLine("lua set_zoom(100)")
    End Sub
The standard output doesn't show anything. Probably a mistake on my part.

Gonna have to wait on testing lengths of commands. My camera's battery is dead!
« Last Edit: 26 / January / 2015, 06:06:30 by JeremyLavine »

*

Offline reyalp

  • ******
  • 14119
Re: alternative ptp client
« Reply #765 on: 25 / January / 2015, 19:01:22 »
chdkptp doesn't hang. I can still call commands successfully after the failed lvdumping.
lvdumpimg should produce some kind of output, or an error message. Error messages might go to stderr rather than stdout.

For testing, you could presumably redirect chdkptp's stdout and stderr to files when you start it.

I guess ProcessWindowStyle.Hidden means the cmd window is hidden? If so, why not try starting without that, and don't redirect chdkptp stdout. Then you should be able to see what's happening in the resulting cmd window.
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #766 on: 26 / January / 2015, 06:12:03 »
reyalp, your commands work perfectly! I was looking in the wrong place for the pam and ppm images. Forgot that it defaults to my project's bin folder. I was looking for them under my Window's profile's directory instead. Stupid me!  ::)

The standard output probably only works within a function. I was calling it within a normal sub, to where I got nothing or it would crash my app. Displaying the chdkptp shell window, no commands or errors displayed. Just a blinking cursor.

The only thing now is to figure out how to create a shim app to handle piped images. For testing purposes, my current app loads ppm and pam images to the Magick.NET dll for processing after chdkptp saves them to my projects folder. It's slow, but works.
« Last Edit: 26 / January / 2015, 06:57:02 by JeremyLavine »

Re: alternative ptp client
« Reply #767 on: 30 / January / 2015, 15:43:05 »
If this would be better placed on the wiki (and deleted here) please advise

For the record.

After using chdkptp successfully for quite a while with cameras either connected directly (win7 laptop) or via a 7 port hub I connected using a new 13 port hub today.

Thereafter, chdkptp gui displayed no connection candidates. Following the wiki usage notes here http://chdk.wikia.com/wiki/PTP_Extension I disabled WIA by:

  • go to Pearl button (Start) and click on the Search programs and files
  • Type services.msc and press Enter
  • locate Windows Image Acquisition (WIA) observe the current status and open to make changes.
  • From General tab you can Start/Stop and change the Windows Image Acquisition (WIA)

chdkptp operation restored  :)

ref http://computerstepbystep.com/windows_image_acquisition_%28wia%29_service.html
« Last Edit: 30 / January / 2015, 15:59:05 by andrew.stephens.754365 »


*

Offline reyalp

  • ******
  • 14119
Re: alternative ptp client
« Reply #768 on: 30 / January / 2015, 16:27:41 »
If this would be better placed on the wiki (and deleted here) please advise

For the record.

After using chdkptp successfully for quite a while with cameras either connected directly (win7 laptop) or via a 7 port hub I connected using a new 13 port hub today.
Thanks, useful note.

It's not clear to me why changing hubs would affect the need to disable WIA. Using the INF drivers on Win7 x64, I have never needed to disable WIA, the cameras associated with the INF driver appear to be ignored by standard windows software. For old (~ digic II era that don't return a serial number) cameras the INF driver appears to only affect specific physical ports.

I'm not sure anything needs to be added to the wiki unless the specifics of when WIA needs to be disabled can be clarified.
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #769 on: 14 / February / 2015, 14:31:09 »
Hi everybody,

I've recently installed CHDK again on my A610 after a long time and came across new features like your remote control/live view program.

After installing the necessary USB driver, when I hit the "connect" button in CHDK PTP, it says: "Error: Operation not supported".

Does this mean that my A610 is incompatible with remote shooting/live view, or did I just do something wrong?

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal