Using rsupdateapp

16 posts / 0 new
Last post
Santa Matt
Santa Matt's picture
Using rsupdateapp

Has anyone gotten a script to run at boot time using the rsupdateapp? Nocturnal said a while back that placing things in there could fire off a script.

What I want to do is to fire off a script that watchs the hand controls, allowing you to trigger four of the macros without the remote. I have the script written but whenever I call it from rsupdateapp it doesn't load my personality, it just goes to the default personality and macros. I have tried it everywhere from the top to the bottom of the rsupdateapp script.

I am working on a personality that will have a number of interesting macros. I have one called Desktop Companion. That one will act as a magic 8 ball, go into a silent guard mode where it takes pictures of any disturbances, give you a random compliment or make random idle comments periodically. I have another that turns him into a Robo DJ. And one that recites my 10 rules. The fourth macro, of course, is Helibot and Tika's great USB terminal.

So, if anyone has any ideas, I'd like to see them.

Helibot
Helibot's picture

Hi Santa Matt,
   Recently I have done just what you were asking.  I have been using rsappudate to boot the robot exactly as normal AND then running extra commands to run the USB console as well. I have been using it for probably 20 boots now and it seems to always work.
  Normally most rsappupdate scripts rename themselves so they only get run once. But I wanted it to do the same thing every boot, so I have not done this.

Here is my script:-

#rsupdateapp SCRIPT TO MAKE THE ROBOT BOOT AS NORMAL
#by Helibot
#(This just completes all the commands done at the end of etc/profile)
#So the robot should boot up exactly as if he booted with running rsupdateapp
#This version then starts the USB console as well

mkdir /tmp/state
touch /tmp/state/RSM_CAMERA_BLUE_HIT_VAR
touch /tmp/state/RSM_CAMERA_GREEN_HIT_VAR
touch /tmp/state/RSM_CAMERA_HUMAN_HIT_VAR
touch /tmp/state/RSM_CAMERA_RED_HIT_VAR
touch /tmp/state/RSM_CAMERA_BLACK_HIT_VAR
touch /tmp/state/RSM_GAUNTLET_L_I_VAR
touch /tmp/state/RSM_GAUNTLET_L_O_VAR
touch /tmp/state/RSM_GAUNTLET_R_I_VAR
touch /tmp/state/RSM_GAUNTLET_R_O_VAR
touch /tmp/state/RSM_FOOT_L_B_VAR
touch /tmp/state/RSM_FOOT_L_F_VAR
touch /tmp/state/RSM_FOOT_R_B_VAR
touch /tmp/state/RSM_FOOT_R_F_VAR
touch /tmp/state/RSM_GRIPPER_R_VAR
touch /tmp/state/RSM_GRIPPER_L_VAR
touch /tmp/state/RSM_IR_TRIGGER_L_D_VAR
touch /tmp/state/RSM_IR_TRIGGER_L_L_VAR
touch /tmp/state/RSM_IR_TRIGGER_L_R_VAR
touch /tmp/state/RSM_IR_TRIGGER_S_D_VAR
touch /tmp/state/RSM_IR_TRIGGER_S_L_VAR
touch /tmp/state/RSM_IR_TRIGGER_S_R_VAR
touch /tmp/state/RSM_SOUND_CENTER_VAR
touch /tmp/state/RSM_SOUND_LEFT_VAR
touch /tmp/state/RSM_SOUND_RIGHT_VAR
touch /tmp/state/AUTOTRACK_POSITION_VAR
touch /tmp/state/BC_AUDIOPLAYER_VAR
touch /tmp/state/BC_IMAGEVIEWER_VAR
touch /tmp/state/BC_TAKEMOVIE_VAR
touch /tmp/state/BC_VIDEOPLAYER_VAR
touch /tmp/state/BC_AUTOTRACK_VAR
touch /tmp/state/BC_JAVA_VAR
touch /tmp/state/BC_TAKEPICTURE_VAR
touch /tmp/state/mp3_state
touch /tmp/state/sleep_state
touch /tmp/curvol
touch /tmp/state/scriptrun
touch /tmp/state/linein_state
touch /tmp/state/usb_state

