Daniel Reetz, the founder of the DIY Book Scanner community, has recently started making videos of prototyping and shop tips. If you are tinkering with a book scanner (or any other project) in your home shop, these tips will come in handy. https://www.youtube.com/channel/UCn0gq8 ... g_8K1nfInQ

Spreads A2200/CHDKPTP camera crash SOLVED

Johannes Baiter's Spreads and SpreadPi are the latest control systems and postprocessors for DIY scanning. http://spreads.readthedocs.org
Post Reply
gareth
Posts: 9
Joined: 18 Jul 2014, 07:56
Number of books owned: 0
Country: UK

Spreads A2200/CHDKPTP camera crash SOLVED

Post by gareth » 25 Feb 2015, 15:48

Those on IRC may know that I have been having a problem with my A2200 cameras under spreads on Ubuntu for a while; when spreads attempted to remote shoot, the camera crashed and powered down with a failure like this:

Terminal code:

Code: Select all

A2200Device[odd]: Capture command failed.
spreads encountered an error:
Traceback (most recent call last):
File "/home/gareth/projects/bookscanner/spreads/spreads/main.py", line 318, in main
run()
File "/home/gareth/projects/bookscanner/spreads/spreads/main.py", line 308, in run
args.subcommand(config)
File "/home/gareth/projects/bookscanner/spreads/spreads/cli.py", line 334, in capture
_trigger_loop()
File "/home/gareth/projects/bookscanner/spreads/spreads/cli.py", line 308, in _trigger_loop
workflow.capture(retake=(char == 'r'))
File "/home/gareth/projects/bookscanner/spreads/spreads/workflow.py", line 104, in wrapped_func
func(*args, **kwargs)
File "/home/gareth/projects/bookscanner/spreads/spreads/workflow.py", line 900, in capture
util.check_futures_exceptions(futures)
File "/home/gareth/projects/bookscanner/spreads/spreads/util.py", line 120, in check_futures_exceptions
raise exc
CHDKPTPException: WARNING: capture_get_data error I/O error
WARNING: error waiting for shot script nil
ERROR: /opt/chdkptp/lua/cli.lua:2274: attempt to concatenate local 'err' (a table value)
stack traceback:
[C]: in function 'xpcall'
/opt/chdkptp/lua/cli.lua:244: in function 'execute'
/opt/chdkptp/lua/main.lua:206: in function 'do_execute_option'
/opt/chdkptp/lua/main.lua:239: in function 'do_no_gui_startup'
/opt/chdkptp/lua/main.lua:274: in main chunk
[C]: in function 'require'
[string "require('main')"]:1: in main chunk
attempted to close non-present device 002:007
rs_init
rs_shoot
get data 1
sending stop message
script wait time 0.0003
Contents of spreads.log:

Code: Select all

2014-10-07 20:38:34,310 Sending capture command to devices [Workflow] [DEBUG]
2014-10-07 20:38:34,325 Calling chdkptp with arguments: [u'/usr/local/bin/chdkptp', '-c-d=008 -b=002', '-eset cli_verbose=2', '-eremoteshoot -tv=0.04 -sv=52.0 "cmp/data/raw/000"'] [A2200Device[odd]] [DEBUG]
2014-10-07 20:38:36,016 Call returned:
['WARNING: capture_get_data error I/O error', 'WARNING: error waiting for shot script nil', "ERROR: /opt/chdkptp/lua/cli.lua:2274: attempt to concatenate local 'err' (a table value)", 'stack traceback:', "\t[C]: in function 'xpcall'", "\t/opt/chdkptp/lua/cli.lua:244: in function 'execute'", "\t/opt/chdkptp/lua/main.lua:206: in function 'do_execute_option'", "\t/opt/chdkptp/lua/main.lua:239: in function 'do_no_gui_startup'", '\t/opt/chdkptp/lua/main.lua:274: in main chunk', "\t[C]: in function 'require'", '\t[string "require(\'main\')"]:1: in main chunk', 'attempted to close non-present device 002:008', 'connected: Canon PowerShot A2200, max packet size 512', 'rs_init', 'rs_shoot', 'get data 1', 'sending stop message', 'script wait time 0.0004'] [A2200Device[odd]] [DEBUG]
2014-10-07 20:38:36,017 Capture command failed. [A2200Device[odd]] [ERROR]
I am pleased to say that with a lot of help from the CHDK forum I have resolved the crash and I'm documenting the fix here for posterity. The full transcript of the investigation is available on the A2200 porting thread but the TL;DR is that gphoto2 was mounting the camera as a PTP device on connection, and the A2200 firmware (CHDK or otherwise) didn't like being in that state then being asked to remote shoot.

The simplest fix for me (also documented in that thread) is to disable the gphoto2 launch for Canon cameras in the udev configuration thus. The original file controlling that (/lib/udev/rules.d/40-libgphoto2-6.rules):

Code: Select all

ACTION!="add", GOTO="libgphoto2_rules_end"
SUBSYSTEM!="usb", GOTO="libgphoto2_usb_end"
ENV{ID_USB_INTERFACES}=="", IMPORT{builtin}="usb_id"
ENV{ID_USB_INTERFACES}=="*:060101:*", ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="PTP", MODE="0664", GROUP="plugdev"

LABEL="libgphoto2_rules_end"
was copied to /etc/udev/rules.d/40-libgphoto2-6.rules and then modified like this:

Code: Select all

ACTION!="add", GOTO="libgphoto2_rules_end"
SUBSYSTEM!="usb", GOTO="libgphoto2_usb_end"
ENV{ID_USB_INTERFACES}=="", IMPORT{builtin}="usb_id"
ENV{ID_USB_INTERFACES}=="*:060101:*", ATTR{idVendor}=="04a9", MODE="0664", GROUP="plugdev", GOTO="libgphoto2_rules_end"
ENV{ID_USB_INTERFACES}=="*:060101:*", ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="PTP", MODE="0664", GROUP="plugdev"

LABEL="libgphoto2_rules_end"

Post Reply