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

RaspberryPi 2

Johannes Baiter's Spreads and SpreadPi are the latest control systems and postprocessors for DIY scanning. http://spreads.readthedocs.org
duerig
Posts: 358
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: RaspberryPi 2

Post by duerig » 13 Jun 2015, 21:56

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.

sunhou
Posts: 7
Joined: 03 Jan 2015, 15:58
Number of books owned: 0
Country: USA

Re: RaspberryPi 2

Post by sunhou » 15 Jun 2015, 13:29

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']..no file 'A/CHDK/SCRIPTS/drawings.lua'..no file 'A/CHDK/LUALIB/drawings.lua'
*** TERMINATED ***

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

duerig
Posts: 358
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: RaspberryPi 2

Post by duerig » 15 Jun 2015, 14:07

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.

-D

sunhou
Posts: 7
Joined: 03 Jan 2015, 15:58
Number of books owned: 0
Country: USA

Re: RaspberryPi 2

Post by sunhou » 15 Jun 2015, 15:46

Still getting the same errors (in the terminal window and on camera screen) with no mouse/keyboard plugged in, doing commands over ssh.

duerig
Posts: 358
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: RaspberryPi 2

Post by duerig » 16 Jun 2015, 07:10

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.

-D

sunhou
Posts: 7
Joined: 03 Jan 2015, 15:58
Number of books owned: 0
Country: USA

Re: RaspberryPi 2

Post by sunhou » 17 Jun 2015, 15:56

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/main.py", line 321, in main
run()
File "/usr/local/lib/python2.7/dist-packages/spreads/main.py", line 308, in run
args.subcommand(config)
File "/usr/local/lib/python2.7/dist-packages/spreadsplug/web/app.py", line 169, in run
app.run_server()
File "/usr/local/lib/python2.7/dist-packages/spreadsplug/web/app.py", line 364, in run_server
self.display_ip()
File "/usr/local/lib/python2.7/dist-packages/spreadsplug/web/app.py", line 327, in display_ip
.format(self._ip_address, self._listening_port))
File "/usr/local/lib/python2.7/dist-packages/spreadsplug/dev/chdkcamera.py", line 293, in show_textbox
self._device.lua_execute("\n".join(script), do_return=False)
File "/usr/local/lib/python2.7/dist-packages/chdkptp/device.py", line 186, in lua_execute
""" % (lua_code, remote_libs)).values()
File "/usr/local/lib/python2.7/dist-packages/chdkptp/lua.py", line 70, in pexecute
return self._parse_rval(self._rt.execute(checked_code))
File "/usr/local/lib/python2.7/dist-packages/chdkptp/lua.py", line 36, in _parse_rval
self._raise_exception(rval[2])
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

duerig
Posts: 358
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: RaspberryPi 2

Post by duerig » 17 Jun 2015, 16:21

Sunhou, maybe you can run a few variants of the lua script that is trying to be executed?

See https://github.com/DIYBookScanner/sprea ... kcamera.py

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.

-D

duerig
Posts: 358
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: RaspberryPi 2

Post by duerig » 17 Jun 2015, 19:35

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:

a2500-100a-1.4.0-4175-full_ALPHA.zip

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.

http://tenrec.builders/pi/a2500-camera-1.zip

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.

-D

sunhou
Posts: 7
Joined: 03 Jan 2015, 15:58
Number of books owned: 0
Country: USA

Re: RaspberryPi 2

Post by sunhou » 18 Jun 2015, 13:08

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest