HP49+ - Backing Up Calculator State



#2

I am trying to create a "one touch" routine that will, as much as possible, back up the entire state of my calculator to the SD card.

The commands are simple enough to backup the home directory (ARCHIVE) and flag settings (RCLF then STO to a variable of form :3:FLAGS, for example).

However, I would like my little program to be as thorough as possible, and I was wondering if there is any easy way write the entire contents of IRAM, ERAM, and FLASH (ports 0, 1, 2) to backup objects on the SD card, as effortlessly as ARCHIVE does for the HOME directory.

At this point this is largely an academic point--I don't store program objects or variables in ports 0 thru 3, and since I install libraries from the SD card I have the originals to reinstall manually if I ever have to. But it is a curiosity and it would be neat to know if anyone else has ever considered it.

As for backing up user key assignments, I must admit this interests me not at all. The HP49+ keyboard is busy enough without me make a dogs breakfast of it with my own assignments, so I don't use them. But if these assignments can be recalled and saved to a backup object, like flags can, that would be good to know.

many thanks,
Les


#3

Hi Les.

You may want to have a look at this post of John H. Meyers' on a looong thread on comp.sys.hp48:



http://groups.google.com/group/comp.sys.hp48/tree/browse_frm/thread/b556b30be73fff9f/942e5c13528971d4?rnum=21&q=backup+HOME+directory&_done=%2Fgroup%2Fcomp.sys.hp48%2Fbrowse_frm%2Fthread%2Fb556b30be73fff9f%2F641d6fee23c0febf%3Flnk%3Dgst%26q%3Dbackup%2BHOME%2Bdirectory%26rnum%3D1%26#doc_641d6fee23c0febf

There were some interesting tips, IIRC.

Hope this helps.

All the best.

Giancarlo


#4

Here's mine

<<
3: BACK49P PURGE 3: BACK49P ARCHIVE[ln]
3: KEYS49P PURGE RCLKEYS 3: KEYS49P STO 3:[ln]
FLAG49P PURGE RCLF 3: FLAG49P STO[ln]
>> ARCH STO

and another useful too:

<<
3: KEYS49P EVAL STOKEYS[ln]
3: FLAG49P EVAL STOF[ln]
3: BACK49P RESTORE[ln]
>> REST STO

Change 3: to 2: if you don't have an SD card. After RESToring, the calculator resets. This preserve settings and the rest.

-- Antonio


#5

Thanks, Antonio, mine looks very similar, but my original question asked if one can go one step further--namely, backup port memory in backup objects on the SD card?

Let's say I have libraries installed in ports 1 and 2--is there a convenient, one step way to backup those ports the same way ARCHIVE backups the HOME directory to a single backup object? My combing over the AUR would suggest no. But I would like to try. It would be a shame to lose things from port memory and have to reinstall each library individually. But if that is the way it needs to be, so be it.

Les


#6

Hi Les.

Quoting from:

http://groups.google.com/group/comp.sys.hp48/tree/browse_frm/thread/b556b30be73fff9f/942e5c13528971d4?rnum=21&q=backup+port+memory+in+backup+objects+on+the+SD+card&_done=%2Fgroup%2Fcomp.sys.hp48%2Fbrowse_frm%2Fthread%2Fb556b30be73fff9f%2F641d6fee23c0febf%3Flnk%3Dgst%26q%3Dbackup%2Bport%2Bmemory%2Bin%2Bbackup%2Bobjects%2Bon%2Bthe%2BSD%2Bcard%26rnum%3D1%26#doc_641d6fee23c0febf

"ALL objects (except libraries) that are stored into ports
are also *automatically* enclosed within a Backup object,
basically to provide a single consistent structure
within the contiguous memory of a port,
giving every stored object a length and a name"


so that a built-in cpability seems not to be available.

But you can use specific piece of software, like this one:


http://www.hpcalc.org/details.php?id=5955

which is commented as follows:

"This 688-byte program allows you to backup all the data of your HP 49G+ into the SD card in just a few seconds. You can select to save Home and/or any port(s) in any path of port 3. Tested with ROM 1.23.
By Jorge Cevallos M."

Hope this helps.
Best regards.
Giancarlo


#7

Perfect! Exactly what I was looking for.

Doesn't backup flags and user key assignments, but that is easy enough to incorporate into a custom routine which, among other tasks, calls the software.

Thanks for the tip!

Les


#8

Les,
I'm very glad to have proved helpful.
Once in a blue moon, it's good to give and not only to take something from this fantastic Forum :-)
Warmest regards.
Giancarlo

#9

Quote:
I am trying to create a "one touch" routine that will, as much as possible,
back up the entire state of my calculator to the SD card.

