Getting Your Palm to Talk to a Linux Box
A Palm is such a neat portable device. You take notes on it, plan meetings or even write down anniversaries. It's a nice tool to have while on the road. Our intranet server, on the other hand, is also a great resource. We have our company's planning and agenda on it, and it has all those interesting notes, addresses and, in our case, a complete knowledge database. This server runs (of course) Linux, an Apache web server and MySQL database on top of it, glued together with a proprietary application engine.
Wouldn't it be great if the two environments could be synchronized? Of course! Now if we could only access the internal databases from the Palm on our Linux server, that would get us pointed toward the right direction. Documentation is sparse and the Internet is big. But then along came Kevin and Jeffrey, two students who, with some effort, put together a solution that allowed us to make changes on the Palm or on the corporate intranet server and have these modifications propagated to one another's counterpart databases.
All code below was tested on an Intel machine running a Red Hat 6.x release and a Palm Vx with serial cradle running Palm OS 3.5, but other combinations shouldn't cause any problems. The libraries used are unchanged since the first Palm appeared on the market, when they were still being produced by 3Com. I suppose (but haven't tested it) that Visor's won't cause any problem either, as they are running the same OS.
Let's start with the simple part: connecting the Palm to the server. First, we need to connect the cradle of the Palm with the serial port of the server. Then we create a device called pilot. This pilot is nothing more than a link to a serial port (in our case /dev/ttyS0):
ln /dev/ttyS0 /dev/pilot
Now, we're ready to open the connection to the Palm using a C program and a simple push on the HotSync button of the cradle. Once the connection is made, we can relax and read records from the Palm's databases.
Communicating and opening the connection to the Palm is easy with the pi library. This library simulates the BSD socket interface: create a socket, bind it to our device, listen for an incoming connection and accept it. The incoming connection is initiated by the Palm/cradle combination when a user hits the sync button on the cradle. Making a dæmon that waits for someone to come by and synchronize its Palm is illustrated in Listing 1. Loop this program forever.
Listing 1. Synchronizing the Palm
Once the connection is open, how do we interact with the Palm databases? Each database on the Palm has a name. We can open a database by name and get a specific record or cycle through the database. On a Macintosh or Windows platform these functions are performed by conduits. Palm itself provides a conduit on these platforms for every standard database included with the Palm OS bundle. The Palm database manager provides ways for us to cycle only through the modified records in a database. Modified since when? Well, since the last synchronization, the last time a server committed this database. So, we should do this in our programs when finished with the synchronization process. The lines in Listing 2 should be executed when the connection is open.
Listing 2. Cycling through Modified Records
Reading records from a Palm database doesn't qualify as synchronizing. We'll need to do more, such as write to the Palm, delete from it and read from our MySQL database. Since connecting to a MySQL database is outside the scope of this article, we won't discuss the further details of the synchronization problem (and the possible conflicts). However, Kevin Velghe has written an excellent document about it. You can read it at www.duo.be/palm/mysql_palm.html.
Records stored in a Palm database have unique numbers. Whenever you write a record to the device, it returns this number. You should store it on your desktop or central database, so that you can delete or update a specific record.
The dlp_WriteRecord accepts a Palm ID. If it is zero, the Palm OS will allocate a new one for you; if you pass an existing ID, the corresponding record will be updated. For most standard databases a pack function packs the structured record into a buffer. This process is shown in Listing 3.
If, as in our case, you're serving multiple Palms on one server/cradle, you'll need to find out whose Palm is in the cradle. Once the connection is open, call the ReadUserInfo function:
{
int db, len, I, attr;
recordid_t id;
struct PilotUser U;
...open the connection...
sd = pi_accept(sd, 0, 0);
dlp_ReadUserInfo(sd,&U);
printf("Palm of: %s", U.username);
pi_close(sd);
}
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| 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 |
| Trying to Tame the Tablet | May 08, 2013 |
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- 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?
- Home, My Backup Data Center
- New Products
- New Products
- RSS Feeds
- This is the easiest tutorial
5 hours 53 min ago - Ahh, the Koolaid.
11 hours 32 min ago - git-annex assistant
17 hours 32 min ago - direct cable connection
17 hours 54 min ago - Agreed on AirDroid. With my
18 hours 4 min ago - I just learned this
18 hours 8 min ago - enterprise
18 hours 39 min ago - not living upto the mobile revolution
21 hours 30 min ago - Deceptive Advertising and
22 hours 5 min ago - Let\'s declare that you have
22 hours 6 min ago
Enter to Win an Adafruit Prototyping Pi Plate 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 Prototyping Pi Plate 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
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




Comments
root
i haven't had a chance to test this software .i'm just starting into linux with a copy of ubuntu but it would be smart to include the info that a few versions of linux don't let you log in as root. for those they will need to use "sudo" to get root access.
randy
lilwoffie