chdkptp can't switch to record mode - page 3 - General Help and Assistance on using CHDK stable releases - CHDK Forum

chdkptp can't switch to record mode

  • 28 Replies
  • 11078 Views
*

Offline ahull

  • *****
  • 634
Re: chdkptp can't switch to record mode
« Reply #20 on: 03 / December / 2013, 10:11:09 »
Advertisements
I settled on this solution in my chdkptp.sh bash script

Code: [Select]
#!/bin/sh
# Kill off the gphoto mounter so it doesn't wreak havoc at camera connection time.
killall  /usr/lib/gvfs/gvfs-gphoto2-volume-monitor >/dev/null 2>&1
# adjust the following to your configuration
CHDKPTP_DIR=".... blah.... /chdk-ptp"
# CHDKPTP_DIR=/path/to/chdkptp
# only need if you have compiled IUP support and have NOT installed the libraries to system directories
#export LD_LIBRARY_PATH=/path/to/iup:/path/to/cd
export LUA_PATH="$CHDKPTP_DIR/lua/?.lua"
"$CHDKPTP_DIR/chdkptp" "$@"
# Restart gphoto volume mounter
/usr/lib/gvfs/gvfs-gphoto2-volume-monitor >/dev/null 2>&1 &

Change the ...blah... to match your own installation.

Its not perfect, but it seems to work.
« Last Edit: 03 / December / 2013, 10:13:30 by ahull »

Re: chdkptp can't switch to record mode
« Reply #21 on: 05 / December / 2013, 12:56:42 »
I "solved" the problem by connecting to and ssh-ing into a raspberry pi, which is free of gphoto :) The advice about killing volume monitor is nice, I will try that too.

Re: chdkptp can't switch to record mode
« Reply #22 on: 11 / July / 2014, 20:00:05 »
@ahull that works for me on a PowerShot A2300. Thanks. You should contact a svn commiter to add that hack to the chdkptp repo.

*

Offline reyalp

  • ******
  • 12217
Re: chdkptp can't switch to record mode
« Reply #23 on: 11 / July / 2014, 22:10:51 »
@ahull that works for me on a PowerShot A2300. Thanks. You should contact a svn commiter to add that hack to the chdkptp repo.
Thanks for bumping that, I'll add a mention of it to the docs.

Note that if you expect to plug the camera in and then use ./chdkptp.sh -c this may not be a good solution, because the gphoto stuff will have already poked the camera on connect.
Don't forget what the H stands for.


Re: chdkptp can't switch to record mode
« Reply #24 on: 06 / August / 2014, 08:14:51 »
How to permanently disable gvfs automounting on Ubuntu 14.04 for a specific device type:

Determine vendor and product id via
Code: [Select]
lsusb
Bus 001 Device 007: ID 046d:c31c Logitech, Inc. Keyboard K120 for Business
Bus 001 Device 005: ID 0557:8021 ATEN International Co., Ltd
Bus 001 Device 043: ID 04a9:3271 Canon, Inc. <---
Bus 001 Device 003: ID 174c:2074 ASMedia Technology Inc.
Bus 001 Device 002: ID 8087:07e6 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