I expect that it's possible.
Quote:
The commands are simple enough to backup the home directory (ARCHIVE) and flag
settings (RCLF then STO to a variable of form :3:FLAGS, for example).

Or just store the list in a global variable, which will be included in the
archive.
Quote:
However, I would like my little program to be as thorough as possible, and I
was wondering if there is any easy way write the entire contents of IRAM,
ERAM, and FLASH (ports 0, 1, 2) to backup objects on the SD card, as
effortlessly as ARCHIVE does for the HOME directory.

Well, first off, on the 49 series (except perhaps the 48gII, which I'm not
very familiar with), I'd recommend not using port 0 for anything, unless
perhaps some library requires that it be in port 0. So why is it there? Well,
because it is useful on the 48 series, because a port is required for using
libraries, but not everyone owns an SRAM card for his 48SX or 48GX, and of
course the other models can't use a card. You might think as port 0 as being
somewhat like a RAM disk on a DOS system; if you don't have the hardware, then
simulate it with software. A major disadvantage of using port 0 is that it
shares the same pool of memory with "System RAM", so using it reduces the
amount of free memory. Another disadvantage is that a memory clear clears port
0 as well. But with the 49 series, you have other ports built-in, so why use
port 0?
Quote:
At this point this is largely an academic point--I don't store program objects
or variables in ports 0 thru 3, and since I install libraries from the SD card
I have the originals to reinstall manually if I ever have to. But it is a
curiosity and it would be neat to know if anyone else has ever considered it.

Sure. Wolfgang's Filer6 program includes includes an ->SD-> card operation, capable of
moving selected or all port objects to an flash card. See
http://page.mi.fu-berlin.de/raut/WR49/index.htm#General. It also has
other advantages; I prefer it to the built-in filer.
Quote:
As for backing up user key assignments, I must admit this interests me not at
all. The HP49+ keyboard is busy enough without me make a dogs breakfast of it
with my own assignments, so I don't use them. But if these assignments can be
recalled and saved to a backup object, like flags can, that would be good to
know.

That's not an issue anyway, because the user key assignments and alarm
information are stored in the hidden subdirectory, and are included within an
archive. Of course, when you RESTORE the archive, some of the alarms may be
past due, so I suppose that it would be a good idea to check them.

But you wanted all objects in a port to be backed up to the card, not just the
libraries. A very simple and easy (but not "one-touch") way is to tag all of
them in the filer, and then use it to copy them to the card. But writing a
UserRPL program to do it seems pretty straight-forward.

Traditionally, existing objects in ports can't be overwritten; if you want to
replace one, you have to purge it first. This first program behaves like that;
it errors out the first time that it can't store a file on the card.

