CANhack.de CAN interfaccia RKS+CAN
Tecnica diesel, tecnica motori, diagnosi auto, riparazione e manutenzione.

C# Beispiel

 
Nuovo argomento 🔒 Bloccato 🔗 ⭐ 🖹 CANhack.de - Indice » Sistema CAN-USB CANhack.de: RKS+CAN

Wie wichtig ist euch ein C# API (Programmierschnittstelle) fĂŒr das CAN-Interface?
Unwichtig, ich programmiere in C oder C++
0%
 0%  [ 0 ]
Ich finde C# super und will so etwas!
100%
 100%  [ 2 ]
Unwichtig, ich nutze nur KCANMonitor.
0%
 0%  [ 0 ]
Voti totali : 2

Autore Messaggio
CAN-Diagnose
Administrator
Administrator
Avatar-CAN-Diagnose

Iscritto il: 07/06/2011
Messaggi: 573
Karma: +29 / -0   Grazie, mi piace!
LocalitĂ : LĂ€ndle



Messaggio05-04-2017, 17:55    Oggetto: C# Beispiel Traduzione in corso...

[Traduzione in corso...]

Noch nicht ganz fertig, prinzipiell geht die C++ DLL zur Nutzung des RKS+CAN Interface so zu nutzen.
Kann man natĂŒrlich noch schöner programmieren und es wird auch nur Seriennummer und Versionsinfo vom Interface dargestellt.

Wenn jemand ein C# Crack ist, bitte bezĂŒglich Verbesserungen bei mir melden. Sinnvoll wĂ€re eine eigene C# Datei zum Einbinden, welche die DLL-API kapselt. Alles kein Hexenwerk.

Viele GrĂŒsse, Rainer



Example-Net.rar
 Descrizione:
 Beispiel, verbesserte Versionen siehe im Laufe des Themas.
Beispiel, verbesserte Versionen siehe im Laufe des Themas.
Scarica
 Nome file:  Example-Net.rar
 Dimensione file:  500.96 KB
 Scaricato:  1108 volte
Dipl.-Ing. (FH) Rainer Kaufmann - Embedded Software Freelancer
System RKS+CAN: CANHack.de CAN-Bus Interface


Ultima modifica il 27-04-2018, 13:05, modificato 9 volte in totale.
Torna su Profilo MP WWW
dunt
Hacker
Hacker


Iscritto il: 06/11/2015
Messaggi: 11
Karma: +0 / -0   Grazie, mi piace!


Supporto Premium

Messaggio11-06-2017, 12:29    Oggetto: C# Beispiel Traduzione in corso...

[Traduzione in corso...]

Hat diesbezĂŒglich schon jemand etwas? Habe das Projekt mal um Ub erweitert was auch soweit funktioniert hat.

HĂ€nge jetzt aber beim empfange der CAN Messages.

Codice:
if(RKSCANRx(&sRx))
- genau hier wie muss ich diese von der DLL ĂŒbernehmen.

es wird folgender fehler angezeigt "ZusĂ€tzliche Informationen: "parameter #1" kann nicht gemarshallt werden: Zeiger dĂŒrfen nicht auf gemarshallte Strukturen verweisen. Verwenden Sie stattdessen ByRef.."


evtl. kann mir jemand helfen icon_wink.gif



2017-06-06_RKS CAN USB.rar
 Descrizione:
 C# Beispiel
C# Beispiel
Scarica
 Nome file:  2017-06-06_RKS CAN USB.rar
 Dimensione file:  988.74 KB
 Scaricato:  1387 volte
Torna su Profilo MP
CAN-Diagnose
Administrator
Administrator
Avatar-CAN-Diagnose

Iscritto il: 07/06/2011
Messaggi: 573
Karma: +29 / -0   Grazie, mi piace!
LocalitĂ : LĂ€ndle



Messaggio16-06-2017, 13:37    Oggetto: C# Beispiel Traduzione in corso...

[Traduzione in corso...]

