locked
POS .net examples for Card Reader? RRS feed

  • Question

  • I'm new to POS .net and was curious if there are any code samples out there that pertain to USB card readers?

    Monday, May 3, 2010 1:21 PM

Answers

  • The short answer is the same code will work for both. The UPOS specification defines an abstration layer between the application and the hardware. This is in the form of an OPOS driver or Service Object. The changes to the code would be the OPOS / SO setup.

    -Sean

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
    Monday, May 3, 2010 9:12 PM
    Answerer
  •  

    Do you mean Magnetic strip reader? Or CF / SD cards?

    The answer to the first is yes. (Some examples here: http://www.seanliming.com/WEPOS.html). The answer to the second is CF and SD cards are not POS devices.

    -Sean

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
    Monday, May 3, 2010 5:43 PM
    Answerer
  • Have you tried the test application with the POS for .NET SDK?

    How did you set the logical name for the MSR OPOS driver?

    -Sean

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step


    Ok, I finally got it to scan a card.

    The problem I encoutnered is that the "void myExplorer_DeviceRemovedEvent(object sender, DeviceChangedEventArgs e) & void myExplorer_DeviceAddedEvent(object sender, DeviceChangedEventArgs e)" doesn't ever get fired so to make it work I had to add this following line of code "myMSR.DataEvent += new DataEventHandler(myMSR_DataEvent);"

    Can you tell me why the other two event's wouldn't fire?

    How is it possible to convert this for a website instead of a web form?

    Tuesday, May 4, 2010 4:14 PM

All replies

  •  

    Do you mean Magnetic strip reader? Or CF / SD cards?

    The answer to the first is yes. (Some examples here: http://www.seanliming.com/WEPOS.html). The answer to the second is CF and SD cards are not POS devices.

    -Sean

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
    Monday, May 3, 2010 5:43 PM
    Answerer
  • Sorry, yes I was referring to a MSR card  reader.  I notice that i see the card reader I have ID Tech is listed in that list but it seems like the tutorials are for the Magtek.  Is there any reason the same code for the Magtek couldn't work with the ID Tech?
    Monday, May 3, 2010 6:04 PM
  • The short answer is the same code will work for both. The UPOS specification defines an abstration layer between the application and the hardware. This is in the form of an OPOS driver or Service Object. The changes to the code would be the OPOS / SO setup.

    -Sean

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
    Monday, May 3, 2010 9:12 PM
    Answerer
  • The short answer is the same code will work for both. The UPOS specification defines an abstration layer between the application and the hardware. This is in the form of an OPOS driver or Service Object. The changes to the code would be the OPOS / SO setup.

    -Sean

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step


    Ok, so that's where I think my problem lies is with the setting up of the OPOS MSR Card Reader.  The problem I have now is that when it tries to run the myMSR.open() command it get a error but there is no error specified.

    Here is the error "Method Open threw an exception. The service object returned a failure status from its open call, but does not have a more specific failure code."

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.PointOfService;
    
    namespace MSR1
    {
     public partial class Form1 : Form
     {
    
     private PosExplorer myExplorer;
     private Msr myMSR;
     
     public Form1()
     {
      InitializeComponent();
      myExplorer = new PosExplorer(this);
    
      DeviceInfo device = myExplorer.GetDevice("Msr", "MTK_MSR"); 
    
      myMSR = (Msr)myExplorer.CreateInstance(device);
      myMSR.Open();
      myMSR.Claim(1000);
      myMSR.DeviceEnabled = true;
      myMSR.DataEventEnabled = true;
      myMSR.DecodeData = true; 
    
      myExplorer.DeviceAddedEvent += new DeviceChangedEventHandler(myExplorer_DeviceAddedEvent);
      myExplorer.DeviceRemovedEvent += new DeviceChangedEventHandler(myExplorer_DeviceRemovedEvent);
     }
    
     void myExplorer_DeviceRemovedEvent(object sender, DeviceChangedEventArgs e)
     {
      if (e.Device.Type == "Msr")
      {
      myMSR.DataEventEnabled = false;
      myMSR.Close();
      lblStatus.Text = "New Msr removed";
    
      }
     }
    
     void myExplorer_DeviceAddedEvent(object sender, DeviceChangedEventArgs e)
     {
      
      if(e.Device.Type == "Msr"){
       
      myMSR = (Msr) myExplorer.CreateInstance(e.Device);
      lblStatus.Text = "New Msr attached: " + e.Device.ServiceObjectName;
    
      myMSR.Open();
      myMSR.Claim(1000);
      myMSR.DeviceEnabled = true;
      myMSR.DataEventEnabled = true;
      myMSR.DecodeData = true;
    
      Update();
      myMSR.DataEvent +=new DataEventHandler(myMSR_DataEvent);
      }   
     }
    
     void myMSR_DataEvent(object sender, DataEventArgs e)
     {
      ASCIIEncoding myEncoding = new ASCIIEncoding();
    
      txtInput.Text = myEncoding.GetString(myMSR.Track2Data);
      lblStatus.Text = "Data Event";
      Update();
      myMSR.DataEventEnabled = true;
     }
     }
    }
    Tuesday, May 4, 2010 11:14 AM
  • Have you tried the test application with the POS for .NET SDK?

    How did you set the logical name for the MSR OPOS driver?

    -Sean

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step
    Tuesday, May 4, 2010 3:44 PM
    Answerer
  • Have you tried the test application with the POS for .NET SDK?

    How did you set the logical name for the MSR OPOS driver?

    -Sean

     


    www.sjjmicro.com / www.seanliming.com, Book Author - XP Embedded Advanced, XPe Supplemental Toolkit, WEPOS / POS for .NET Step-by-Step


    Ok, I finally got it to scan a card.

    The problem I encoutnered is that the "void myExplorer_DeviceRemovedEvent(object sender, DeviceChangedEventArgs e) & void myExplorer_DeviceAddedEvent(object sender, DeviceChangedEventArgs e)" doesn't ever get fired so to make it work I had to add this following line of code "myMSR.DataEvent += new DataEventHandler(myMSR_DataEvent);"

    Can you tell me why the other two event's wouldn't fire?

    How is it possible to convert this for a website instead of a web form?

    Tuesday, May 4, 2010 4:14 PM