%%HP: T(3)F(.);
@ For 49g+ or 50g.
@ Program to copy all objects from port 0, 1, or 2 to a flash card.
@ Will error out ("Object In Use") if the file already exists in the directory
@ on the flash card.
@ There must be enough free system memory available to hold the largest object
@ in the port, plus a little more.
@ There must be enough available capacity on the memory card to hold all of
@ the objects from the port.
@ Arguments:
@ Level 2: Real or zint, port number to copy objects from.
@ Level 1: String, directory on the card to store the files in, in the form
@ "DIR1/DIR2/DIR3". Use just an empty string, "", to store them in
@ the root directory. To key in the / character, press ALPHA (if
@ needed), then press RightShift, and then press the divide key.
@ Results from the BYTES command:
@ Checksum: #7B4Eh
@ Size: 149.
\<< @ Begin program.
"/" + @ Append to path.
SWAP PVARS DROP @ List of port variable names.
1. @ Loop index initial value.
OVER SIZE @ Loop index final value.
FOR n @
DUP n GET @ Tagged port variable name.
DUP RCL @ Port variable object.
SWAP DTAG @ Untagged port variable name.
IF @
DUP TYPE 28. == @ Library number?
THEN @
"L" SWAP + @ Prepend "L".
ELSE @
\->STR @ Quoted name within string.
2. OVER SIZE 1. - SUB @ Remove "'" name delimiters.
END @
4. PICK SWAP + @ Prepend path string.
3. \->TAG @ Tag with port number for memory card.
STO @ Store object as file on memory card.
NEXT @
DROP2 @ Discard path and list.
\>> @ End program.
But suppose that you want to store the files on the card, even if they already
exist there? That's an easy modification. This next program will replace
existing files without warning.
%%HP: T(3)F(.);
@ For 49g+ or 50g.
@ Program to copy all objects from port 0, 1, or 2 to a flash card.
@ Will replace same-named files without warning.
@ There must be enough free system memory available to hold the largest object
@ in the port, plus a little more.
@ There must be enough available capacity on the flash card to hold all of the
@ objects from the port.
@ Arguments:
@ Level 2: Real or zint, port number to copy objects from.
@ Level 1: String, directory on the card to store the files in, in the form
@ "DIR1/DIR2/DIR3". Use just an empty string, "", to store them in
@ the root directory. To key in the / character, press ALPHA (if
@ needed), then press RightShift, and then press the divide key.
@ Results from the BYTES command:
@ Checksum: # C9EEh
@ Size: 154.
\<< @ Begin program.
"/" + @ Append to path.
SWAP PVARS DROP @ List of port variable names.
1. @ Loop index initial value.
OVER SIZE @ Loop index final value.
FOR n @
DUP n GET @ Tagged port variable name.
DUP RCL @ Port variable object.
SWAP DTAG @ Untagged port variable name.
IF @
DUP TYPE 28. == @ Library number?
THEN @
"L" SWAP + @ Prepend "L".
ELSE @
\->STR @ Quoted name within string.
2. OVER SIZE 1. - SUB @ Remove "'" name delimiters.
END @
4. PICK SWAP + @ Prepend path string.
3. \->TAG @ Tag with port number for memory card.
DUP PURGE @ Purge file if it exists.
STO @ Store object as file on memory card.
NEXT @
DROP2 @ Discard path and list.
\>> @ End program.
How about one that asks what to do if the file already exists? That doesn't
seem as if it ought to be too difficult, but I was surprised at how much time
I spent chasing down typos, as well as some things that I meant to type in,
but apparently didn't; maybe I needed a little food to power my brain? I
really should remember to eat when I need to. Anyway, this one seems to work
now.
%%HP: T(3)F(.);
@ For 49g+ or 50g.
@ Program to copy all objects from port 0, 1, or 2 to a memory card.
@ Will ask whether to replace a file.
@ There must be enough free system memory available to hold the largest object
@ in the port, plus a little more.
@ There must be enough available capacity on the memory card to hold all of
@ the objects from the port.
@ Arguments:
@ Level 2: Real or zint, port number to copy objects from.
@ Level 1: String, directory on the card to store the files in, in the form
@ "DIR1/DIR2/DIR3". Use just an empty string, "", to store them in
@ the root directory. To key in the / character, press ALPHA (if
@ needed), then press RightShift, and then press the divide key.
@ Results from the BYTES command:
@ Checksum: # D168h
@ Size: 491.5
\<< @ Begin program.
\<< @ Beginning of recursive subprogram for file exists.
PICK3 @ Untagged port variable name string.
"\010already on card.\010Press R to replace.\010Press S to skip.\010Press Q to quit." @
+ @ Concatenate strings.
CLLCD @ Clear display.
3. DISP @ Prompt for keystroke.
0. WAIT @ Wait for keystroke.
CLLCD @ Clear display.
IP @ Ignore keyplane.
CASE @
DUP 52. == @ R pressed?
THEN @
DROP @ Discard key value.
DUP PURGE @ Purge file from card.
STO @ Store object as file on memory card.
END @
DUP 53. == @ S pressed?
THEN @
3. DROPN @ Discard key value, name, and object.
END @
51. == @ Q pressed?
THEN @
5. DROPN @ Clean up stack.
0. DOERR @ Error out.
END @
\<-s EVAL @ Recurse.
END @
\>> @ End of subprogram for file exists.
\-> \<-s @ Bind.
\<< @ Begin local defining procedure.
"/" + @ Append to path.
SWAP PVARS DROP @ List of port variable names.
1. @ Loop index initial value.
OVER SIZE @ Loop index final value.
FOR n @
DUP n GET @ Tagged port variable name.
DUP RCL @ Port variable object.
SWAP DTAG @ Untagged port variable name.
IF @
DUP TYPE 28. == @ Library number?
THEN @
"L" SWAP + @ Prepend "L".
ELSE @
\->STR @ Quoted name within string.
2. OVER SIZE 1. - SUB @ Remove "'" name delimiters.
END @
DUP UNROT @ Copy to level 3.
5. PICK SWAP + @ Prepend path string.
3. \->TAG @ Tag with port number for memory card.
DUP2 @ Copy for error condition.
IFERR @ Trap error.
STO @ Try storing object as file on memory card.
THEN @
IF @
ERRN #9h == @ "Object in Use" error?
THEN @
IF @
-55. FC? @ Last argument saved?
THEN @
DROP2 @ Discard extra object and name.
END @
\<-s EVAL @ Execute subprogram.
ELSE @
ERRN DOERR @ Execute any other error.
END @
ELSE @
DROP2 @ Discard extra object and name.
END @
DROP @ Discard the string.
NEXT @
DROP2 @ Discard path and list.
\>> @ End local defining procedure.
\>> @ End program.
I really admire the input form in Jorge's BCKP21, but I'm too lazy to attempt
that.

