Use Aleratec Roboracer LS Duplex under Linux to automate daily dvd backups
This is a successor to my another post published a few days ago: http://ricochen.wordpress.com/2009/07/14/use-aleratec-roboracer-cddvd-duplicator-under-linux/

#!/bin/bash
# script to control RoboRacer LS Duplex under linux
ADMIN=change_to@admin.email.address
DEBUG=1
DEV=`dmesg|awk '/pl2303.*ttyUSB/{print $NF;exit}'|tr -d ' '`
if [ -n "$DEV" ]; then
DEV=/dev/$DEV
if [ ! -c $DEV ]; then
info="pl2303 port does not exist, make sure \
RoboRacer LS Duplex is connected. If\
so please reboot it and try again."
rpr "Problem" "$info"
exit 1
fi
fi
# change the following device names if needed, if there
# are no other drives other than the Duplex's then most likely
# the names will be /dev/sr0 and /dev/sr1
TOPDRIVE=/dev/sr1
BOTTOMDRIVE=/dev/sr2
SCRIPT=${0##*/}
rpr() {
if [ -n "$ADMIN" ]; then
echo -e "$2" | mail -s "`hostname -f` \
RoboRacer: $1" $ADMIN
fi
}
usage() {
echo ">>Examples:"
echo "$SCRIPT demo"
echo "$SCRIPT load_topdrive"
echo "$SCRIPT load_bottomdrive"
echo "$SCRIPT eject_topdrive"
echo "$SCRIPT retrieve_topdrive"
echo "$SCRIPT eject_bottomdrive"
echo "$SCRIPT retrieve_bottomdrive"
echo "$SCRIPT remove_disc_topdrive"
echo "$SCRIPT remove_disc_bottomdrive"
echo "$SCRIPT top_hand_small"
echo "$SCRIPT top_hand_big"
echo "$SCRIPT top_hand_back"
echo "$SCRIPT bottom_hand_small"
echo "$SCRIPT bottom_hand_big"
echo "$SCRIPT bottom_hand_back"
echo "$SCRIPT top_tray_load_disc"
}
w() {
echo -e "$1" >$DEV
}
ww() {
case $1 in
top_hand_small) w !BNKRG95;; #top handle turns a small angle
top_hand_big) w !BNKRB90;; #top handle turns a big angle
top_hand_back) w !BNKRH96;; #top handle turns back to origin
bottom_hand_small)w !BNKPG93;; #bottom handle turns small angle
bottom_hand_big) w !BNKPB8E;; #bottom handle turns a big angle
bottom_hand_back) w !BNKPH94;; #bottom handle turns back to origin
top_tray_load_disc) w !BNKDP90;; #release one disc from the top disc loader
1) w !BNKLF8E;;
2) w !BNKFG89;;
10) w !BNKLG8F;;
13) w !BNKSTA3;;
*)
echo "unsupported parameter" && exit 0
;;
esac
sleep 2
}
eject_topdrive() {
[ -b $TOPDRIVE ] && /bin/eject $TOPDRIVE || echo "$TOPDRIVE does not exist"
}
retrieve_topdrive() {
[ -b $TOPDRIVE ] && /bin/eject -t $TOPDRIVE || echo "$TOPDRIVE does not exist"
}
eject_bottomdrive() {
[ -b $BOTTOMDRIVE ] && /bin/eject $BOTTOMDRIVE || echo "$BOTTOMDRIVE does not exist"
}
retrieve_bottomdrive() {
[ -b $BOTTOMDRIVE ] && /bin/eject -t $BOTTOMDRIVE || echo "$BOTTOMDRIVE does not exist"
}
load_topdrive() {
eject_topdrive
ww top_hand_small
ww top_hand_back
ww top_tray_load_disc
retrieve_topdrive
[ $DEBUG -eq 1 ] && echo "Top drive $TOPDRIVE is loaded"
}
load_bottomdrive() {
eject_bottomdrive && sleep 2
ww bottom_hand_small
ww bottom_hand_back
ww top_hand_big
eject_topdrive && sleep 2
retrieve_bottomdrive
ww top_hand_back
retrieve_topdrive && sleep 2
[ $DEBUG -eq 1 ] && echo "Bottom drive $BOTTOMDRIVE is loaded"
}
remove_disc_topdrive() {
ww top_hand_back
eject_topdrive && sleep 2
ww top_hand_small
ww top_hand_back
retrieve_topdrive
[ $DEBUG -eq 1 ] && echo "Disc removed from top drive $TOPDRIVE."
}
remove_disc_bottomdrive() {
ww bottom_hand_back
eject_bottomdrive && sleep 2
ww bottom_hand_small
ww bottom_hand_back
retrieve_bottomdrive
[ $DEBUG -eq 1 ] && echo "Disc removed from bottom drive $BOTTOMDRIVE."
}
demo() {
echo "executing $0 load_topdrive"
load_topdrive
echo "Simulating writing data to disc in top drive"
sleep 5
echo "executing $0 load_bottomdrive"
echo "Loading disc from top drive to bottom drive"
load_bottomdrive
echo "Simulating labeling disc in bottom drive"
sleep 5
echo "executing $0 remove_disc_bottomdrive"
echo "Removing disc from bottom drive"
remove_disc_bottomdrive
echo "Done."
}
if [ -c $DEV -a -b $TOPDRIVE -a -b $BOTTOMDRIVE ]; then
case $1 in
demo)
demo;;
load_topdrive)
load_topdrive;;
load_bottomdrive)
load_bottomdrive;;
eject_topdrive)
eject_topdrive;;
retrieve_topdrive)
retrieve_topdrive;;
eject_bottomdrive)
eject_bottomdrive;;
retrieve_bottomdrive)
retrieve_bottomdrive;;
remove_disc_bottomdrive)
remove_disc_bottomdrive;;
remove_disc_topdrive)
remove_disc_topdrive;;
top*|bottom*|1|2|10|13)
ww $1;;
*)
usage;;
esac
else
[ $DEBUG -ne 1 ] && rpr "Problem" "Check dud burner's connection"
fi
The above script is the major part of a dvd email archiving application that I have developed recently. With the help of USB Sniffer (current version 1.8) I am able to get those magic control strings. What amazed me is that under Linux, this duplicator doubles as a true robotic dvd archiver — all processes, from generating iso files to light-scribing labels, run ompletely without user interference. The only thing needs to be done is to load empty discs (capacity: 100 discs) and collect them once a while. Basically I use the above script in this way:
1) Generate daily (encrypted) email archive
2) Generate weekly iso’s
3) When iso is ready, burn the iso file on the first tray on the Duplex
4) Use python Image Library to generate a .bmp file with the date-range of the archives as the label for the following step
5) Light-scribe the disc on the second tray with data side faced-up.
6) Disc removed from the second tray into the dvd holder.
Hi, your script looks/sounds amazing! I intend to try running it with the Roboracer.
Do I understand correctly that you can light-scribe the label using a linux command?
If so, what is that command? I understand one needs a BMP image. How does one feed the image to the device for light-scribing?
Thanks
Andrew
Andrew,
Thanks and the script does do a great job in Linux (Using OpenSuSE 11).
Regarding light-scribing, I am using the lightscribe software from Lacie which has some CLI commands that I can use in my archiving script. Here’s the link
http://www.lacie.com/support/drivers/driver.htm?id=10094
You’ll need to install both the Host software and labeler to get it work.
As an alternative, you may want to check out the labeler from lightscribe.com:
http://www.lightscribe.com/downloadSection/linux/index.aspx
I tried the simple labeler but haven’t done any actual burning test yet and I don’t know if it has a CLI. I don’t know how this software works on the roboracer as the roboracer I wrote scripts for has been put into production for a few months now.
It’s correct that you need to supply a bitmap image to the lightscribing utility (either CLI or GUI). I use python imaging library (some OS calls it PIL) to generate bitmap file with date/time as the label and feed it to the burner.
When you get everything ready basically you put them all together in a logic order such as:
generate iso file -> (auto) load empty disc into top tray -> burn data with the top tray -> (auto) flip and load into second tray -> generate data/time bitmap file -> lightscribe -> eject disc to the bottom disc holder -> Done
You might also need to add some scripts to handle errors and generate report. Good luck.
Hi! Thanks for the reply. I have installed the Lacie software and will give it a go (64-bit Fedora 11)
Regarding image (bmp) auto-generation/editing: I suppose another option is to use ImageMagick (with python or any other gazillion interfaces to ImageMagick out there.)
This is process is so cool! Thanks for sharing it!
(When we actually get things going I’ll post here any additional observation that might be helpful)
Andrew
ImageMagick does rock. I tried using the command convert (which is from ImageMagick) under bash to create some curved text and it’s incredibly powerful and easy.
Hi. Your script has worked for me before, but now it is not. I have upgraded to Fedora 12 — not sure if that’s what’s making a difference.
” $script load_topdrive ” opens the top tray, but the disk does not drop down, so the tray closes empty.
any ideas?
thanks
andrew