Search PalmPower's 487 Palm-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
An introduction to serial communications (continued)

The speed of the connection is measured in bits-per-second, although it's usually erroneously expressed as "baud rate." Baud refers to the frequency over telecommunications lines and since it's already measured in hertz, saying "rate" is redundant. Nevertheless, if you say something like "9600 baud" or ask "what baud rate" everyone understands what you mean.

So to send serial data, you need to set the UART to the configuration you'd like (number of bits per character, parity or not, baud rate, and any other specifics to that hardware), then pump data to it to be sent and read received data from it.

Palm OS Serial APIs
Palm OS has no implicit APIs (Application Programming Interfaces) to control the serial port; instead, they're implemented as library routines. This means you must ask the OS to load the library, which gets you a reference number, and then use that reference number in calls to the APIs within the library.

Once the serial communications library is loaded, you use the following APIs:

  • SerClearErr
  • SerClose
  • SerGetSettings
  • SerGetStatus
  • SerOpen
  • SerReceive
  • SerReceiveCheck
  • SerReceiveFlush
  • SerReceiveWait
  • SerSend
  • SerSendWait
  • SerSetReceiveBuffer
  • SerSetSettings

When Palm OS 2 came out, several additional APIs appeared:

  • SerReceive was renamed to SerReceive10 and a new SerReceive appeared.
  • SerSend was renamed to SerSend10 and a new SerSend appeared.
  • SerSendCheck, SerSendFlush, and SerControl were added.

Beyond these calls, there are a number of undocumented APIs. I'll get into those another time.

SerialEcho receives and sends characters
The listing (see http://www.component-net.com/pp-extras/serial.html) shows a simple program which receives characters from the serial port and then echos them back. As usual, SerialEcho is based on the Hello World application, so most of it will look familiar.

Near the beginning are five routines that talk to the serial port. These routines use the Palm OS 1 APIs, so no version checking is included.

Two header files are required: Pilot.h and SerialMgr.h. The library API (SysLibFind) is in Pilot.h, and the serial API prototypes are in the SerialMgr.h header file.

The first routine, serialOpenPort, loads the serial library and opens the port, setting a specific baud rate and default control settings. The serial library is included in the Palm device's ROM, so it's always available; you don't need to specially install it on the Palm device. This routine saves the reference number in a global variable for use by the other routines.

The corresponding serialClosePort waits until all the characters have been sent, and then closes the serial port.

To send characters, call serialPrintf with a string. This isn't a real printf function - it only accepts a single string without any printf-like formatting characters. The string is transmitted over the opened serial port. But calling it serialPrintf helps make it easier to remember and understand.


« Previous  ·  1  ·  2  ·  3  ·  4  ·  Next »
Other articles you might like
Home > Phones and PDAs > Palm and Treo > Programming (24 articles)
   How PDA software is born
   Program with Simplicity
   Kinectivity 2.0 brings enterprise application developers new tools
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Other PalmPower Articles
Palm gets up to date with new Tungsten family of handhelds
Create handwritten email with riteMail
Presenter-to-Go puts PowerPoint presentations on your Palm OS handheld
Looking for the cutting edge
Gain remote access to databases and PLCs
PalmSource Open House showcases what's new in the Palm community
Analysis: handheld market share
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
DominoPower: Application development, William Shatner, and the origin of the universe
OutlookPower: More about disappearing text
-- Advertisement --

NO HASSLE PHOTO PRINTING, SHARING, AND STORAGE -- AS LOW AS $2.54 PER MONTH
Discover an easier way to share, print and manage your photos online! Get your own online photo album site for sharing photos, as well as easy-to-use editing tools to make sure your photos look their very best. You can even order high quality prints directly from your album -- and have them delivered right to your door!

Best of all, you can also get login-free photo sharing at your personal domain name (if you have one), so your friends and family don't have to hassle with signing up or logging in just to view your pictures. It's the perfect solution for sharing, printing and storing all your favorite images!

And it's only from The Duck! Tap here to get started.

-- Advertisement --

Write for Computing Unplugged!
Share your experience and expertise with other handheld device users. There are new opportunities at ZATZ for contributing authors and editors.

Write about something you're an expert on and get your name in lights.

For Writers' Guidelines and to discuss topics, contact Staff Editor Steve Niles. This is your opportunity to shine in front of your peers, your clients, and friends.

Click for more info!

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login