Makro SendMessage nur auf internem Netz

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
AndreasZ
Posts: 15
Joined: Mon 28. Jan 2013, 11:38

Makro SendMessage nur auf internem Netz

Post by AndreasZ » Mon 28. Jan 2013, 11:44

Hallo,

ich habe ein Makro mit einer Senderoutine welches über "msg.Write PcanConn, timestamp"
eine Nachricht sendet. Diese sehe ich jedoch nur im Empfangsfenster.
Unter "Werkzeug->Status Display" sehe ich das die Message bei Makro gesendet wird, auf dem internen Netz ist und im PeakCan Explorer empfangen wird, jedoch geht die Nachricht nicht über die Hardware an mein Gerät.

Wie bekomme ich die Nachricht auf die PCAN Hardware??

MfG

Andi

M.Maidhof
Support
Support
Posts: 1751
Joined: Wed 22. Sep 2010, 14:00

Re: Makro SendMessage nur auf internem Netz

Post by M.Maidhof » Mon 28. Jan 2013, 12:49

Hallo,

bitte verwenden Sie ein Netz was mit der Hardware verbunden ist, interne Netze sind virtuelle Netze ohne Hardwareanbindung. Bitte starten Sie das Netzkonfigurationstool, und verschieben Sie das Netz auf eine Hardware. Vorher die Verbindung trennen, damit das Netz verschiebbar ist.

Mit freundlichen Gruessen

Michael Maidhof

AndreasZ
Posts: 15
Joined: Mon 28. Jan 2013, 11:38

Re: Makro SendMessage nur auf internem Netz

Post by AndreasZ » Mon 28. Jan 2013, 13:19

Hallo,
danke für die Antwort. Ich habe im Projekt Browser das Netz eingestellt welches ich über meinen PCAN-USB sehe. Wenn ich im Sende / Empfangsfenster eine Nachricht einrichte und diese abschicke bekomme ich auch eine Antwort meines Geräts.
Die Makroroutine sieht wie folgt aus:

Code: Select all

Sub SendMessage()

'DESCRIPTION: Sends CAN messages using a new PCAN client
  Dim UseConn, conn
  ' Find the first enabled connection in the project that uses the CAN protocol
  Set UseConn = Nothing
  For Each conn In Connections
    If conn.IsEnabled And conn.Protocol = peProtocolCAN Then
      Set UseConn = conn
      MsgBox "Project CAN connections OK"
      Exit For
    End If
  Next 
  If UseConn Is Nothing Then
  	 PrintToOutputWindow "No CAN Connections!"
    MsgBox "Project does not contain any enabled CAN connections"
    Exit Sub
  End If

  ' Create a new client and connect it to the same Net that the
  '  found connection uses
  Dim MyClient, PcanConn
  Set MyClient = CreateObject("PCAN3.PCANClient")
  MyClient.Device = UseConn.Device
  MyClient.Name = "Macro"
  PrintToOutputWindow "NetName "  &CStr(UseConn.CommunicationObject.NetName) 
  Set PcanConn = MyClient.Connections.Add(UseConn.CommunicationObject.NetName)
  
  ' Now create and initialize a new transmit message
  Dim msg
  Set msg = MyClient.Messages.Add
  timestamp = MyClient.GetSystemTime + 100
  SendFreq = 500 'ms'
  i = 0
  S_Response = 1
  S_SetValue = 1
  S_SelCell  = 0
  S_MMode	 = 0
PrintToOutputWindow "Start Sending on "  &CStr(UseConn.CommunicationObject.NetName)
  
DO
i = i + 1
With msg
    .ID = &H501
    .DLC = 8
    .MsgType = pcanMsgTypeExtended
    .Data(0) = &H13
    .Data(1) = &H00
    .Data(2) = &H00
    .Data(3) = &H00
    .Data(4) = &H00
    .Data(5) = &H00
    .Data(6) = &H00
    .Data(7) = &H00
End With
  
msg.Write PcanConn, timestamp
timestamp = timestamp + SendFreq
   
  While not MyClient.XmtQueueEmpty
    	Wait SendFreq
  Wend
  LOOP
   
End Sub
Jetzt sollte es ja auf meiner PCAN-Hardware gesendet werden. Ich sehe allerdings nur im Empfang des PCAN Explorer diese Nachricht. Auf dem Internen Bus sehen ich diese auch (unter Werkzeug->StatusDiplay). Siehe Bilder...

Wie bekomme ich diese auf die PCAN USB Hardware?

MfG

Andi
Attachments
TX-Rx.PNG
TX-Rx.PNG (20.23 KiB) Viewed 4940 times
StatusDisplay.PNG
StatusDisplay.PNG (28.91 KiB) Viewed 4940 times

AndreasZ
Posts: 15
Joined: Mon 28. Jan 2013, 11:38

Re: Makro SendMessage nur auf internem Netz

Post by AndreasZ » Mon 28. Jan 2013, 15:11

Hallo,

Thema gelöst.
Sollte Standard Frames versenden...

With msg
.ID = &H501
.DLC = 8
.MsgType = pcanMsgTypeStandard

Danke an Hr. Maidhof!!!

MfG

Andi

Post Reply