Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Communications > MSComm Control Problem...Help!


Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2006, 01:59 AM
aldinlapinig aldinlapinig is offline
Newcomer
 
Join Date: Aug 2006
Posts: 4
Default MSComm Control Problem...Help!


Hi all,

I have a problem using MSComm Control for vb6... first I have to show u a little snippet of a program:

Assumption: Port settings already setup

Code:
Public Sub Command1_Click()
   MSComm1.Inputlen = 0
   MSComm1.RThreshold = 1
   MSComm1.Output = "AT" & vbCr
End Sub

Private Sub MSComm1_OnComm()
   Dim in_buffer as String
   
   Select Case MSComm1.CommEvent
        Case Is = comEvReceive            
            in_buffer = MSComm1.Input
        Case else
   End Select
End Sub
The problem is that, I could not read the entire content of MSComm1.Input (hardwarely, input buffer). As far as I know, it should read the entire content of the input buffer because I set the Inputlen property of the Comm Control to zero and that it would trigger the OnComm method if a character is received in the input buffer. The following is the result if the program is executed:

I sent: AT<cr> and I should receive: AT<cr><cr><lf>OK<cr><lf>

but I could only read:
in_buffer = "AT<cr>"

the remaining of the response packet is in the MSComm1.Input (I added watch to the control input property):
MSComm1.Input = "<cr><lf>OK<cr><lf>"

What could be the possible reason to this? Any idea on how I could solve this? I already researched about MSComm on the net and no information regarding this matter is available. Can anybody give me a good resource for understanding the inner working of MSComm Control? Thank you very much. I highly appreciate your time and help.

Kind Regards,
-=alDin=-
Reply With Quote
  #2  
Old 08-16-2006, 02:11 AM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

Hi,

It's a matter of timing. The OnComm event is triggered when the first character is received (RThreshold = 1) at the time you issue the MSComm1.Input only "AT<cr>" has been received. By the time Watch reports the buffer has been cleared (because you read the "AT<cr>" ) and the rest of the data has arrived. If you let it run you will see that you actually receive more than one OnComm event so you have to concatinate the input until you have received all the message.

Regards
Doug
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data
Reply With Quote
  #3  
Old 08-16-2006, 02:26 AM
namrekka namrekka is offline
Junior Contributor
 
Join Date: Feb 2005
Location: Netherlands
Posts: 219
Default

Also fill your own buffer with:
Code:
in_buffer =in_buffer & MSComm1.Input
Reply With Quote
  #4  
Old 08-16-2006, 03:28 AM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

Quote:
Originally Posted by namrekka
Also fill your own buffer with:

Code:
in_buffer =in_buffer & MSComm1.Input
Make sure that in_buffer is defined as Static in the OnComm Event or is defined in the Declarations section of the form.
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->