VBS macro: how to wait transmit queue to be empty ?

Professional Windows® software to communicate with CAN and CAN FD busses and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939

VBS macro: how to wait transmit queue to be empty ?

Postby MaximeG » Mon 1. Jul 2019, 14:07

Hello,
i use VBS macros for transmit sequences.
What is the correct way to wait transmit queue to be empty ?

For example
Code: Select all
  msgtx.VariableValue("TestVar") = 5
  msgtx.CycleTime = 100
  msgtx.IsPaused = false
  Wait(250)
  msgtx.IsPaused = true
  msgtx.VariableValue("TestVar") = 10
  msgtx.Write(0)


I expect to obtain 2 frames with TestVar=5 and then 1 frame with TestVar=10.
However I get 2 frames with TestVar=5, 1 frame with TestVar=10 and then 6 frames with TestVar=5.
I attached snapshots.

Best regards
Attachments
code.PNG
code.PNG (13.65 KiB) Viewed 172 times
trace.PNG
trace.PNG (17.34 KiB) Viewed 172 times
MaximeG
 
Posts: 9
Joined: Mon 25. Mar 2019, 12:14

Re: VBS macro: how to wait transmit queue to be empty ?

Postby K.Wolf » Tue 2. Jul 2019, 14:17

Hello,
when you start the cyclic transmission of a message, PCAN-Explorer builds a transmit queue that holds messages for the next 500 ms. Therefore, when you stop the cyclic transmission, and the cycle time of your message is 100 ms, up to 5 more messages will be sent.

The following example macro checks if the transmit queue of the first connection in the project is empty:
Code: Select all
Sub WaitXmtQueueEmpty()
  Dim client
  Set client = Connections(1).CommunicationObject.Parent
  While not client.XmtQueueEmpty
    Wait 100
  Wend
  MsgBox "Empty"
End Sub
K.Wolf
Software Development
Software Development
 
Posts: 115
Joined: Wed 22. Sep 2010, 14:37

Re: VBS macro: how to wait transmit queue to be empty ?

Postby MaximeG » Tue 2. Jul 2019, 14:32

Thank's for the reply.
Is it working for J1939 connection ?
MaximeG
 
Posts: 9
Joined: Mon 25. Mar 2019, 12:14

Re: VBS macro: how to wait transmit queue to be empty ?

Postby K.Wolf » Wed 3. Jul 2019, 14:38

No, for J1939 connections there is no XmtQueueEmpty property yet.
But we have already started to implement it, in the next version 6.3.3 it will be possible.
K.Wolf
Software Development
Software Development
 
Posts: 115
Joined: Wed 22. Sep 2010, 14:37


Return to PCAN-Explorer 6 & Add-ins



This website uses cookies for analytics, for logins to the online shop and the forum, and for the handling of an order. By browsing this website you agree to the use of cookies. Detailed information on their use can be found in our privacy policy.

OKPrivacy Policy