#!/bin/bash # # Copyright 2013 Dany Qumsiyeh # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -o errexit set -o nounset ARDUINO=/dev/ttyACM0 # for git version of scanimage: # export LD_LIBRARY_PATH=sane-backends/backend/.libs SCAN_SETTINGS='--mode Color --resolution 300' # set up serial port for reading stty -F $ARDUINO 9600 min 1 time 2 -icrnl scanimage -V echo # find scanners SCANNERS=$(scanimage -L) echo "$SCANNERS" SCANNER1=$(echo "$SCANNERS" | head -n 1 | cut -d'`' -f2 | cut -d"'" -f1) SCANNER2=$(echo "$SCANNERS" | tail -n 1 | cut -d'`' -f2 | cut -d"'" -f1) echo echo $SCANNER1 echo $SCANNER2 echo echo 'ready to scan...' cat $ARDUINO \ | while read line; do echo 'scanning next page' > /dev/stderr echo done \ | tee >(scanimage --device $SCANNER1 $SCAN_SETTINGS --calibration-file /tmp/sane_cal1 --batch=%06da.pnm --batch-prompt) \ | tee >(scanimage --device $SCANNER2 $SCAN_SETTINGS --calibration-file /tmp/sane_cal2 --batch=%06db.pnm --batch-prompt)