Hello everyone,
Does anyone knows how to delete messages with a specific CAN-ID from the Transmit List through VBS?
I don't want to clear all the Transmit List, just to erase some messages, according to their CAN-IDs...
Thanks in advance!
Delete messages with a specific CAN-ID from Transmit List
- PEAK-Support
- Sales & Support
- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Re: Delete messages with a specific CAN-ID from Transmit Lis
Here you find a simple Macro which generate 3 differnt CAN-ID´s in the Transmit List: ID 0x100, ID 0x110 and ID 0x120. Then the macro search in the Transmit List for the ID 0x100, ID 0x110 and ID0x120 and delete them.
Hope that solve your problem.
Hope that solve your problem.
Code: Select all
Option Explicit
Sub TransmitListSample_Start()
Dim msg1, msg2, msg3
' generate 3 Messages and add to transmit List
Set msg1 = Connections.TransmitMessages.Add
' Initialize the CAN message
PrintToOutputWindow "Create 3 new Msgs in Transmit list - every Second a new one"
With msg1
.ID = &H100
.DLC = 3
.Data(0) = &H11
.Data(1) = &H22
.Data(2) = &H33
.CycleTime =25
If Connections.Count > 0 Then _
Set .Connection = Connections(1)
End With
Wait(700) ' 700msec delay
Set msg2 = Connections.TransmitMessages.Add
With msg2
.ID = &H110
.DLC = 4
.Data(0) = &H12
.Data(1) = &H23
.Data(2) = &H34
.Data(3) = &H45
.CycleTime =50
If Connections.Count > 0 Then _
Set .Connection = Connections(1)
End With
Wait(700) ' 700msec delay
Set msg3 = Connections.TransmitMessages.Add
With msg3
.ID = &H120
.DLC = 8
.Data(0) = &H1
.Data(1) = &H2
.Data(2) = &H3
.Data(3) = &H4
.Data(4) = &H5
.Data(5) = &H6
.Data(6) = &H7
.Data(7) = &H8
.CycleTime =100
If Connections.Count > 0 Then _
Set .Connection = Connections(1)
End With
' now search in the list for ID ßx100
Set msg2 = Connections.TransmitMessages.FindID(&H100)
MsgBox msg2.Count & " times CAN ID 0x100 found in Transmit List - now delete it"
for each msg3 in msg2 ' search in thje collection of msg2 all IDs (msg3)
Connections.TransmitMessages.Remove msg3 ' and delet them
next
Wait(500)
' now search in the list for ID ßx110
Set msg2 = Connections.TransmitMessages.FindID(&H110)
MsgBox msg2.Count & " times CAN ID 0x110 found in Transmit List - now delete it"
for each msg3 in msg2 ' search in thje collection of msg2 all IDs (msg3)
Connections.TransmitMessages.Remove msg3 ' and delet them
next
Wait(500)
' now search in the list for ID ßx120
Set msg2 = Connections.TransmitMessages.FindID(&H120)
MsgBox msg2.Count & " times CAN ID 0x120 found in Transmit List - now delete it"
for each msg3 in msg2 ' search in thje collection of msg2 all IDs (msg3)
Connections.TransmitMessages.Remove msg3 ' and delet them
next
End Sub
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
Re: Delete messages with a specific CAN-ID from Transmit Lis
U.Wilhelm wrote:Here you find a simple Macro which generate 3 differnt CAN-ID´s in the Transmit List: ID 0x100, ID 0x110 and ID 0x120. Then the macro search in the Transmit List for the ID 0x100, ID 0x110 and ID0x120 and delete them.
Hope that solve your problem.
Code: Select all
Option Explicit Sub TransmitListSample_Start() Dim msg1, msg2, msg3 ' generate 3 Messages and add to transmit List Set msg1 = Connections.TransmitMessages.Add ' Initialize the CAN message PrintToOutputWindow "Create 3 new Msgs in Transmit list - every Second a new one" With msg1 .ID = &H100 .DLC = 3 .Data(0) = &H11 .Data(1) = &H22 .Data(2) = &H33 .CycleTime =25 If Connections.Count > 0 Then _ Set .Connection = Connections(1) End With Wait(700) ' 700msec delay Set msg2 = Connections.TransmitMessages.Add With msg2 .ID = &H110 .DLC = 4 .Data(0) = &H12 .Data(1) = &H23 .Data(2) = &H34 .Data(3) = &H45 .CycleTime =50 If Connections.Count > 0 Then _ Set .Connection = Connections(1) End With Wait(700) ' 700msec delay Set msg3 = Connections.TransmitMessages.Add With msg3 .ID = &H120 .DLC = 8 .Data(0) = &H1 .Data(1) = &H2 .Data(2) = &H3 .Data(3) = &H4 .Data(4) = &H5 .Data(5) = &H6 .Data(6) = &H7 .Data(7) = &H8 .CycleTime =100 If Connections.Count > 0 Then _ Set .Connection = Connections(1) End With ' now search in the list for ID ßx100 Set msg2 = Connections.TransmitMessages.FindID(&H100) MsgBox msg2.Count & " times CAN ID 0x100 found in Transmit List - now delete it" for each msg3 in msg2 ' search in thje collection of msg2 all IDs (msg3) Connections.TransmitMessages.Remove msg3 ' and delet them next Wait(500) ' now search in the list for ID ßx110 Set msg2 = Connections.TransmitMessages.FindID(&H110) MsgBox msg2.Count & " times CAN ID 0x110 found in Transmit List - now delete it" for each msg3 in msg2 ' search in thje collection of msg2 all IDs (msg3) Connections.TransmitMessages.Remove msg3 ' and delet them next Wait(500) ' now search in the list for ID ßx120 Set msg2 = Connections.TransmitMessages.FindID(&H120) MsgBox msg2.Count & " times CAN ID 0x120 found in Transmit List - now delete it" for each msg3 in msg2 ' search in thje collection of msg2 all IDs (msg3) Connections.TransmitMessages.Remove msg3 ' and delet them next End Sub
Thank you U.Wilhelm! It works like a charm!
