Shop OBEX P1 Docs P2 Docs Learn Events
Magnetic Card Reader (reading serial data with stamp, but unable to perform mat — Parallax Forums

Magnetic Card Reader (reading serial data with stamp, but unable to perform mat

donnieB.donnieB. Posts: 2
edited 2005-10-19 16:14 in BASIC Stamp
Hi,

I am working on a project to read magnetic card data with stamp. I am using a <a href="http://www.magtek.com/products/card_reading/magstripe/swipe/mini/specs_rs_232.asp">Mini Port-Powered RS-232</a> and have the data coming into the stamp.

Any I try to use any math operations they give me stranger results. Track two is a byte array of the account number. Any thoughts on what I am doing wrong?


Here is the code:
' {$STAMP BS2p}
' {$PORT COM1}

'PINS
RxD CON 0 'serial receive
TxD CON 1 'serial send
DtR CON 2 'power on for magnetic card reader?

'CONSTANTS
NBaud CON 16624 '9600 for BS2p

'VARIABLES
CardData VAR Byte(15) 'serial data from mag reader

'INIT
HIGH 3 'turn on power to LED
HIGH 2 'turn on power to card reader
HIGH 0 'high for RxD
HIGH 1 'high for TxD

'RUN
MAIN:
PAUSE 2000
DEBUG CLS
HIGH 3 'turn on power to LED
SERIN RxD, NBaud,[noparse][[/noparse]WAIT(";"),CardData(0),CardData(1),CardData(2),CardData(3),CardData(4),CardData(5),CardData(6),CardData(7),CardData(8),CardData(9),CardData(10),CardData(11),CardData(12),CardData(13),CardData(14),CardData(15)] 'input serial data for mag reader
DEBUG CR,CardData(0),CardData(1),CardData(2),CardData(3),CardData(4),CardData(5),CardData(6),CardData(7),CardData(8),CardData(9),CardData(10),CardData(11),CardData(12),CardData(13),CardData(14),CardData(15),CR 'debug sewrial data from mag reader
HIGH 0 'high for RxD
HIGH 1 'high for TxD

'start not working part
sum VAR Word
sum = CardData(0)+ CardData(1)
DEBUG CR, sum,CR
'end not working part

GOTO SENDBYTES 'sub for sending byte by byte
GOTO MAIN 'main loop

SENDBYTES:
i VAR Byte ' counter
i = 0 'init
LOOP: ' loop for sending bytes out
PULSOUT 3,CardData(i)*1000 ' BLINK LED
DEBUG "Array(",DEC i,") = ",CardData(i),CR 'DEBUG Data
SEROUT 15, 16624,[noparse][[/noparse]CardData(i)] ' SEND BYTE
i = i + 1 'increment
IF i = 16 THEN MAIN 'if loop finished return to main
GOTO LOOP ' loop for 'sub' LOOP

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2005-10-19 15:04
    Donnie,

    In your SERIN line, you are grabbing the data, but I think they are staying as ASCII values. In front of each "CardData", put in a DEC2 or DEC3 so that they get converted to numbers that the math will work on.

    Cheers

    Tom
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-19 15:28
    You might want to use the STR modifier in your SERIN and DEBUG statements -- it will be a bunch easier:

    SERIN RxD, NBaud, [noparse][[/noparse]WAIT(";"), STR cardData\15]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • donnieB.donnieB. Posts: 2
    edited 2005-10-19 16:14
    Hey Tom,

    That was it! I used DEC1 in the SERIN and it worked. Thanks for the post.

    All the Best,
    Donnie
Sign In or Register to comment.