Macro: Send Message with incrementing ID

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
H31nZ
Posts: 2
Joined: Mon 15. Jun 2015, 13:12

Macro: Send Message with incrementing ID

Post by H31nZ » Mon 15. Jun 2015, 13:17

Hi,
i want to write a macro that lets me send a CAN-message with an incrementing ID, something like:

while i < 799h
Send 1 i 2 12h 34h
Wait 10
i++
wend

As i don't know anything about VBS i am having trouble bringing this to life!
Can anyone please help me?
Thanks and Greetings :twisted:

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: Macro: Send Message with incrementing ID

Post by K.Wolf » Tue 16. Jun 2015, 14:04

Hi,
this VBS macro should do it:

Code: Select all

Sub IncrementID()
  Dim msg, id
  Set msg = Connections.TransmitMessages.Add
  Set msg.Connection = Connections(1)
  msg.DLC = 2
  msg.Data(0) = &H12
  msg.Data(1) = &H34
  For id = 0 To &H799
    msg.ID = id
    msg.Write 0
    Wait 10
  Next
End Sub

H31nZ
Posts: 2
Joined: Mon 15. Jun 2015, 13:12

Re: Macro: Send Message with incrementing ID

Post by H31nZ » Tue 16. Jun 2015, 14:45

Works like a charm!
Thank you :)

Post Reply