CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2007
    Posts
    1

    Com port framming error

    I am using a hardware which has UART pin shared with some other serial protocol pin. So when the hardware is handling data with the other protocol, I get garbage on the UART.

    Now I have written an application in VB 6.0, which reads this data from the hardware. But I never get the data reliably with the application. Sometimes the application stops getting any data from UART. Whereas if I kill my application and connect the same port using HyperTerminal, I still get the data with some garbage in between.

    I feel that when the hardware sends some garbage, which is due to the other protocol, there some framing error occurs and I am unable to handle that error properly(may be resetting that error). So the MSCOM stops getting further data.

    Can anybody tell me anythig about it?

    Thanks for the help.

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Com port framming error

    In your MSComm_OnComm() event handler you're supposed to have something like this:
    Code:
        dim ErMsg$
        Select Case MSComm1.CommEvent
            ' handle events
            Case vbMSCommEvReceive
                     'handle incoming data
    
            'other Cases are for errors
            Case vbMSCommErFrame
                ErMsg = "Frame-error"
            Case vbMSCommErOverrun
                ERMsg = "Overrun"
            Case vbMSCommErCDTO
                ERMsg = "Carrier timeout"
            Case vbMSCommErRxOver
                ERMsg = "Receive buffer overrun"
            Case vbMSCommErRxParity
                ErMsg = "Parityerror"
            Case vbMSCommErTxFull
                ErMsg = "Sendbuffer full"
        End Select
        debug.print ErMsg
    The above sample shows how to detect what kind of error occurs.
    E.g. if you really had a frame error, the CommEvent would be vbMSCommErFrame and the apropriate Case statement would be executed, here loading an error message which is then printed.

    Maybe that gives you a clue what error really occurs and you might take measures in the apropriate Case.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured