The standard way to query the OS version on the PalmOS is to use a snippet of code that looks something like this:
UInt32 romVersion = 0;
FtrGet(sysFtrCreator,sysFtrNumROMVersion, &romVersion);
After calling this, your romVersion variable will be filled with the version of the OS that is running in the format of 0xMMmfsbbb. Expanding on this, the MM is the major version, the m is the minor version and the f is the "fix" version. Here's an example: if the version of the PalmOS that your PDA was running was 4.1.2, the value returned from this function would be something like 0x04120000. (The 0's might be something else, but for all intents and purposes, the only ones you care about are the MM, the m and the f.) If you are looking for a feature that is specific to a particular OS, it is more advisable to check for that feature inidividually, rather than check the OS version. However, there certainly are examples where the only way to check for a feature is by checking the OS version. One current example of this has presented itself with the advent of NVFS. I won't go into the details of NVFS in this article, however, suffice it to say that the original implementation of NFVS was lacking. In response to this perceived deficiency, palmOne has released a newer version that is available as a ROM update to Sprint Treo 650s and comes by default in the new Tungsten E2.
According to the documentation, the way to check for the presence of NVFS is to use something like this:
FtrGet(sysFtrCreator, sysFtrNumDmAutoBackup, &returnVal);
If returnVal is 1, then the device uses NVFS. Now, with two different NVFS implementations, we are presented with the problem of knowing which version of NVFS we have. There are many projects (including my own) that have implemented "special" workarounds for NVFS. With the newer implementation, developers may not want to use those workarounds if the updated version of NVFS is present.
Here is where we come to the real meat of the article. As I was digging around looking at the two different Sprint Treo 650s that I have, I noticed that the unpatched device is running PalmOS version 5.4.5 and the patched device is running 5.4.7. I then checked my E2 which comes with the updated NVFS implementation and it also is running 5.4.7. So, armed with this knowledge, I have been able to deduce that the way to check whether a device has the updated NVFS implementation is to check that the OS version is greater than or equal to 5.4.7. Easy enough right? Well, as usual there's a wrinkle. On the Tungsten T5, the Treo 650 and the Tungsten E2, the code that I presented at the beginning of the article doesn't quite work. These devices all return 0x05400000. That seemed very strange because the finder displays the correct version. So, I went digging to see if there are other ways to query for the OS version. This led me to the SysGetROMTokenString function. To be honest, I had never used this function before because it returns a string value instead of a numeric value. However, as it turns out, this function returns the correct information on the new devices.
I could probably write more about this, but the moral of this story is that the only way to check for the updated NVFS implementation is to call SysGetROMTokenString() and parse the returned string to check for OS version 5.4.7 or greater.
As always, I hope this helps you in your journeys, and if you find it helpful, I always like to know.
-Jon
|