A bigger problem would be automatically restoring the files to a port, as
there doesn't seem to be any built-in RPL (or assembly language) method of
getting a list of the files on the card (or in one of it's directories). Using
the filer is easy enough, but
SDFiler may well
include that capability (I haven't tried it yet).

Quote:
many thanks,

many welcomes, and,

Regards,
James


#10

James,

hats off to your post!! (and I feel this is a very well-spent pair of exclamation marks :-)

An outstanding piece of information and education of User RPL programming at the same time.

I'm really delighted and I'm gonna bookmark and save it for any future reference.

Thank you & best regards.

Giancarlo

#11

Wow!

This wildly beyond anything I dreamed of when making my original query.

For whatever reason, I prefer to back up flags to a separate file on the SD card and restore them before restoring the rest of the archive, very much as in Antonio's little routine. My little routine is quite similar--indeed, the file names are actually the only thing that is really any different.

I agree with you that it is unwise to put anything in port 0 and I frankly never do.

This discussion has got me wondering how desperately important it is for me to back up ports 1 and 2 to the SD card, since automating the process is not as straightforward as backing up main memory, flags, and key assignments. The fact is, I only use ports 1 and 2 to store libraries, and in the unfortunate and unlikely event that these libraries get erased (ON-A-F and dead main batteries do not erase ports 1 and 2, and the backup button cell seems in good shape on my unit), it is a simple matter to copy the desired libraries back over from the SD card to the desire ports and reattach them via ON-C.

My interest in "total backup" is linked to my newfound preference for powering the unit with NiMH cells. One of the great advantages of the 49 series is SD storage capability. It is fast and robust, unlike the fussy and delicate magnetic cards of the 41 series and the at-times compicated serial port interface of the 48 series.

Indeed, I would make the admittedly bold statement that there is absolutely no excuse for the truly serious user of 49g+ or 50g not to have and SD card in the calculator for backup at all times. Granted, there was a time when such memory was not cheap--just four years ago I paid 130CAD (about 110USD) for a 128MB MemoryStick for my Sony Clie!--but nowadays the smaller size cards, which are more than adequate for use with the the relatively tiny files created by these calculators are so cheap it seems that some sellers can't even give the things away! Indeed, the 128MB card I use with my 49G+ was a throw-in accessory with a digital recorder I bought. It is woefully inadequate for serious sound recording and will only accomodate a few minutes of a 96kHz/24bit WAV file, so I wasted no time in getting 2GB card for that device. But the little card is positively huge as far as the 49G+ is concerned--I could back up my existing memory hundreds of times over and still have lots of space.

So my low-level solution right now is the little program similar to Antonio's, which I assign to a the global variable BKUP. I hit that key several times when using the calculator, always before turning it off after a session. And every so often I copy the contents of the SD card to a folder on my PC. Overkill?--perhaps. But it is just so quick and easy especially when I consider that using WALL to backup my 41CX takes 11 magnetic cards, a few minutes of time, fairly fresh batteries, and organization lest I mix up the cards! And I am ever mindful that the much celebrated 42S, 32SII, and 15C don't have any backup capacity at all.

As for backing up port memory, I can do that less frequently and by using either James's code or the very easy to use BCKP21.

Les


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime reset to factory state? BruceH 3 5,134 11-26-2013, 07:27 PM
Last Post: BruceH
  hp49 en hp50 qgrdne 1 1,060 02-04-2013, 08:05 AM
Last Post: Eduardo Duenez
  Symbolic limit of a function of 2 variables, HP49/50 Gilles Carpentier 0 902 08-26-2012, 10:28 AM
Last Post: Gilles Carpentier
  HP49 PocketGuide in German / Italian / Spanish / French / Portuguese Software49g 1 1,147 06-30-2012, 09:43 AM
Last Post: Luiz C. Vieira (Brazil)
  Backing up several HP48G/G+/GX via HP50 Thomas Chrapkiewicz 4 1,825 02-14-2011, 11:39 AM
Last Post: Tim Wessman
  HP 41C and CV boards with some piggy backing from the factory Geoff Quickfall 0 861 03-18-2010, 01:51 PM
Last Post: Geoff Quickfall
  HP49 with 48series KB... NACHO 0 762 06-18-2009, 05:43 PM
Last Post: nacho
  State of the art Walter B 12 2,970 03-20-2008, 01:12 PM
Last Post: designnut
  Communicating stack state transitions, a notation. Arne Halvorsen (Norway) 7 2,159 10-10-2007, 01:43 PM
Last Post: Arne Halvorsen (Norway)
  HP49+ Memory--scratching my head Les Wright 10 2,750 06-03-2006, 03:52 AM
Last Post: James M. Prange (Michigan)

Forum Jump: