Solved

delays with mscomm

Posted on 2003-12-12
4
454 Views
Last Modified: 2010-05-01
I'm using the MSComm OCX to communicate with a robot. I send a command out and the robot sends back a response. The problem I'm having is it takes a couple seconds round trip for the VB program to receive the data. I know it's not the robots fault because I have a similar program in C++ and if I send the same data then it comes back with the results within milliseconds. I don't see any kind of priority setting on the OCX, any ideas here?
I'm using win 98 and VB6. My ReceivePacket function is modeled directly after sample code.

Here it is.
Public Sub ReceivePacket(InByte As Byte)
Static Serial_Buffer(255) As Byte
Static PacketLen As Integer
Static Index As Byte 'stores index point in comm buffer. Serial bytes
                     'are placed in Serial_Buffer[index], then [index]
                      ' is incremented.
Static begin_flag As Byte ' If begin_flag = 0 and index = 0, look for
                        ' 0x54 on serial stream.Otherwise,
                        ' place byte in Serial_Buffer[index] and wait
                        ' until PacketLen is equal to index.

Serial_Buffer(Index) = InByte
Hex$(Serial_Buffer(Index))
If begin_flag = 0 Then
    If InByte <> &H54 Then
        GoTo EndReceivePacket
    Else:
        begin_flag = 1
    End If
End If


If Index >= 2 Then
    PacketLen = (Serial_Buffer(2) + 6)
    If PacketLen > 254 Then
        Index = 0
        begin_flag = 0
        GoTo EndReceivePacket
    End If
    If Index = PacketLen Then ' process packet
        Index = 0
        begin_flag = 0
        Call Process_Packet(Serial_Buffer)
        GoTo EndReceivePacket
    End If 'end of process packet

End If

Index = Index + 1 ' get ready to receive next byte
EndReceivePacket:
End Sub

Thanks Ringo
0
Comment
Question by:ringo42
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Sector10 earned 250 total points
ID: 9930331
Hi Ringo,

Just a tought using the MSComm1_OnComm Event:

If MSComm1.CommEvent = MSCOMM_EV_RECIEVE Then
0
 
LVL 1

Expert Comment

by:Sector10
ID: 9930387
Hi Ringo,

Pressed the submit button to quick, but here is the rest.

Just a tought using the MSComm1_OnComm Event try to print the input to a textfield by rewriting the bufferarray:

Dim temp1 AS String
Dim BufferArray() AS Byte

If MSComm1.CommEvent = MSCOMM_EV_RECIEVE Then

BufferArray = MSComm1.Input
For I = 0 To UBound(BufferArray)
    temp1 = temp1 & BufferArray(i)
Next I



Regards,

Paul
0
 
LVL 27

Expert Comment

by:planocz
ID: 10289665
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
No response from ringo42 from 12/12/2003 comment
Award points to Sector10 is recommend.
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

planocz
EE Cleanup Volunteer
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question