Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2006
    Location
    Muscat
    Posts
    2

    Question Unanswered: Com Port problem.

    Hi everybody
    I have a problem while reading data from com port.
    I have connected MSR( Magnetic Card Reader) in the com port.When the member swipes the card in the card reader i am collectiong the member id and storing in a text box. I am using the following code to read data from the card reader . sometimes this code is working properly and some other time it is not reading the member card and not showing any error also. I don't know what is wrong in my code. (Actually I am opening the port and am not closing for a long time ie, more than 3 to 4 hours.)

    Initializing the port at form load

    Private Sub Form_Load()
    MSComm1.CommPort = 3
    MSComm1.Settings = "19200,n,8,1"
    'MSComm1.DTREnable = True
    MSComm1.RTSEnable = True
    MSComm1.RThreshold = 12
    MSComm1.InputMode = comInputModeText
    MSComm1.InputLen = 0
    MSComm1.PortOpen = True
    End Sub

    I am reading the data and storing it in a variable by using the following code

    Private Sub MSComm1_OnComm()
    Dim aaa As String
    If MSComm1.CommEvent = comEvReceive Then
    aaa = MSComm1.Input
    Text1.Text = aaa
    End If
    End Sub

    I am collecting the memner id for every swipe. Format of the member id is
    %99999-123?. length of the member id is not fixed length . it differs from card to card.
    example
    1. %99999-123?
    2. %99994-12?
    3. %99995-1?
    4. %99999/01-123?
    5. %99994/01-12?

    Pls help me. some times i can get the member id from the card reader when the member swipes his card properly. some times i can not get any out put from the card reader. it is not showing any error messages also. Ple help me

    Thanks and regards
    Prem
    premananth_11176@yahoo.co.uk
    Last edited by loquin; 05-07-07 at 13:41. Reason: your schedule is your schedule

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    It looks like the end-of-field marker is the question mark?

    If so, you need to keep adding the received text into a text buffer until you've received the question mark. Only then will you process the member ID.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Dec 2006
    Location
    Muscat
    Posts
    2

    com port problem

    Hai Loquin
    Thanx for ur reply. end-of-field is always question mark. my problem is sometimes i am not receiving any out put from the MSR when the member swipes the card.

    Regards
    Prem
    premananth_11176@yahoo.co.uk

  4. #4
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    no output at all, or a few bytes, or malformed data?

    If there's no output at all, you won't be able to do anything from the app, as, according to the input, nothing HAS happened.

    If there is a byte or two of data with an illegible read, potentially, you can start a one-shot timer on the first receipt of any data, and if no end-of-record marker is received before the timer expires, then clear the buffer and prompt the user to re-scan. When the end-of-file marker IS received, be sure the disable the timer.

    It may also be possible to configure the scanner to output a standard error code in the event of a mis-read. This would allow your app to respond as well - by reviewing the data in the buffer. If it matches the error description, then prompt the user to re-scan.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •