Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start and run CANoe from Command Prompt

Is it possible to start and run Vector CANoe from the Command Prompt and/or by using any other external script?

like image 602
Gustaf Gulliksson Avatar asked Dec 08 '14 13:12

Gustaf Gulliksson


3 Answers

This document tells you how to control CANoe from C++, C# etc. This by making use of the CANoe as a COM Server utilities. http://www.vector.com/portal/medien/cmc/application_notes/AN-AND-1-117_CANoe_CANalyzer_as_a_COM_Server.pdf

like image 82
Christian Herrera Avatar answered Nov 13 '22 13:11

Christian Herrera


Yes, it is possible to run Vector CANoe from an external script. The following VBS script code shows the various possibilities to start CANoe and to react on events within CANoe

' Creates and returns a reference to CANoe Application.    
Set App = CreateObject("CANoe.Application")
Set Measurement = App.Measurement
Set Logging     = App.Configuration.OnlineSetup.LoggingCollection(1)
Dim TestFunction, IsRunning
Wscript.ConnectObject Measurement, "Measurement_"

For Count = 1 To 5
    Logging.FullName = "C:\CANWIN" & Count & ".ASC"
    StartMeasurement()
    MsgBox "Press [Ok] to start the next 
    Measurement...", vbSystemModal
    Measurement.Stop
Next
MsgBox "Logging script done..."

While IsRunning
  On Error Resume Next
  TestFunction.Call(CDbl(Second(Time)))
  Wscript.Sleep 1000
Wend
  Wscript.DisconnectObject Measurement

Set Measurement = Nothing
Set App = Nothing

Sub Measurement_OnInit()
  Set TestFunction = 
  App.CAPL.GetFunction("TestFunction")
End Sub

Sub Measurement_OnStart()
  IsRunning = True
End Sub

Sub Measurement_OnStop()
  IsRunning = False
End Sub

Sub StartMeasurement()
  IsRunning = False
  Measurement.Start
  Count = 0
  While Not IsRunning
    Wscript.Sleep 100
    Count = Count + 1
    If Count = 10 Then
      MsgBox "Failed to start measurement!"
      Wscript.Quit
    End If
  Wend
End Sub
like image 2
Om Choudhary Avatar answered Nov 13 '22 12:11

Om Choudhary


CANOE simply loads a .cfg configuration file. For Jenkins, I am using the Visual Basic script and using this loading particular configuration file.

In this was it bypasses the "I accept" and other windows and loads the desired configuration also also using same kind of VB script you can close the application.

'ToStart CANoe_Start.vbs

Set App = CreateObject("CANoe.Application")   
dim fso: set fso = CreateObject("Scripting.FileSystemObject")   
dim CANoe_config    
CANoe_config = fso.BuildPath(fso.GetAbsolutePathName("."), "<target.cfg>")

App.Measurement.Start()

After that you can add the operations in Jenkins jobs; to close the same appilcation use:

'ToStop CANoe_Stop.vbs
Set App = CreateObject("CANoe.Application")
App.Quit()

This worked for me. You can call the vbs's over command prompt.

like image 2
np2807 Avatar answered Nov 13 '22 13:11

np2807