Solved

MSCOMM Garbage Data Returning on .Input Event

Posted on 2010-08-23
2
823 Views
Last Modified: 2013-11-27
I am using Visual Studio (VB.NET) 2003 to build a very simple application that uses an MSCOMM control to connect to a serial port MSR card reader.  The code is supposed to open the port and wait for a card swipe through the card reader.  Everythign works fine right now, but the data getting returned is all garbled and I am trying to figure out where I went wrong with reading the data.  

The code snippet is attached allong with a print screen of the information getting returned in a message box.

The card that is returning that data should be returning the following instead:

;013035101515158731?

I am very new to MSCOMM so this could be just a setting I have set wrong or something like that, but the fact that the port is opening and returning data makes me believe that the connection settings are correct.

Any help is greatly appreciatd!

 Swipe-Results.doc

 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        AxMSComm1.PortOpen = True
        If Err.Number = 0 Then
            MsgBox("Open communication!")
        Else
            MsgBox("Error opening COM port. Please verify MSR is set to COM Port 3.")
        End If

        Exit Sub

RegError:
        MsgBox("Error locating ODBC connection. Please verify ODBC connection has been created.")
        End
    End Sub

    Private Sub AxMSComm1_OnComm(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxMSComm1.OnComm
        Dim InBuffer As String

        Select Case AxMSComm1.CommEvent
            Case MSCommLib.OnCommConstants.comEvReceive

                InBuffer = CStr(AxMSComm1.Input)

                Call HandleInput(InBuffer)
        End Select

    End Sub

    Sub HandleInput(ByVal InBuffer As String)
        ' This is where you will process your input. This
        ' includes trapping characters, parsing strings,
        ' separating data fields, etc. For this case, you
        ' are simply going to display the data in the TextBox.
        txtOCR.Text = InBuffer
        MsgBox(InBuffer)
    End Sub

Open in new window

0
Comment
Question by:Supergrov
2 Comments
 
LVL 41

Expert Comment

by:graye
ID: 33558739
Just guessing... but have you set the following properties:
AxMSComm1.RTSEnable = True
AxMSComm1.DTREnable = True
 
0
 

Accepted Solution

by:
Supergrov earned 0 total points
ID: 33577929
They are both set to true.  I have reverted back to converting the swipe hardware to act as keyboards and am going through that process.  Thanks for the suggestion.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
RLDC Reporting in Visual studio 11 30
Can't disable touch pad on Windows 10 computer 16 45
Iteration Help (Asp.net VB) 5 24
VB.NET Textbox input validation 4 40
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question