[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

delays with mscomm

Posted on 2003-12-12
4
Medium Priority
?
475 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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