What is the easiest way to get track data off a simple USB HID magnetic card reader? - usb

I need to get Track 1 and Track 2 data off magnetic cards and send them over the network to a waiting server. What is an easy way to get the track data from a USB HID magnetic card reader?
In case it helps, I have a MAGTEK Mini Swipe Magnetic Strip Reader (part no. 21040140)
I'm OS agnostic -- a solution for Windows, Mac or Linux would be great. Preferably no .NET, but if that's the easiest way I'll go for it.
What do you all think?
Thanks!

Every card reader I've seen has had a keyboard emulator, so you swipe the card and it sends characters through the keyboard buffer. Looks like this one also does that (documentation : http://www.magtek.com/documentation/public/99875206-16.01.pdf)
Page 14 describes the data sent after a swipe, which is again, fairly standard across card readers:
[Tk1 SS] [Tk1 Data] [ES] [Tk2 SS] [Tk2 Data] [ES] [Tk3 SS] [Tk3 Data] [ES] [CR]
So your track one data starts with % and ends with ?
Track two data starts with ; and ends with ?
I noticed the question was tagged credit-card though, so it would be worth making sure you know the consequences of sending raw card-data across a network (even an internal network). Take a look at the Payment Card Industry Data Security Standards (PCI-DSS) : https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml
There is a demo program for that specific reader that comes with VB source.
http://www.magtek.com/support/software/demo_programs/usb_swipe_insert.asp

Easiest way to download the Cab file from this link & include it in the project directory in a "magtek" folder.
http://www.magtek.com/support/software/demo_programs/card/usb_hid_swipe_readers/read_parse.asp
Add this code in aspx file after tag (change cab file src as per )
<object id="USBHID" classid="CLSID:22571E97-956A-4CDD-AF8D-AE9C26597683" codebase="magtek/99510060.CAB#version=1,13,0,2">
</object>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#txtNameFirst').focus(); // Focus on a textbox is required
USBHID.PortOpen = true;
if (USBHID.PortOpen == false) {
$('#<%= lblStatus.ClientID %>').text('Could not open MagTek reader');
}
else {
$('#<%= lblStatus.ClientID %>').text('Please Swipe a card');
}
});
$("#txtNameFirst").bind('change', function () {
var CCData = $("#txtNameFirst").val(); // CCData will contain the complete credit card data in a string.
alert(CCData);
$("#txtNameFirst").val(CCData.split('^')[1].split(' ')[0]);
$("#txtNameLast").val(CCData.split('^')[1].split(' ')[1]);
$("#txtCCNo").val(CCData.split('^')[0].substring(2, 18));
//alert(' Split1: ' + CCData.split('^')[1] + ' Split2: ' + CCData.split('^')[2]);
//alert('parsing good!');
$("#txtExpiDt_RoutingNo").val(CCData.split('^')[2].substring(2, 4) + '/' + CCData.split('^')[2].substring(0, 2));
});
</script>
As per the above code I have added focus on a text box . After swiping the card focused textboxes automatically show the complete credit card data string.

Related

First time NFC write/read issue

