Palm Pilot Development Tools
The PalmOS keeps a queue of events being handled by the system. These events are sent to the current application in order to execute the code to handle each event. An event is triggered when a UI button is pressed, the Palm pen touches the screen (penDownEvent) or when other operations occur. An application should transfer any events it doesn't handle to the system. When the event is handled, the PalmOS takes the next event in the queue and passes it on to the application. The application can also put events in the queue. Many PalmPilot functions cause all sorts of events to be placed in the event queue. A list of all events and what they do is in the official documentation for the Palm Pilot.
The main procedure of a program is called PilotMain. When the PalmOS calls PilotMain, it transfers a command to it. The PilotMain procedure should find out what the command says. The command can say, for example, that this is a normal launch of the application (sysAppLaunchCmdNormalLaunch) or that this is a command to find a string (sysAppLaunchCmdfind). PilotMain should ignore or respond to these commands in its code. An example of an application that responds to the sysAppLaunchCmdfind is the address book. Whenever we press the find button, the PalmOS sends this command to all the applications. One application that will accept this command is the address book—it starts searching for the string we entered in its database.
To handle all events, we should use an event loop. An event loop simply takes an event, handles it, then takes the next event in the queue. If we do not want to handle a certain event, we can send it to the PalmOS event handlers so it will be handled for us.
To take advantage of all the functionality of the PalmOS, there is well-documented API for your use. You should read the API manual to see which kinds of events, functions and types of objects exist in the PalmOS. Listing 2 is simple code that writes “Hello World” on the Palm Pilot.
The first step toward running an application on the Palm is to build the resources. As mentioned earlier, we can build the resources using the command pilrc.
To add the bitmap with ID 10 to the main form, I used a tool that converts ppm files to Tbmpxxx.bin resources. I used xv to convert the format of peng.gif (found at http://www.linux.org.il/) to black-and-white ppm format. Then I used ppmtoTbmp on the peng.ppm file, and named the result Tbmp000a.bin. The 000a in the file name is the 32-bit hexadecimal value for 10. I needed to specify this value because this is the bitmap ID I wrote in the pilrc resource file for the main form. This tool was written by Ian Goldberg, and it can be found at http://www.pilotgear.com/.
The next step is to compile the C code. To do this, we use the gcc m68-palmos-coff cross compiler, with the same flags as for the normal Linux gcc:
m68k-palmos-gcc -O2 -o hello hello.c
The result of this command is an m68k COFF object file named hello. The m68k COFF object file should be combined with the resources just created using the pilrc program. To complete this mission, we first use the obj-res utility that splits the COFF file into the code and data resources, and then use the build-prc utility to combine resources.
m68k-palmos-obj-res helloThis command will split the hello file into three resource files: code0000.hello.grc, code0001.hello.grc and data0000.hello.grc. Now we are ready for the final step of building the prc database.
build-prc hello.prc "hello" hwld *.grc *.binThis command builds a prc application with a creatorID hwld and type appl.
Testing the application on your Palm Pilot is not such a good idea. A bug might require us to reset the machine, and programs can't be debugged with the normal tools. The best way to test our just-created “Hello World” application is with a program that will emulate the Palm Pilot from within our desktop. POSE, available from http://www.palm.com/ with source code included, is a very good emulator. It can use a special debug ROM, also available from that site. With the debug ROM, we can get more debugging information on our application, which makes finding errors much easier, and we can hook gdb to it in order to debug with this well-known debugging tool. To install POSE, you will need the FLTK X toolkit. All instructions come with the POSE tar file.
There is one more emulator for X, called xcopilot. In order to use your own machine RAM or ROM, you can use the pilot-link package. The pilot-link package gives you the ability to communicate with the Palm Pilot from the serial port. There are some good utilities in this package, available from ftp://ryeham.ee.ryerson.ca/pub/PalmOS/. Using the pilot-link utilities, we can also transfer databases from our desktop to the Palm Pilot and from the Palm Pilot to the desktop.
Figure 1 is how POSE looks with our hello world application for the Palm.
Eddie Harari (firstname.lastname@example.org) works for Sela Systems & Education in Israel as a senior manager and is involved in some security projects. He has been hacking computers for 13 years.
All listings referred to in this article are available by anonymous download in the file ftp.linuxjournal.com/pub/lj/listings/issue73/3782.tgz.
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Dynamic DNS—an Object Lesson in Problem Solving
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Tech Tip: Really Simple HTTP Server with Python
- Roll your own dynamic dns
1 hour 33 min ago
- Please correct the URL for Salt Stack's web site
4 hours 45 min ago
- Android is Linux -- why no better inter-operation
7 hours 27 sec ago
- Connecting Android device to desktop Linux via USB
7 hours 28 min ago
- Find new cell phone and tablet pc
8 hours 27 min ago
9 hours 55 min ago
- Automatically updating Guest Additions
11 hours 4 min ago
- I like your topic on android
11 hours 50 min ago
- This is the easiest tutorial
18 hours 26 min ago
- Ahh, the Koolaid.
1 day 5 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?