Canon M10 Remote Control - Creative Uses of CHDK - CHDK Forum

Canon M10 Remote Control

  • 3 Replies
  • 5167 Views
Canon M10 Remote Control
« on: 07 / December / 2019, 06:20:32 »
Advertisements
I created a remote control for the Canon M10 that works in the browser thanks to the GUI library REMI.

The camera can be controlled with any device (computer, tablet, phone) and the code is all in Python.

I think it is not too difficult to adapt it to other cameras, but I have only the M10 with CHDK installed, so I didn't try other models.

The code is here: https://github.com/emanuelelaface/Canon-M10

*

Offline reyalp

  • ******
  • 14079
Re: Canon M10 Remote Control
« Reply #1 on: 07 / December / 2019, 14:29:07 »
Very cool :)

Some comments:
1) Exposing CHDK Lua to an un-trusted network is extremely insecure. Even with the "native calls" option disabled, there are trivial RCEs, and with RCE you can brick or modify the firmware. This is not a problem with your tool, it's fine to use on localhost or on your home wifi, but users should be warned.

2)  https://github.com/5up3rD4n1/chdkptp.py seems to be based on an old, no longer updated version of chdkptp. However, it relies on a patch to run as a shared object, so it might not be trivial to update. In any case, as long as there's no features or bug fixes you need, it's fine.

3) The calls to things like post_levent_to_ui(0x11ea,1) and call_event_proc("PTM_SetCurrentItem",0x80b8,2) make the tool camera specific. In particular, the PTM_ functions are quite dangerous and could potentially corrupt flash parameters if used on the wrong camera. call_event_proc also requires native calls enabled on the camera (enabled by default in chdkde builds, but not the official autobuild). I'd suggest checking that the camera is an M10 (USB product ID == 12960) and refuse to run or disable those functions if not. You could also use chdkptp connect options to only match that PID.

Again, you've done very nice work and I'm glad you shared it. Please don't take any of the above as criticism of the project.
Don't forget what the H stands for.

Re: Canon M10 Remote Control
« Reply #2 on: 07 / December / 2019, 16:33:14 »
Thanks, yes you are definitely right on everything. Sorry I wrote quickly the post and I didn't point out the weakness.

Quote
1) Exposing CHDK Lua to an un-trusted network is extremely insecure. Even with the "native calls" option disabled, there are trivial RCEs, and with RCE you can brick or modify the firmware. This is not a problem with your tool, it's fine to use on localhost or on your home wifi, but users should be warned.

Yes, never use it on a public network. It is very easy to modify the program to publish just the photos or the live view without commands, but this version is intended to a full control of the camera and it should stay private.

Quote
2)  https://github.com/5up3rD4n1/chdkptp.py seems to be based on an old, no longer updated version of chdkptp. However, it relies on a patch to run as a shared object, so it might not be trivial to update. In any case, as long as there's no features or bug fixes you need, it's fine.

True, but is there something better? I found everything about talking with the ptp protocol of chdk very complicate to do with Python. Maybe I should write a native library to do it.

Quote
3) The calls to things like post_levent_to_ui(0x11ea,1) and call_event_proc("PTM_SetCurrentItem",0x80b8,2) make the tool camera specific. In particular, the PTM_ functions are quite dangerous and could potentially corrupt flash parameters if used on the wrong camera. call_event_proc also requires native calls enabled on the camera (enabled by default in chdkde builds, but not the official autobuild). I'd suggest checking that the camera is an M10 (USB product ID == 12960) and refuse to run or disable those functions if not. You could also use chdkptp connect options to only match that PID.

Ok, I will add this check. I use that function for the zoom functions, I haven't find a better way to do it, especially for the 10x. I am open to change the call with something less camera-dependent if it is possible. I think that also the get_live_view function is very camera specific, but maybe it can be abstracted better.

If I have time I will try to separate a bit more the GUI from the camera functions so we may reuse it for other cameras.

Thanks again for the comments.

*

Offline reyalp

  • ******
  • 14079
Re: Canon M10 Remote Control
« Reply #3 on: 07 / December / 2019, 18:30:35 »
Thanks, yes you are definitely right on everything. Sorry I wrote quickly the post and I didn't point out the weakness.
No problem at all.

Quote
True, but is there something better? I found everything about talking with the ptp protocol of chdk very complicate to do with Python. Maybe I should write a native library to do it.
I'm not aware of anything better for python, only mentioned in case it wasn't clear https://github.com/svn2github/chdkptp is not updated any more.

Mostly my fault for not integrating the shared library patch. It's relatively simple, but last time I looked into it there are complications with supporting it generally. I should look into it again.

A native python library would be useful, but a lot of work to replicate all the chdkptp code.
Quote
Ok, I will add this check. I use that function for the zoom functions, I haven't find a better way to do it, especially for the 10x.
Yes CHDK generally doesn't have control over it. You could just disable that feature for other cameras. As an aside, I was initially confused to see a "zoom" control since EOS doesn't control the lens.

You can set regular digital zoom on powershots with other eventprocs (for example SS.MoveDigitalZoomAt, registered by SS.Create). This will affect the jpegs if you don't turn it off after shooting though, and at higher zooms the live view resolution is reduced anyway.

Quote
I am open to change the call with something less camera-dependent if it is possible. I think that also the get_live_view function is very camera specific, but maybe it can be abstracted better.
There are a few variations of the framebuffer layout. chdkptp can record the live view stream to lvdump files, so if you want to support other variants, I'm sure people here can provide examples.
Don't forget what the H stands for.


 

Related Topics