I am using the Symbol MSR (Magnetic Stripe Reader). This library runs in
two modes: buffered mode or unbuffered mode.
Buffered mode requires the app to issue an "arm to read" command to the MSR.
The app then sits waiting for the card to be swiped by the user. You cannot
do anything else while waiting for the card swipe. No menus, nothing.
Under some UI circumstances this may be a good method to read the card. But
if you want the user to go about his business in the app (using menus, tap
other buttons, perform other functions, etc) then you need to use unbuffered
mode. In unbuffered mode the app can go about it's business and the MSR
will issue a virtual keyDownEvent to signal that the user has swiped his
credit card. The code in your form used to handle the card read is basically
this:
if ( eventP->eType == keyDownEvent )
{
if ( eventP->data.keyDown.chr == msrDataReadyKey )
... Read the card data and do something ...
}
Once the card has been swiped once, the MSR will not generate another event
until the card data has been read by your app, clearing the buffer. This is
an important point, because if you are not able to trap this event and don't
read the card data from the buffer then the MSR stops working.
In the MSR Demo app that comes with the Symbol SDK they make use of the
unbuffered mode. It is considered a special condition if the app is doing
something else and does not want to process the card swipe. What they have
done in this sample app to handle this condition is to place code in the
AppEventHandler() function that basically does the following:
If the main form is NOT the current form
If it is the msrDataReadyKey keyDownEvent
Read the card data and discard
What this does is catch the msrDataReadyKey event for all forms except the
main form that will handle the card read event. In this case it will grab
the card data and ignore it. This clears out the card buffer and gets the
MSR ready for the next swipe.
Here is where my problem comes in. When an alert box is on the screen (or a
keyboard or some other condition) the msrDataReadyKey event is never caught
by my app. Therefore the MSR goes dead and the app is rendered useless
because I did not grab the data out of the MSR. The original designers of
this app must have had this problem because what they did was place a "read
the card data" function call in the main form update event. This basically
clears our the data and resets the MSR to wait for another card swipe and
issue an event every time the form is updated. There is no function call to
test if a card has been swiped but not read yet so it does the clear on
every form update whether it needs to or not.
You would think this this would work, but it has problems. If the user
doesn't realize that they are not supposed to be swiping their card when the
dialog box is up, they will swipe their card anyway. And they will swipe
several times before they realize they're not supposed to be swiping. There
is a bug somewhere (in the MSR library code or the Palm OS serial port
manager) because when the apps comes back around to the main form update
event and it reads the card buffer I get a fatal error. I have made some
minor modifications to the Symbol MSR Sample app to demonstrate this
problem, so I know it's nothing I am doing in my app.
When the app is in another form (not an alert box) the code in the
AppEventHandler grabs the event, realizes that we're not in the main form,
and fetches the MSR data. This works just fine and I can swipe the card as
much as I want and I never get a fatal error. I believe there is some sort
of buffer overrun problem in the MSR library code that occurs when you swipe
the card more than once before the app clears out the buffer.
So the MSR library requires me to catch this event, but there are times when
I cannot catch the event and there is a bug somewhere that causes a fatal
error if I don't catch this event. I am working with Symbol on this problem
and all I really want is a solution because my app has fatal errors.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/