1. how to read from a magnetic card reader
- Posted by oscarezio Jan 13, 2011
- 1343 views
Hi everybody I have the next issue: I have a magnetic card reader connected to a windows xp computer via usb
I have to read 2 tracks each time I swipe a card the problem I face is that
some cards comes with 2 tracks while other comes with 3 tracks
I have tried to read it char by char with the next code
-- wait until there is something to read while get_key()=-1 do end while -- start reading while 1=1 do vca=get_key() if vca=-1 then exit else linea=linea&vca end if end while
but as soon as it read the first character it stops
maybe it is a simple question but i have not solved it yet
any idea
thanks in advance
2. Re: how to read from a magnetic card reader
- Posted by cargoan Jan 14, 2011
- 1250 views
Use:
integer vca = -1 sequence linea = {} -- wait until there is something to read while vca = -1 do vca = get_key() end while linea &= vca -- start reading while 1 do vca = get_key() if vca = '\n' then exit elsif vca != -1 then linea = linea & vca end if end while
Or:
include std/console.e -- start reading linea = {} while 1 do vca = wait_key() if vca = '\n' then exit else linea = linea & vca end if end while
3. Re: how to read from a magnetic card reader
- Posted by oscarezio Jan 14, 2011
- 1260 views
Thanks for your answer I try it, and I don't know why, but it didn't worked either
4. Re: how to read from a magnetic card reader
- Posted by cargoan Jan 15, 2011
- 1253 views
It does not work because get_key() returns -1 when the keyboard buffer is empty, does not wait for the next key.
5. Re: how to read from a magnetic card reader
- Posted by unkmar Jan 16, 2011
- 1130 views
Generally a magnetic card reader is no more than a keyboard stuffer. They will return 1 or more lines of data, each line generally ends with a linefeed or '\n'. So, what you need is a program that reads a number of lines of data and can determine how many which lines belong where because, you state some cases you get 2 lines and others you get 3.