Page 2 of 2

Re: RaspberryPi 2

Posted: 13 Jun 2015, 21:56
by duerig
I still need to look into this error more and try to reproduce it. The problem is in the code which opens up the camera to try to display a friendly message about how to connect to the Pi.

My theory is that you aren't connected to a network, or your network doesn't have DHCP enabled on it so the Pi doesn't have an IP address. So the code which tries to write out the IP address to the screen is failing because it doesn't have one. Try connecting your Pi to a network and seeing if it recurs. In the mean time, I'll take a look at that code to see if I can learn more.

Re: RaspberryPi 2

Posted: 15 Jun 2015, 13:29
by sunhou
No, my Pi had an IP address, and I can ssh into it just fine.

One other thing was that after each unsuccessful attempt to fire up spread, my keyboard would stop working. Unplugging and re-plugging in the USB plug for the keyboard would make it start working again. This keyboard strangeness doesn't happen if I just use chdkptp to talk to the cameras.

I used one of my cameras to manually take a photo of the error on the other camera screen that pops up when I try to run "spread web" so I could read it -- it is:

e.preload['drawings'] file 'A/CHDK/SCRIPTS/drawings.lua' file 'A/CHDK/LUALIB/drawings.lua'

Not sure if that's actually relevant to the trouble I'm having, though.

Re: RaspberryPi 2

Posted: 15 Jun 2015, 14:07
by duerig
I hope to have some time tonight to debug this more. If worst comes to worst, I can build a version with that display code removed for you to try.

In the mean time, maybe try running without the keyboard plugged in at all. Use SSH to invoke it and have only the cameras plugged in. Perhaps there is some issue where it is mistaking your keyboard for the camera and trying to connect to it. This would explain why the keyboard stops working.


Re: RaspberryPi 2

Posted: 15 Jun 2015, 15:46
by sunhou
Still getting the same errors (in the terminal window and on camera screen) with no mouse/keyboard plugged in, doing commands over ssh.

Re: RaspberryPi 2

Posted: 16 Jun 2015, 07:10
by duerig
sunhou, I have two ideas. Either the version of chdk you are using is not the latest or the installation of chdk was corrupted. Go download the very latest experimental version for your firmware and reinstall. This should fix it if either of the above is true. Remember that your two cameras might have different firmware.


Re: RaspberryPi 2

Posted: 17 Jun 2015, 15:56
by sunhou
After I posted my last update, it had also occurred to me that probably my version of CHDK was part of the problem.

I had CHDK 1.3.0 (the stable version) before, now I have 1.4.0. Things are still not working. E.g. when I tried to run spread web, I got this:

