Recieving data with MSComm1.Input 
Author Message
 Recieving data with MSComm1.Input

I have a device that sends streaming serial data in an ascii format.
The overall string is seperated by a carriage return and the fields in
that string are seperated by a space.  I'm creating an application to
receive the data and sort it out.  The problem I'm having is with the
routine that receives the data.  Another routine I've got that
searches for serial ports then goes to this routine to see if what is
available at that port is the expected string type.  What is happening
is that the initial data received from the input buffer appears to be
garbage.  Then after awhile the data looks fine.  Unfortunately the
data I have saved as the string is the one that contains the garbage.
What have I got hosed here.  I'm icluding a copy of the routine.
Thanks in advance.

mike

Private Function ModemCommand(APEXSearch) As Integer
Dim strDataIn as String
strDataIn = ""

ModemCommand = 2 'initialize setting for error to FindComPort Routine
MSComm1.Settings = "38400,N,8,1"
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeText    'only want Ascii

'Try a brief pause to allow data to be received if on Comm 1
Sleep (500)
strDataIn = MSComm1.Input
   'Search string for unique identifiers to the string
   If (InStr(strDataIn, Chr(13))) And (InStr(strDataIn, strFirm)) Then
        ModemCommand = 0        'no error, correct string
   Else
        ModemCommand = 1        'look to next port
   EndIf
End Function



Sun, 12 Aug 2001 03:00:00 GMT  
 Recieving data with MSComm1.Input
Michael - I don't know what the garbage could be, unless the buffer is
uninitalized, but rather than getting input the way you are, try the OnComm
event. I've never tried polling the Comm control, and have had very good
results.
HTH - Mike Reublin
Quote:

>I have a device that sends streaming serial data in an ascii format.
>The overall string is seperated by a carriage return and the fields in
>that string are seperated by a space.  I'm creating an application to
>receive the data and sort it out.  The problem I'm having is with the
>routine that receives the data.  Another routine I've got that
>searches for serial ports then goes to this routine to see if what is
>available at that port is the expected string type.  What is happening
>is that the initial data received from the input buffer appears to be
>garbage.  Then after awhile the data looks fine.  Unfortunately the
>data I have saved as the string is the one that contains the garbage.
>What have I got hosed here.  I'm icluding a copy of the routine.
>Thanks in advance.

>mike

>Private Function ModemCommand(APEXSearch) As Integer
>Dim strDataIn as String
>strDataIn = ""

>ModemCommand = 2 'initialize setting for error to FindComPort Routine
>MSComm1.Settings = "38400,N,8,1"
>MSComm1.InputLen = 0
>MSComm1.InputMode = comInputModeText 'only want Ascii

>'Try a brief pause to allow data to be received if on Comm 1
>Sleep (500)
>strDataIn = MSComm1.Input
>   'Search string for unique identifiers to the string
>   If (InStr(strDataIn, Chr(13))) And (InStr(strDataIn, strFirm)) Then
> ModemCommand = 0 'no error, correct string
>   Else
> ModemCommand = 1 'look to next port
>   EndIf
>End Function



Mon, 13 Aug 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. MSComm does not recieve data when Hyper Terminal recieves data OK

2. MSComm1.Input...

3. display out mscomm1.input

4. RS232 and MSCOMM1.Input

5. MSCOMM1 input, help needed

6. Serial input recieve comm event with no characters in the buffer

7. recieve data asynchronously and send the data on the same socket

8. mscomm1, error in receive data

9. recieve data from com1 vb

10. winsock not recieving all data

11. Sending and recieving serial data...HOW?

12. recieving enctype/form-data

 

 
Powered by phpBB® Forum Software