So i searched for the responsible udev rule ...
Code: [Select]
ls /lib/udev/rules.d/*gphoto*.rulescopied it to where i am allowed to editing it ...
Code: [Select]
sudo cp /lib/udev/rules.d/40-libgphoto2-6.rules /etc/udev/rules.d/And then added this in /etc/udev/rules.d/40-libgphoto2-6.rules to the begining of the fourth line:

Code: [Select]
ATTR{idVendor}!="04a9", ATTR{idProduct}!="3271",
So this udev.rules / gvfs-gphoto automount stuff doesnt apply to the Canon A2500. I couldnt find a way how to disable a specific device for gvfs via an exclude list, conf-files or any other interface.

Edit:
Ohh and regarding the chdkptp-sample.sh in bash $CHDKPTP_DIR can be set like this:
Code: [Select]
CHDKPTP_SH="$(readlink -f $0 2>/dev/null)" # full path to this bash script
CHDKPTP_DIR=${CHDKPTP_SH%/*} # path without filename (bash string manipulation)

This always expands to the directory where chdkptp and the start script are placed in.
« Last Edit: 06 / August / 2014, 12:02:44 by ladiko »

*

Offline reyalp

  • ******
  • 12217
Re: chdkptp can't switch to record mode
« Reply #25 on: 17 / August / 2014, 03:58:06 »
Thanks a lot for the udev tips.
On a ubuntu 14.04 system, I was able to prevent libgphoto from accessing my elph130 using modified  /etc/udev/rules.d/40-libgphoto2-6.rules

My D10 and A540 however would still get accessed, no matter what I put in the rules. I verified that the rules were matching, but gphoto would still grab the cameras. After much headbanging, I realized these two cameras appear in /lib/udev/hwdb.d/20-libgphoto2-6.hwdb. Copying this to /etc/udev/hwdb.d/20-libgphoto2-6.hwdb, commenting out the section for each camera, and running udevadm hwdb --update seems to make them behave like the elph130. I'm not really clear why both exist, the rules are still run for the ones in hwdb. It seems like there should be a way to override the hwdb stuff in rules, but I wasn't able to find it.

A few other comments:
From my understanding of http://www.reactivated.net/writing_udev_rules.html#syntax and testing the "," in rules is effectively an and so
Code: [Select]
ATTR{idVendor}!="04a9", ATTR{idProduct}!="3271",
will skip the rule if the camera is a Canon, or has the specified PID.

The modified rule will also skip setting the user and group, which may affect whether the device is accessible, though on my 14.04 system, my regular user account was able to access the camera.

If you want to skip all Canon's just the vendor ID should do it.

If you want to select specific PIDs, a rule like this before line 4
Code: [Select]
ATTR{idVendor}=="04a9", ATTR{idProduct}=="3265", GOTO="libgphoto2_rules_end"
seems to do the trick. You can also expand this to set the permissions, like
Code: [Select]
ATTR{idVendor}=="04a9", ATTR{idProduct}=="3265", MODE="0664", GROUP="plugdev", GOTO="libgphoto2_rules_end"
If you want to select specific cameras,
Code: [Select]
ATTR{serial}=="... serial number from chdkptp list or kernal log.."
seems to work.

One other thing is the ENV{ID_USB_INTERFACES}=="*:060101:*". I think this Identifies PTP capable devices. If you are matching by vendor, you might want to restrict to that so you don't affect say, canon printers.


What I ended up using was
Code: [Select]
ENV{ID_USB_INTERFACES}=="*:060101:*", ATTR{idVendor}=="04a9", MODE="0664", GROUP="plugdev", GOTO="libgphoto2_rules_end"
Which should catch any canon cameras.

Other useful commands
udevadm monitor --env

adding a rule to log when it's hit
Code: [Select]
ATTR{idVendor}=="04a9", PROGRAM="/root/foo.sh" ...
where you can use foo.sh to log verify that the match is hit or log environment variables.

edit:
I should add that overriding these entire files is sub-optimal, because if your distro updates the files in /lib/ you will probably have to update manually.

edit2:
A couple things I don't understand despite some hours of headbanging...
1) how does gvfs-gphoto2-volume-monitor ultimately get notified about a new device? The 40-libgphoto2-6.rules just sets ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="PTP" and the file permissions. I would expect a RUN somewhere later that actually does some thing with them, but the only other mentions are I see are
Code: [Select]
70-uaccess.rules:ENV{ID_GPHOTO2}=="*?", TAG+="uaccess"
95-cd-devices.rules:SUBSYSTEM=="usb", ENV{ID_GPHOTO2}!="", ENV{COLORD_DEVICE}="1", ENV{COLORD_KIND}="camera"

2) When do the values in hwdb get set and used in relation to the udev rules? I tried setting the ENV variables to empty in the rule, but that didn't seem to work.

edit:
Fixed missing comma in final rule
« Last Edit: 03 / September / 2014, 00:45:30 by reyalp »
Don't forget what the H stands for.

Re: chdkptp can't switch to record mode
« Reply #26 on: 28 / March / 2016, 19:05:36 »
The udev rule suppresses gphoto from poking the camera, but now I don't know how to connect using chdkptp. It used to connect with just c, but it can't find any usb devices now.

*

Offline reyalp

  • ******
  • 12217
Re: chdkptp can't switch to record mode
« Reply #27 on: 28 / March / 2016, 22:19:13 »
The udev rule suppresses gphoto from poking the camera, but now I don't know how to connect using chdkptp. It used to connect with just c, but it can't find any usb devices now.
This is odd, I haven't encountered anything like it in my test. chdkptp definitely doesn't depend on gphoto doing anything to the camera. 'c' in chdkptp just uses regular libusb calls to list devices, and connects the first one with bInterfaceClass==USB_CLASS_PTP

I didn't think any of the udev stuff was needed for that, but my understanding of it is pretty hazy.

You can use !return chdk.list_usb_devices() to see a raw list of devices with USB_CLASS_PTP, but if c doesn't find anything I'd expect this to be empty.

The system logs might provide some clues.

If you have "USB remote" enabled on the camera, it will not be recognized as a USB device at all.
Don't forget what the H stands for.


Re: chdkptp can't switch to record mode
« Reply #28 on: 28 / March / 2016, 23:23:26 »
nevermind...this rejects all canon devices.. chdkptp.sh works with c, and finds the correct device. chdkptp-gui auto identifies the usb bus and device. lsusb will show it too.

ACTION!="add", GOTO="libgphoto2_rules_end"
SUBSYSTEM!="usb", GOTO="libgphoto2_usb_end"
ENV{DEVTYPE}!="usb_device", GOTO="libgphoto2_usb_end"
ATTR{idVendor}=="04a9", GOTO="libgphoto2_usb_end"

 

Related Topics