Using Vector.Diagnostic.dll for sending diagnostics requests

1.5k views Asked by At

I want to send some diagnostics request using python. Code:

clr.AddReference('Vector.CANoe.Interop')
clr.AddReference('Vector.Diagnostics')
import CANoe
import Vector.Diagnostics
 
mCANoeApp = CANoe.Application()
mCANoeApp.Open("myPath")
mCANoeMeasurement =  mCANoeApp.Measurement
mCANoeMeasurement.Start()
mCANoeBus = CANoe.Bus(mCANoeApp.get_Bus("Ethernet"))
MNetwork = CANoe.Networks(mCANoeApp.get_Networks(11))
net = CANoe.Network(MNetwork.get_Item(1))
devices = CANoe.Devices(net.Devices)
device = CANoe.Device(devices.get_Item("myDevice"))

I also attached the following image with the COM Hierarchy from CANoe. COM Object Hierarchy Where it says that device should have a object Diagnostic. But on my side device isn`t having the Diagnostic object, only: ApplicationSocket, AudioInterface and MostDisassambler. Because of this I can not access Diagnostic object in order to create a request.

    diag_ob = device.Diagnostic             #isnt creating a Diag object
    diag_ob.CreateRequest("Default_Start")  #Error

device details

CANoe.Diagnostic failing

device.Diagnostic

Because i cant get access to the Diagnostic object i tried to use directly the Vector.Diagnostics which is seem is not recognize the measurement and im trying to understand how can I link them.

When I'm trying to use the Vector.Diagnostics.Application.GetEcu() I'm receiving a NoneType and My assumption is that GetEcu() method is not seeing the CANoe opened.

Do you have any idea how can a link them ?

1

There are 1 answers

2
Shyam On

Few things to note at the beginning:

  1. You don't have to mention the add reference lines since those dlls are registered when installing CANoe.
  2. Most important is "Vector.Diagnostics" is not to be referenced as this is something which is used by CANoe.
  3. What you are trying to use is the COM interface and not the diagnostic interface.

Check out the following code for sending a default session request:

from win32com.client import *
import time
mainApp = DispatchEx('CANoe.Application')
print(mainApp.Networks("CAN network 1").Devices("Example_ECU").Name) # To make sure you are referencing the correct ECU
diagreq = mainApp.Networks("CAN network 1").Devices("Example_ECU").Diagnostic.CreateRequest("DefaultSession_Start")
time.sleep(1)
diagreq.Send()

Try this out and post any errors which you see in the console. The measurement is to be started before executing the above code.