echo ***rsupdateapp - starting /usr/bin/robot/run.sh**

/usr/bin/robot/init_sd.sh
/usr/bin/robot/run.sh

if [ -f /tmp/SD_EXIST ]; then
 /bin/mount /dev/mmc /mnt/sd -o ro,remount
else
 /bin/mount /dev/nand3 /mnt/sd -o ro,remount
fi

#Helibot added the commands below to setup the USB Console link
echo ***Installing USB Console shell**
/sbin/rmmod mx1ads_usbd
#Wait for Windows to recognise the USB driver being removed
sleep 8
#Now load the USB console driver
/bin/mknod -m 777 /tmp/ttyUSB c 188 0
/sbin/insmod /mnt/sd/rsupdate/mx1ads_usbserial.o
ln -s /bin/sh /tmp/redirect
/tmp/redirect < /tmp/ttyUSB > /tmp/ttyUSB 2<&1 &
echo ***Finished Installing USB Console shell**

#When this script finished the /etc/profile will go into a forever loop.
#So lets start another shell.
sh

If you copy the above to a file remember you MUST use an editor to save it in UNIX Mode. 

I love your ideas for a personality with different behaviour (not just 'play something and finish').  I have been planning todo something for 'random' remarks, but you have already done it...:-). Would love to try it out!.

 Cheers
   Helibot

 

Santa Matt
Santa Matt's picture

Interestingly, my default rsupdateapp is totally different from yours.

#!/bin/sh

# Set the value to yes to generate a console.log, any other value will disable the log
DEBUG="yes"

# Create state variables

mkdir /tmp/state
touch /tmp/state/RSM_CAMERA_BLUE_HIT_VAR
touch /tmp/state/RSM_CAMERA_GREEN_HIT_VAR
touch /tmp/state/RSM_CAMERA_HUMAN_HIT_VAR
touch /tmp/state/RSM_CAMERA_RED_HIT_VAR
touch /tmp/state/RSM_CAMERA_BLACK_HIT_VAR
touch /tmp/state/RSM_GAUNTLET_L_I_VAR
touch /tmp/state/RSM_GAUNTLET_L_O_VAR
touch /tmp/state/RSM_GAUNTLET_R_I_VAR
touch /tmp/state/RSM_GAUNTLET_R_O_VAR
touch /tmp/state/RSM_FOOT_L_B_VAR
touch /tmp/state/RSM_FOOT_L_F_VAR
touch /tmp/state/RSM_FOOT_R_B_VAR
touch /tmp/state/RSM_FOOT_R_F_VAR
touch /tmp/state/RSM_GRIPPER_R_VAR
touch /tmp/state/RSM_GRIPPER_L_VAR
touch /tmp/state/RSM_IR_TRIGGER_L_D_VAR
touch /tmp/state/RSM_IR_TRIGGER_L_L_VAR
touch /tmp/state/RSM_IR_TRIGGER_L_R_VAR
touch /tmp/state/RSM_IR_TRIGGER_S_D_VAR
touch /tmp/state/RSM_IR_TRIGGER_S_L_VAR
touch /tmp/state/RSM_IR_TRIGGER_S_R_VAR
touch /tmp/state/RSM_SOUND_CENTER_VAR
touch /tmp/state/RSM_SOUND_LEFT_VAR
touch /tmp/state/RSM_SOUND_RIGHT_VAR
touch /tmp/state/AUTOTRACK_POSITION_VAR
touch /tmp/state/BC_AUDIOPLAYER_VAR
touch /tmp/state/BC_IMAGEVIEWER_VAR
touch /tmp/state/BC_TAKEMOVIE_VAR
touch /tmp/state/BC_VIDEOPLAYER_VAR
touch /tmp/state/BC_AUTOTRACK_VAR
touch /tmp/state/BC_JAVA_VAR
touch /tmp/state/BC_TAKEPICTURE_VAR
touch /tmp/state/mp3_state
touch /tmp/state/sleep_state
touch /tmp/curvol
touch /tmp/state/scriptrun
touch /tmp/state/linein_state
touch /tmp/state/usb_state

# Remount the SD readwrite

mount -o remount -o rw -t vfat /dev/mmc /mnt/sd

# Start things running!

/usr/bin/robot/init_sd.sh

killall nano-X
killall main_ui

. /usr/bin/robot/init.sh.ff
/usr/bin/robot/nano-X -p&
/mnt/sd/rsupdate/mediadaemon_sun&
#/mnt/sd/rsupdate/mediadaemon_sun_pipe&
/usr/bin/robot/start_robot_main &
/usr/bin/robot/main_ui&

# Add the midp ARM libs to the LD_LIBRARY_PATH

export LD_LIBRARY_PATH=/mnt/sd/midp/lib/arm:$LD_LIBRARY_PATH

# Add the midp ARM bin to the PATH (prepend because the old VM might already be in path)

export PATH=/mnt/sd/midp/bin/arm:$PATH

# Switch to media mode.

sleep 2s

#/mnt/sd/rsupdate/togglemode

sleep 1s

#/mnt/sd/rsupdate/togglemode

# Select the Midlet to run by uncomment the run line (you can only run one midlet at a time)

export MIDP_HOME=/mnt/sd/midp

if [ -f /mnt/sd/midlet.jar ]; then
opt='-classpathext /mnt/sd/midlet.jar -1 Main'
else
opt='-1 com.sun.robot.test.MainTest'
fi

if [ "x"$DEBUG = "xyes" ]; then
/mnt/sd/rsupdate/debugMidlet.sh $opt &
else
runMidlet $opt &
fi

## Run the Robot exit demo midlet
#runMidlet internal com.sun.robot.demo.escape.ExitDemo &

## Run the Robot dance demo midlet
#runMidlet internal com.sun.robot.demo.dance.DanceDemo &

cd /mnt/sd
exec /bin/ash

But your works just fine and launches the usbserial too. Someone with more Linux and RS Media savvy than I will need to answer that one. Anyway, I am starting to alter yours with my additions. As for the personality, I have some more things I would like to add before general release. But if you would like an alpha copy I would be happy to send it to you.

Nocturnal
Nocturnal's picture

On looks like a copy of the standard onboard boot script, the other looks like a copy of the boot script that comes with the java dev kit.

Incidentally, helibot, you dont need this bit.

if [ -f /tmp/SD_EXIST ]; then
/bin/mount /dev/mmc /mnt/sd -o ro,remount
else
/bin/mount /dev/nand3 /mnt/sd -o ro,remount
fi

Unless you want to make the SD card read only, and even then you only need 1 line.

Santa Matt
Santa Matt's picture

While we are discussing scripts, does anyone know how to change to media mode via a script?

Helibot
Helibot's picture

Hi Santa Matt,
Yes , your startup code is quite different to mine. I guess Nocturnal is right - did you have the java dev kit version?
Interestingly it looks like you have a different version of mediadaemon called '/mnt/sd/rsupdate/mediadaemon_sun'. Wonder whats differnt in it?
If you still use any of the Java function then you may want to make sure your mediadaemon_sun is still used. (In my script I think that script /usr/bin/robot/run.sh start it.)
Did you check that the USB console worked allright with my script?
(If its oK, then I will post the script to the USB console thread and get Tika to include it in the next devkit version.)

Hey Nocturnal,
Thanks for the hint , I would like to have the SD card writable by defualt!.
I'll change my script.

Cheers
Helibot

Helibot
Helibot's picture

Santa Matt said: While we are discussing scripts, does anyone know how to change to media mode via a script?

Hi Santa Matt,

     No , Im not sure , but would like to know! (I could do this in the RSM Alarm Clock startup script). 

Also to extend your question - does anyone know how to change the volume from a script or commandline?   (There is a /tmp/curvol file but that just sems to be readable - you cant set it by writing to it).

Cheers
  Helibot

Nocturnal
Nocturnal's picture

The commented out toggle mode lines may work, just one small problem, changing the mode on the main board, will not change the mode in the interface. In other words, the UI and the robot go out of sync.

I don't recall if the togglemode command with the java dev kit actually works or not (if not a correct call to send_robot_cmd should do it), but its easy to test. While in control mode, run the togglemode command, if the right hand direction pad on the remote causes the RS Media's left arm/hand to move, you've changed modes. If the head moves, you haven't.

Helibot
Helibot's picture

Hi Nocturnal,
Can you tell me the correct send_robot_cmd for changing modes?.
I had a reference to
Modes
------
ff 00 04 01 00
ff 00 04 02 00
ff 00 04 03 00
from a very old post (may have even been yours Nocturnal!!)
But send_robot_cmd ff 00 04 xx 00 seems todo nothing.
Cheers Helibot

Nocturnal
Nocturnal's picture

Unfortunately I don't have my notes in front of me, so I can't say. The best way to check if it changed modes is with the test I outlined in my previous post (which I assume you have tried), since visually there will be no difference.

A small addition, if your in media mode, the RS Media should not respond to the right hand direction pad.

Helibot
Helibot's picture

Hi Nocturnal,
Yep, I tried your test, it Right remote keys moved head. So it wasnt working. If anyone elase know the right send_robot_cmd then please let me know.

Cheers
Helibot

Santa Matt
Santa Matt's picture

Interesting development, if I use Helibot's rsupdateapp, the SD gets mounted ro. I removed the:
if [ -f /tmp/SD_EXIST ]; then
/bin/mount /dev/mmc /mnt/sd -o ro,remount
else
/bin/mount /dev/nand3 /mnt/sd -o ro,remount
fi
I added:
mount -o remount -o rw -t vfat /dev/mmc /mnt/sd
both after the touch area and as the last line
and I also tried:
/bin/mount /dev/mmc /mnt/sd -o rw,remount
in the same places. Either of these commands will work from a prompt within the USBserial terminal. But none of them seem to work from the rsupdateapp script. I'm wondering if something in the init_sd or run scripts are setting it back? But you would think that as the last line it would work.

Helibot
Helibot's picture

Hi Santa Matt,
   I tried changing my code to :
#if [ -f /tmp/SD_EXIST ]; then
/bin/mount /dev/mmc /mnt/sd -o rw,remount
#else
# /bin/mount /dev/nand3 /mnt/sd -o ro,remount
#fi

and it didnt work??? Dont know why. I think you guessed right - that stuff in the run.sh script maybe changing things.

So instead I put:-
...
echo ***Finished Installing USB Console shell**
sleep 10
/bin/mount /dev/mmc /mnt/sd -o rw,remount
#When this script finished the /etc/profile will go into a forever loop.
#So lets start another shell.
sh

And this seemed to work OK.  BTW a good way to check what all the mounts are is run command  

cat /proc/mounts

Cheers
   Helibot

Santa Matt
Santa Matt's picture

I just run mount with no parameters and it returns a list of all mounted volumes. I tried those lines and it worked for me also. Now, the next step is to get my Win XP box setup to cross compile and get me a new book on C.

Helibot
Helibot's picture

Hi Matt,
I have been looking at finding/building a new compiler (other than what is available in the Redhat VM image that is commonly used - I cant link to the libraries on RSMedia using that version). I successfully built a new linux GCC version last night. I haven't tested it yet though - I'll let you know if it works.

Cheers
Helibot

Santa Matt
Santa Matt's picture

I currently have my main machine, Win XP, a Mac running OS9 and I recently built a Ubuntu 8 machine. Of course I can always make VM too. I've worked with MS virtual PC, Sun's Virtual box and VMware. But between Sparky and my Nokia 770, I think it is time I learned C and cross compiling.