pi@raspberrypi: ~ $ spread web
spreadsplug.web: Starting scanning station server in "scanner" mode
spreads.plugin: Finding devices for driver "CHDKCameraDevice"
spreads encountered an error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/spreads/", line 321, in main
File "/usr/local/lib/python2.7/dist-packages/spreads/", line 308, in run
File "/usr/local/lib/python2.7/dist-packages/spreadsplug/web/", line 169, in run
File "/usr/local/lib/python2.7/dist-packages/spreadsplug/web/", line 364, in run_server
File "/usr/local/lib/python2.7/dist-packages/spreadsplug/web/", line 327, in display_ip
.format(self._ip_address, self._listening_port))
File "/usr/local/lib/python2.7/dist-packages/spreadsplug/dev/", line 293, in show_textbox
self._device.lua_execute("\n".join(script), do_return=False)
File "/usr/local/lib/python2.7/dist-packages/chdkptp/", line 186, in lua_execute
""" % (lua_code, remote_libs)).values()
File "/usr/local/lib/python2.7/dist-packages/chdkptp/", line 70, in pexecute
return self._parse_rval(self._rt.execute(checked_code))
File "/usr/local/lib/python2.7/dist-packages/chdkptp/", line 36, in _parse_rval
IndexError: tuple index out of range

This next part is likely not relevant to the above, but I include it just as more background, just in case what I'm seeing with this approach sheds any more light on what's going on with spreads.
I'm also seeing a bit of strange behavior when I just try to talk to the cameras directly with chdkptp now. I should note that I am running 2 copies of chdkptp in separate terminal windows. Before updating CHDK, I was able to get things minimally working via a kludge where I'd run 2 copies of chdkptp, each reading input commands from a separate text file. I had then whipped up a C program that would let me input various commands and then would write the appropriate commands to those 2 text files. It was a way I could pretty much simultaneously trigger both cameras by pressing the Enter key once. Now when I try to do this, I'm having trouble with the chdkptp processes remaining connected to each of their respective cameras. (I use "connect -s=xxxxxx" to make each chdkptp process connect to a given camera).

As an example of this, here are the outputs from two consecutive "list" commands (serial numbers truncated):
___> list
-1:Canon PowerShot A2500 b=001 d=027 v=0x4a9 p=0x3271 s=7F9...
-2:Canon PowerShot A2500 b=001 d=026 v=0x4a9 p=0x3271 s=6EE...
___> list
open_camera_dev_usb: ptp_opensession failed 0x2ff
open_camera_dev_usb:usb_ptp_device_reset(): Device or resource busy
usb_ptp_get_device_status(): Device or resource busy
open_camera_dev_usb: ptp_opensession 2 failed: 0x2ff
!1: b=001 d=027 ERROR: connection failed
-2:Canon PowerShot A2500 b=001 d=026 v=0x4a9 p=0x3271 s=6EE...

A list command on the other chdkptp process generated this:
___> list
Could not get device info!
!1: b=001 d=027 ERROR: connection failed
-2:Canon PowerShot A2500 b=001 d=026 v=0x4a9 p=0x3271 s=6EE

Re: RaspberryPi 2

Posted: 17 Jun 2015, 16:21
by duerig
Sunhou, maybe you can run a few variants of the lua script that is trying to be executed?

See ...

Lines 279-293 show the code that assembles and then sends the lua commands. Line 293 is where it is failing. If you run those commands by hand, you should be able to see where it is going wrong. Before it seemed like the require("drawings") was the failure and this made me think that your chdk installation was corrupted because a file was missing.


Re: RaspberryPi 2

Posted: 17 Jun 2015, 19:35
by duerig
Aha! I think I have figured it out. I would bet fifty cents that you are running the 'small' and not the 'full' CHDK image. Verify that your CHDK image is from:

The full one has lua modules for scripting that the small one does not. And Spreads assumes the full one. I had forgotten that there was even a small one because I haven't downloaded a new image in a while.

Even simpler, if you are using an A2500 camera, then you can use the following pair of images. Each one should go on the camera that takes a picture the given page (even or odd). The even camera is on the left and the odd camera is on the right.

I have verified that those exact images work on my exact archivist-1 image posted above on a Raspberry Pi 2 with a2500 cameras. Make sure to write-protect after you create the sd cards.


Re: RaspberryPi 2

Posted: 18 Jun 2015, 13:08
by sunhou
I had downloaded the full version (not the small version) myself when I tried it yesterday. Then when that still had trouble, I used the Acid program (since I live in a Mac OS-X world these days) to have it automatically identify and download the experimental CHDK for me; it claimed it did the full version too.

I wasn't able to extract the contents of your zip file on my Mac for some reason, even though I generally don't have any trouble with zip files. But I was able to extract on the RPi, then send the images back over to the Mac to burn to the SD cards.

But anyway, I don't know what the previous problems were, but your chdk images seem to have solved the problem! This time, when I ran spreads, on their screens the cameras actually displayed the IP address to connect my web browser to, and I was able to shoot photos with both cameras!

One small glitch is that I find the keyboard on the RPi still stops working every time I run spreads, but I can unplug it & plug it in again to get it back. And once I'm up and running, I'll only be starting things over ssh anyway, with no keyboard on the RPi.

Despite having done programming in Unix (SunOS, Linux, Mac OS-X) for 25 years, this particular software has been quite confusing to me. I have never touched lua before, and only barely used Python (I'm a C/MATLAB/R person). The docs I've looked at haven't given me a good understanding of the pieces coming together here, and it has been embarrassingly hard for me to figure out what's been going wrong.

My Archivist kit arrived several days ago, and I have slowly been assembling it in the evenings after my kids are in bed, so I hope I'm getting close to being functional! (By the way, fantastic job packing all the parts in the kit, and I love the well-labeled bags of bolts, nuts, etc.)

Thanks so much for all the help! I'm hoping I won't have too much trouble getting the rest of the way. But I'm sure once I've got things up and running, then I'll have to do some major thinking about how/where to do postprocessing. With my cardboard-box scanner that I experimented with as a precursor to all this, I just used ImageMagick on my Mac to convert all my JPGs to a single PDF. I had played briefly with ScanTailor, but had trouble with that -- when I tried to use it to process e.g. a batch of 20 pages, it would grind away for huge periods of time and I think eventually run out of memory (on a Mac with 32GB of RAM), so I must've been doing something very wrong.