Home > Bash, linux, Programming > Use Aleratec Roboracer LS Duplex under Linux to automate daily dvd backups

Use Aleratec Roboracer LS Duplex under Linux to automate daily dvd backups

[UPDATED 3/12/2012]
Just created a new project on github for this script for better viewing: https://github.com/midnightcodr/roboracer_ls_script

This is a successor to my another post published a few days ago: https://ricochen.wordpress.com/2009/07/14/use-aleratec-roboracer-cddvd-duplicator-under-linux/

ALERATEC DVD CD ROBORACER LS DUPLEX BURN AUTO FLIP

#!/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.

Advertisements
Categories: Bash, linux, Programming
  1. Andrew
    October 21, 2009 at 3:50 am

    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

  2. ricoch3n
    October 21, 2009 at 4:15 am

    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.

  3. Andrew
    October 22, 2009 at 8:51 am

    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

    • ricoch3n
      October 30, 2009 at 2:46 am

      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.

      • Andrew
        March 25, 2010 at 2:51 am

        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

  4. Charles
    March 13, 2012 at 1:52 pm

    This sounds very interesting. I am about to try this on CentOS/RedHat and was wondering if anyone had any experience in that environment.

    Another question is did you use cdrecord program to write the data to the disk?

    • ricoch3n
      March 15, 2012 at 1:05 am

      Yes I did use cdrecord as the command line tool to write data but that was the choice back then and I think any cd writer tool should work as long it can be executed via shell.

  5. Mr Person
    March 15, 2012 at 3:35 am

    #!/bin/bash

    This is buggy, use #!/usr/bin/env bash. Better yet use only POSIX features and #!/bin/sh

    # 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 ‘ ‘`

    Why search dmesg instead of using a tool designed for the job?

    rpr() {

    }

    not bad

    w() {
    echo -e “$1” >$DEV
    }

    why the function name, it seems hard to parse?

    ww() {
    }

    same question

    eject_topdrive() {
    [ -b $TOPDRIVE ] && /bin/eject $TOPDRIVE || echo “$TOPDRIVE does not exist”
    }

    why /bin/eject instead of checking to see if the tool exists? it might be more useful to non-linux systems this way.

    • ricoch3n
      March 19, 2012 at 11:01 am

      Thanks for your comments Mr Penson. Some of your points might be valid but I would not make any changes to this script as it was written back in 2009 while I was working on that project. I have changed my job and I don’t have access to that device any more. I am not afraid of changing code but changing the code without the actual machine to test with is never a good idea. I updated this post and uploaded the script to my github account simply wanting the code to be easier on the eyes, nothing more. You are welcome to make any changes if you are interested in. Regarding function names, I totally agree that I shouldn’t have used function names such as w and ww but again I was lazy back then.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: