September 5th, 2007, 06:24 AM
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.
September 5th, 2007, 03:12 PM
Re: Com port framming error
In your MSComm_OnComm() event handler you're supposed to have something like this:
The above sample shows how to detect what kind of error occurs.
Select Case MSComm1.CommEvent
' handle events
'handle incoming data
'other Cases are for errors
ErMsg = "Frame-error"
ERMsg = "Overrun"
ERMsg = "Carrier timeout"
ERMsg = "Receive buffer overrun"
ErMsg = "Parityerror"
ErMsg = "Sendbuffer full"
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.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!