darrylo@hpnmdla.hp.com (Darryl Okahata) (04/08/91)
Here is a beta-release of a program to backup the ENTIRE contents (libs and all) of an HP-48SX. It's not perfect, it's huge (about 1000 bytes), and it's probably inefficient (I just slapped this together). Also, while I've tried to work out any bugs, there's no guarantee that it works. ;-) The big advantage of these functions, over previously-released ones, is that you only need as much memory as the largest library/port variable to do a backup, as the libraries/port variables are saved in separate files and not as a concatenated list in main memory. The code at the end of this message contains two functions: BACKUP and RECOVER. In order to use these functions, you need to backup to a kermit SERVER; you must place the destination machine in kermit SERVER mode to use these routines. If you do not have a kermit that supports SERVER mode, you cannot use these routines. You must also use binary transfer mode; if you accidentally use ASCII mode, the transfer will take hours. Also, the clock display must be turned off, due to the archive bug; if the display is turned on, the clock will be turned off, and you will be asked to redo the operation. You press BACKUP to archive the contents of your HP-48SX. BACKUP sends each variable/library to the kermit server, one by one (it first checks to see if you have enough memory, though). They are stored in files named like: Lpnnn Where "p" is the port number (0..2), and "nnn" is a number from 1 to however many variables are in the port. As each port object is sent to the server, a note of its type (variable vs library) is made and is saved away (this is used to restore the backup). After all port objects have been saved, the flags are saved in a variable, and an ARCHIVE is done (the ARCHIVE file name is hard-coded to "BACKUP"). The HP-48SX will also terminate the kermit server at the end of the backup. Filename collisions are a problem here. I strongly suggest starting the kermit server in an empty directory before starting the backup. Here's a summary of the backup process: 1. Make sure the HP-48SX is using wire/binary transfer. 2. Place kermit into SERVER mode. 3. Press BACKUP. Have a cup of coffee while you wait. If the suppress error beep flag (-56) is not set, the calculator will beep when the full backup is complete. To restore the contents of your HP-48SX, you do the following: 1. Go to the directory containing the backup files. 2. Using kermit, transfer the "backup" archive back to the HP-48SX, and RESTORE it. 3. Put kermit into server mode. 4. Go to the HP-48SX directory that contains the BACKUP and RECOVER functions. 5. Press RECOVER. The calculator will transfer the necessary files and place the objects into the correct ports. That's it. ***** Known problems: * This program backs up EVERYTHING in RAM (of course, it doesn't touch ROM). It backs up *ALL* libraries, backup objects, other variables, etc.. You cannot tell it to not backup something, other than purging the object, or pulling the RAM card out of the calculator. * This program is huge, due partly to the extensive checks that makes sure that enough memory is present before doing the BACKUP/RECOVER. Perhaps these checks should be deleted (but I like having user-friendly programs ...)? * No kermit error checking is done. * Currently, some of the constants used to estimate the minimum amount of RAM needed are stored in variables ("M" and "S"). Perhaps these should be hard-coded? * The current set of functions can be placed anywhere, as long as the directory hierarchy is maintained. Some RAM can be saved if these functions were hard-coded to work in a particular directory (such as "{HOME BACKUP}"). Does anyone have any preferences? * Does anyone know how to force binary kermit transfers? * I consider this to be a beta-release. As such, the code is not commented. Extract the program at the end of this message into a file called "backup", and upload it to your HP-48SX. -- Darryl Okahata UUCP: {hplabs!, hpcea!, hpfcla!} hpnmd!darrylo Internet: darrylo%hpnmd@relay.hp.com DISCLAIMER: this message is the author's personal opinion and does not constitute the support, opinion or policy of Hewlett-Packard or of the little green men that have been following him all day. =============================================================================== %%HP: T(3)A(D)F(.); DIR BACKUP \<< PATH 0 0 \-> p sz n \<< L IFERR CCHECK THEN p EVAL ERRM DOERR END CLLCD "CHECKING" 4 DISP 0 2 FOR p p IFERR PVARS THEN DROP { } "" END IF TYPE 0 == THEN OBJ\-> IF DUP 0 > THEN DUP 'n' STO+ 1 SWAP START RCL BYTES SWAP DROP IF DUP sz > THEN 'sz' STO ELSE DROP END NEXT ELSE DROP END ELSE DROP END NEXT IF sz DUP MEM M + n S * + > THEN DROP p EVAL 1 DOERR END 'NEEDED' STO RCLF 'FLAGS' STO { } DUP DUP 'PV2' STO 'PV1' STO 'PV0' STO OPENIO 0 2 FOR p p IFERR PVARS THEN DROP { } "" END IF TYPE 0 == THEN OBJ\-> IF DUP 0 > THEN 1 SWAP FOR i CLLCD "Port " p + C$ 3 : " + OVER + C$ 1 " + 4 DISP IF DUP OBJ\-> DROP TYPE 0 \=/ THEN DUP \->STR ELSE p END "'PV" p + "'" + OBJ\-> STO+ RCL "'L" p + i + "'" + OBJ\-> SWAP OVER STO DUP SEND CLLCD "Wait ..." 4 DISP IF DUP VTYPE 15 == THEN PGDIR ELSE PURGE END NEXT ELSE DROP END ELSE DROP END NEXT CLLCD "Archiving main mem ..." 4 DISP :IO: BACKUP ARCHIVE DONE p EVAL \>> \>> RECOVER \<< PATH \-> p \<< L IFERR CCHECK THEN p EVAL ERRM DOERR END IF NEEDED MEM > THEN p EVAL 1 DOERR END OPENIO 0 2 FOR p "'PV" p + "'" + OBJ\-> RCL OBJ\-> IF DUP 1 \>= THEN 1 SWAP FOR i CLLCD \-> n \<< "L" p + i + DUP KGET "'" DUP ROT + SWAP + OBJ\-> DUP RCL DUP IF n TYPE 0 == THEN 0 p \->TAG STO ELSE n OBJ\-> STO END CLLCD "Wait ..." 4 DISP IF TYPE 15 == THEN PGDIR ELSE PURGE END \>> NEXT ELSE DROP END NEXT FLAGS STOF DONE p EVAL \>> \>> M 300 S 10 L DIR FLAGS { # 3808000400100FF0h # 0h } PV0 { 0 0 } PV1 { } PV2 { } NEEDED 2955 CCHECK \<< IF -40 FS? THEN -40 CF "Clock display disabled Retry operation" DOERR END \>> DONE \<< FINISH CLOSEIO CLLCD "DONE" 1 DISP 1 FREEZE IF -56 FC? THEN 1400 .1 BEEP END \>> END END
cook@hplvec.LVLD.HP.COM (Steve Cook) (04/26/91)
I found that the hp48 has to be in STD mode before the backup routine will work properly. This is a handy program. Thanks for your effort, Darryl.