Email:   
Home
In This Issue
EasyPrint
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.




[ Prev ]

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
-- Advertisement --

ONLINE GROUP CALENDAR - FOR UP TO 100 OF YOUR CLOSEST FRIENDS
Stay organized and in control with 24/7 access to all of your important events, projects and files --whether you're at work, at home or on the road.

You can share your calendar, projects and files so everyone in your office is up to date. Plus, search your entire group to find times when everyone is available to meet, manage company resources and much more.

Organize your entire team for as low as $9.95 per year (and yes, that's where the decimal place is supposed to be!)

Tap here to get started right away.

-- Advertisement --

SECURE YOUR SITE WITH AN IRONCLAD SSL CERTIFICATE
An IronClad SSL Certificate helps you build an impenetrable fortress around your customer's credit card information. IronClad SSL Certificates are:

  • Fully validated
  • Up to 256-bit encryption
  • Up to 10 years validity
  • Stringent authentication
  • Around-the-clock customer support

Build trust. Protect your customers. Grow your online business.

Tap here now and be IronClad with SSL tonight.

Copyright © 1998-2008, ZATZ Publishing. All rights reserved worldwide.
Editor's Login