I have a problem that only happens sometimes. I send a string to the comport and then wait for a reply. I am tring to receive a 7 byte block form the comport and sometimes I lose the first byte. When this happen it will do it every time I try I can resend the request and will recive 6 bytes. Other times it will work fine when I run it and every time I try after that. Any Ideas?
This is what I should reciev in HEX if that matters
31 0D 0a 50 54 58 3E
Opening port
VB Code:
With MSComm1 .CommPort = 5 'ComPort .Handshaking = comNone '2 - comRTS .RThreshold = 1 .RTSEnable = True .DTREnable = True .Settings = "9600,n,8,1" .SThreshold = 1 .InputMode = comInputModeText .InputLen = 1 .PortOpen = True ' Leave all other settings as default values. End With
Writing what read to text1.text
VB Code:
Do While Timer < TimeOut + 1 If FrmHitScores.MSComm1.InBufferCount > 0 Then 'to be sure something in the buffer sTEMP = MSComm1.Input 'get a byte strRX = strRX & sTEMP 'assemble the input bytes into strRX End If If Len(strRX) = 7 Then for a = 1 to 7 text1.text = text1.text & Hex(Asc(Mid$(strRX, a, 1))) next a strRX = "" Exit Do End If Loop




Reply With Quote