I am trying to add the NFC feature in my react-native app by using react-native-NFC-Manager and it is working fine. But the issue is at the first time I am unable to read/write the NFC card. For the first time, I need to write a new tag by using the NFC Tool app to convert 'NdefFormatable' to 'Ndef' otherwise I am not able to read/write the NFC card
I have used this code to write data:
await NfcManager.requestTechnology(NfcTech.Ndef, {
alertMessage: 'Ready to write some NDEF',
});
const bytes = Ndef.encodeMessage([Ndef.textRecord('Hello NFC')]);
if (bytes) {
await NfcManager.ndefHandler // Step2
.writeNdefMessage(bytes); // Step3
if (Platform.OS === 'ios') {
await NfcManager.setAlertMessageIOS('Successfully write NDEF');
}
}
Is there any solution to this issue?
A Two part answer.
For Android if you code did not just ask for detection already formatted tags with the NfcManager.requestTechnology(NfcTech.Ndef, and instead used the more basic NfcManager.setEventListener(NfcEvents.DiscoverTag, (tag) => { method of detecting Tags then you can write an unformatted Tag (as writing formats it)
For iOS is a lot more complicated as it does not allow writing to unformatted Tags https://github.com/revtel/react-native-nfc-manager/blob/main/FAQ.md#ios-cannot-write-ndef-into-nfc-tags
As a background in simple terms an unformatted Ndef formatted Tag has a capability container record but no TLV entry, formatting adds a blank TLV entry, where as writing add a TLV entry with a non blank TLV entry.

Limiting simultaneous downloads using RxAlamofire

Given my App will download files from a server and I only want 1 download to be progressed at the same time, then how could this be done with RxAlamofire? I might simply be missing an Rx operator.
Here's the rough code:
Observable
.from(paths)
.flatMapWithIndex({ (ip, idx) -> Observable<(Int, Video)> in
let v = self.files![ip.row] as! Video
return Observable.from([(idx, v)])
})
.flatMap { (item) -> Observable<Video> in
let req = URLRequest(url: item.1.downloadURL())
return Api.alamofireManager()
.rx
.download(req, to: { (url, response) -> (destinationURL: URL, options: DownloadRequest.DownloadOptions) in
...
})
.flatMap({ $0.rx.progress() })
.flatMap { (progress) -> Observable<Float> in
// Update a progress bar
...
}
// Only propagate finished items
.filter { $0 >= 1.0 }
// Return the item itself
.flatMap { _ in Observable.from([item.1]) }
}
.subscribe(
onNext: { (res) in
...
},
onError: { (error) in
...
},
onCompleted: {
...
}
)
My problem is a) RxAlamofire will download multiple items at the same time and b) the (progress) block is called multiple times for those various items (with different progress infos on each, causing the UI to behave a bit weird).
How to ensure the downloads are done one by one instead of simultaneously?
Does alamofireManager().rx.download() download concurrently or serially?
I'm not sure how it does, so test that first. Isolate this code and see if it does execute multiple downloads at once. If it does, then read up on the documentation for serial downloads instead of concurrent downloads.
If it downloads one at a time, then it means it has something to do with your Rx code that triggers the progress bar update issue. If it doesn't download one at a time, then it means we just need to read up on Alamofire's documentation on how to download one at a time.
Complex transformations and side effects
Something to consider is that your data streams are becoming more complex and difficult to debug because so many things are happening in one stream. Because of the multiple flat maps, there can be a lot more emissions coming out affecting the progress bar update. It is also possible that the numerous flat maps operations that acquired an Observable are the cause for the multiple triggering of the updates on the progress bar.
Complex data streams
In one data stream you (a) performed the network call (b) updated the progress bar (c) filtered finished videos (d) and went back to the video you wanted by using flatMapWithIndex at the start to pair together id and the video model so that you can return back to the model at the end. Kind of complicated... My guess is that the weird progress bar updates might be caused by creating a hot observable on call of $0.rx.progress().
I made a github gist of my Rx Playground that tries to model what you're trying to do.
In functional reactive programming, it would be much more readable and easier to debug if you first define your data streams/observables. In my gist, I began with the observables and how I planned to model the download progress.
This code will avoid the concurrency issues if the RxAlamofire query downloads 1 at a time, and it properly presents the progress value for a UIProgressBar.
Side note
Do you need to track the individual progress downloads per download item? Or do you want your progress bar to just increment per finished download item?
Also, be wary with the possible dangers of misusing a chain of multiple flatMaps as explained here.

Detecting Front and Back camera in windows 8 tabs

I am developing a metro style app using c# and xaml. For a particular task i need to detect which cam(front or back) is currently capturing. Is there any way to detect front cam or back cam in winrt. Please help me.
Using indexes on the DeviceInformationCollection won't be a reliable solution:
Sometimes front camera will be index 0 and sometimes 1, after testing on the surface 2 a few times it seems to be kind of random.
User could use the USB port to connect an other webcam so you could end up with more than 2 items in your collection without any clue which camera is which index.
Having the same problem as you this is how I solved it:
// Still need to find all webcams
DeviceInformationCollection webcamList = await eviceInformation.FindAllAsync(DeviceClass.VideoCapture)
// Then I do a query to find the front webcam
DeviceInformation frontWebcam = (from webcam in webcamList
where webcam.EnclosureLocation != null
&& webcam.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front
select webcam).FirstOrDefault();
// Same for the back webcam
DeviceInformation backWebcam = (from webcam in webcamList
where webcam.EnclosureLocation != null
&& webcam.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back
select webcam).FirstOrDefault();
In this exemple I used Linq queries but it works the same with a foreach on "webcamList".
Just look on each DeviceInformation the .EnclosureLocation.Panel property, which is a Windows.Devices.Enumeration.Panel enum. The rest is obvius, Front for the front camera, Back for the back one.
Be also carefull to check if .EnclosureLocation is null or not, using an USB webcam it seems to be null most of the time.
You can use this code.
DeviceInformationCollection videoCaptureDevices = await eviceInformation.FindAllAsync(DeviceClass.VideoCapture);
If the videoCaptureDevices count is zero ,there is no camera attached.
And if camera count is 2 , then there will be both Front & back cameras.
If you initializing camera operation with videoCaptureDevices [0], that will be using Front Camera, and will be Back Camera if it is using videoCaptureDevices [1] .

Possible dijit.Tree Cookie issue (SaveStateCookie)

So our app is set up like the standard left frame with the tree, right frame has the main content (loaded from clicking the tree).
Our web app inconsistently displays a blank page in the main frame in Firefox. By inconsistent I mean everyday for a few, rarely for others, never for most. Once we get this, going to any other page through our tree results in a blank page. We found that deleting the "aTreeSaveStateCookie" restores normal operation. "aTree" is the name of our Div. I found "SaveStateCookie" strings in dijit/Tree.js.
This also happens in IE, except I would get a browser error page which I can't recall right now. I would then delete the only cookie I could find for our app (not sure how to do the Firefox steps in IE)
Any ideas on why this would happen?
Thanks
Dojo 1.3 through http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js
Firefox 3.1x
IE 8
Windows XP
In my case, I don't recall ever changing browser settings around Private Data.
Please check to see if the response code is 413 (413 = request entity too large), usually this happens when the cookie(s) used to store the tree(s) expansion state (aTreeSaveStateCookie) exceed(s) the maximum request size for your server
You could try increasing the maximum request size (follow instructions for your specific web app server) or at least display a meaningful error message like "please clear your browser cache" when the 413 error code is encountered
If the persist property is set to a truthy value, dijit.Tree is persisting its state to remember which nodes were expanded, and expand them after a page reload. If you need to persist the tree state in presence of a very large data structure, I recommend overriding Tree to use localStorage instead of dojo.cookie.
This is Dojo v. 1.9, but similar changes can be done to the non-AMD version 1.3
_saveExpandedNodes: function(){
if(this.persist && this.cookieName){
var ary = [];
for(var id in this._openedNodes){
ary.push(id);
}
// Was:
// cookie(this.cookieName, ary.join(","), {expires: 365});
localStorage.setItem(this.cookieName, ary.join(","));
}
},
And:
_initState: function(){
// summary:
// Load in which nodes should be opened automatically
this._openedNodes = {};
if(this.persist && this.cookieName){
// Was:
// var oreo = cookie(this.cookieName);
var oreo = localStorage.getItem(this.cookieName);
if(oreo){
array.forEach(oreo.split(','), function(item){
this._openedNodes[item] = true;
}, this);
}
}
},

Multiple Flv Component playback - through a for loop - rewind issues AS3 Flash CS4

I am building a "video wall" app in flash AS3. I am importing a movie clip with a flvPlayback component nested within, then Adding it to the display list 12 times in a for loop (which is based on the length of an xml file.) The xml file aslo points to the .source of the flv instance.
This method is working, for displaying video content on all screens BUT, it only loops the last flvPlayback component. The rest just go back to the first frame of the video.
var vidURL = vidXML.video_item[i].#url
SS.video.source = vidURL;
SS.video.autoRewind = true;
SS.video.autoPlay = true;
SS.video.addEventListener(VideoEvent.COMPLETE, Loop);
function Loop(event:VideoEvent):void
{
SS.video.play();
}
I have tried refering to the SS + [i] to call the event to rewind as soon as it happens (as the videos are different lengths) but have had no luck.
Any help would be appreciated.
Thanks
Jono
Don't worry chaps...
using the "event.target.play()" is triggered when each video finishes, and rewinds them all nicely.
Sorry.
Jono