carlosefr / magstripelib Goto Github PK
View Code? Open in Web Editor NEWMagnetic (swipe-type) card reader library for the Arduino.
License: MIT License
Magnetic (swipe-type) card reader library for the Arduino.
License: MIT License
Hello,
I am interested in getting this to work. What technical limitations exist that stop the library from being able to read all 3 tracks at once? Can only specific pins be used?
If we cannot get simultaneous reading to work, can we change the pins used in our program on the fly? So if 3 tracks are needed, the program can swap the pins to the 2nd and then 3rd track. It would require 3 swipes, but would still make reading all 3 tracks possible without changing any wiring.
like the leds are changing with the insertion of a card and stuff but im getting 0 output in the serial monitor .. im using an osepp nano
Am using NodeMCU 1.0 ESP8266
At startup it bring this error.
ctx: cont
sp: 3ffffee0 end: 3fffffc0 offset: 0000
3ffffee0: 00000688 feefeffe feefeffe feefeffe
3ffffef0: 000000fe 00000000 00000000 00000000
3fffff00: 00000000 00000000 00000000 00ff0000
3fffff10: 5ffffe00 5ffffe00 feefeffe 00000000
3fffff20: 00000003 00000000 3ffee354 402021ba
3fffff30: 40100462 00002580 00000000 402021d0
3fffff40: 00000003 40203199 3ffee354 402026e1
3fffff50: 00000000 00000001 3ffee3e0 3ffee448
3fffff60: 00000000 00000001 3ffee3e0 3ffee448
3fffff70: 3fffdad0 00000000 3ffee354 40202790
3fffff80: 00002580 0000001c 00000000 40201228
3fffff90: 3fffdad0 00000000 3ffee408 40201050
3fffffa0: feefeffe feefeffe feefeffe 40201e10
3fffffb0: feefeffe feefeffe 3ffe84e4 40100d6d
<<<stack<<<
H!⸮ԅ⸮⸮⸮⸮⸮ISR not in IRAM!
User exception (panic/abort/assert)
Abort called
I am using the MagStrip library (https://github.com/carlosefr/magstripelib 1). In my main loop I call the function which runs the code:
void magcardFunc()
{
static const byte DATA_BUFFER_LEN = 108;
static char magcard[DATA_BUFFER_LEN];
// Don't do anything if there isn't a card present
if (!card.available()) {
return;
}
// Read the card into the buffer "magcard" (as a null-terminated string)
short chars = card.read(magcard, DATA_BUFFER_LEN);
if (chars < 0) {
Serial.print("bad read");
return;
}
// Send the data to the computer if data was read
if (chars != 0) {
Serial.print(magcardstr);
}
}
The code successfully reads a magnetic card when inserted.
The problem is, I have other functions which are called from the main loop but they do not get called as the code pauses at:
if (!card.available()) {
return;
}
// Read the card into the buffer "magcard" (as a null-terminated string)
short chars = card.read(magcard, DATA_BUFFER_LEN);
If I insert a card into my mag reader (and leave it there), the program continues and the other functions are called. I want the main loop to continue and the other functions be called without having to leave a card inserted.
I have tried removing the IF statement:
if (!card.available()) {
return;
}
and I have tried reversing it
if (card.available()) {
return;
}
If I reverse it as above, the other functions run but when I do swipe a card, it is not read.
I get no compiler errors.
An example sketch:
#include <MagStripe.h>
void magcardFunc();
void otherFunc();
MagStripe card;
static const byte DATA_BUFFER_LEN = 108;
static char data[DATA_BUFFER_LEN];
void setup()
{
// The card data will be sent over serial...
Serial.begin(9600);
// Initialize the library for reading track 2...
card.begin(2);
}
void loop()
{
magcardFunc();
otherFunc();
}
void magcardFunc()
{
// Don't do anything if there isn't a card present...
if (!card.available()) {
return;
}
// Read the card into the buffer "data" (as a null-terminated string)...
short chars = card.read(data, DATA_BUFFER_LEN);
if (chars < 0) {
Serial.println("no chars");
return;
}
// Send the data to the computer...
Serial.println(data);
}
void otherFunc()
{
Serial.println("I am another function");
delay(500); //feel free to remove me
}
Any help is appreciated.
@carlosefr, thanks for this library. I did run into an issue with the card readers that I have but was able to fix it using a capacitor to filter the data line. I wrote up a blog post about it. I plan to make some changes to the library as I have an idea to make it more reliable for this type of issue.
The blog post is at https://teelsys.com/?p=708.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.