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.
Interrupt-driven serial communications (continued)

Instead, we can us some other undocumented APIs to get a pointer directly to the receive buffer.

First we call SerReceiveCheck to get a total count of the received chars. Then, instead of calling SerReceive (or SerReceive10), we call SerReceiveWindowOpen. This gets us a pointer to a contiguous block of characters, and the length of that block. This is a pointer directly into the receive ISR's buffer. Because it's a circular buffer, the received characters might wrap around -- some at the end of the physical buffer, then next at the beginning again. In this case, we'll get a pointer to the group at the end of the buffer (the next chars to read in). We'll need to call SerReceiveWindowOpen a second time to get the wrapped part of the buffer.

We call SerReceiveWindowOpen to get the pointer to and length of data. We do as we wish with the data, then call SerReceiveWindowClose, telling it how many characters we actually used. Then, if we didn't get all the characters indicated in the call to SerReceiveCheck, we'll call SerReceiveWindowOpen and SerReceiveWindowClose a second time.

Finally, we want to tell the serial ISR to call our callback again, so we call SerPrimeWakeupHandler.

Note that there might be more characters than we ask for (the "prime count") when we process our special keyDownEvent -- this example just processes all that are there.

Conclusion
This article shows you how to use a callback for serial receive. As I mentioned, there's a bit of risk because it's undocumented, but it's been used by other applications and discussed occasionally on the developer mailing list and newsgroups.

Because they use APIs that aren't in the original Pilot 1000 and 5000, applicationss which use these techniques should check the Palm OS version number. The standard samples do this. In the interest of simplicity, and because of laziness, fighting the flu and impending deadlines, I didn't put the version checking into this sample application. It didn't crash on my Pilot 1000, but it didn't work either -- certainly it can't be expected to always fail gracefully.

Product availability and resources
Source code to SerialEchoINT is at my web site at http://www.ajw.com/PalmPower/ProgrammingPower/Mar99/SerialEchoINT.zip

Alan Jay Weiner writes software for PalmPilots. His email address is alan@ajw.com.


« Previous  ·  1  ·  2  ·  3  ·  4
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 --

Sent Items Organizer
When you need to file your sent email into their proper folders based on keywords or who it's to. It's also perfect for shared mailboxes.

It also adds a "Send And File" toolbar button while you're composing (similar to the way Lotus Notes used to work) for quick and easy filing.

Find out more!

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