Gnarf... zum C# Hacker wider Willen. Das Leben könnte so einfach sein, bin dran und bald wieder urlaubsreif.

Hier ist erklÀrt wie es geht:
http://andyrushton.co.uk/csharp-calling-c-functions-marshalling-structs/
https://docs.microsoft.com/en-us/dotnet/framework/interop/passing-structures

Anstatt jeden einzelnen Funktionsaufruf der C/C++-DLL kompliziert zu verpacken, wÀre es wohl sinnvoll die C# RKS-USB Klasse um Wrapperfunktionen zu erweitern, die man stattdessen aufruft. So hat man den Aufwand nur einmal.

Viele GrĂŒsse, Rainer
Dipl.-Ing. (FH) Rainer Kaufmann - Embedded Software Freelancer
System RKS+CAN: CANHack.de CAN-Bus Interface


Ultima modifica il 09-12-2017, 13:17, modificato 5 volte in totale.
Torna su Profilo MP WWW
CAN-Diagnose
Administrator
Administrator
Avatar-CAN-Diagnose

Iscritto il: 07/06/2011
Messaggi: 573
Karma: +29 / -0   Grazie, mi piace!
LocalitĂ : LĂ€ndle



Messaggio10-01-2018, 20:58    Oggetto: C# Beispiel Traduzione in corso...

[Traduzione in corso...]

Codice:
using System.Runtime.InteropServices;

// CAN frame types

// CAN data structure
public class can_data_t
{
  public uint dwID;
  public byte byDLC;
  public byte[] abyData = new byte[8]; // max 8 data bytes
}

// CAN error information structure
public class can_err_t
{
  public byte byError;
}

// CAN information structure
//C++ TO C# CONVERTER TODO TASK: Unions are not supported in C#, but the following union can be replicated with the StructLayout and FieldOffset attributes:
//ORIGINAL LINE: union can_union_t
[StructLayout(LayoutKind.Explicit)]
public struct can_union_t
{
  [FieldOffset(0)]
  public can_data_t sData;
  [FieldOffset(0)]
  public can_err_t sErr;
}

// The final CAN frame structure used for send/receive
public class can_msg_t
{
  public byte byType;
  public uint dwTimeStamp;
  public can_union_t uFrm = new can_union_t();
}


internal static class DefineConstants
{
   public const int FRAME_TYPE_NORMAL = 0x1;
   public const int FRAME_TYPE_RTR = 0x2;
   public const int FRAME_TYPE_NORMAL_EXT = 0x3;
   public const int FRAME_TYPE_RTR_EXT = 0x4;
   public const int FRAME_TYPE_ERR = 0x5;
}
Dipl.-Ing. (FH) Rainer Kaufmann - Embedded Software Freelancer
System RKS+CAN: CANHack.de CAN-Bus Interface
Torna su Profilo MP WWW
CAN-Diagnose
Administrator
Administrator
Avatar-CAN-Diagnose

Iscritto il: 07/06/2011
Messaggi: 573
Karma: +29 / -0   Grazie, mi piace!
LocalitĂ : LĂ€ndle



Messaggio27-04-2018, 13:15    Oggetto: C# Beispiel Traduzione in corso...

[Traduzione in corso...]

C# Wrapper von Alexander Schmidt auf Github:
https://www.canhack.de/it/viewtopic.php?t=2400
Dipl.-Ing. (FH) Rainer Kaufmann - Embedded Software Freelancer
System RKS+CAN: CANHack.de CAN-Bus Interface
Torna su Profilo MP WWW

Valutazioni - C# Beispiel

Valutazione media: 0,00 - valutazione peggiore: 0 - valutazione migliore: 0 - numero di valutazioni: 0 - Visualizza valutazioni

Non sei autorizzato a valutare questo argomento. Danke sagen
Nuovo argomento 🔒 Bloccato 🔗 ⭐ 🖹 CANhack.de - Indice » Sistema CAN-USB CANhack.de: RKS+CAN
Vai a:  
Non puoi scrivere nuovi argomenti in questo forum.