NET DCU 8 CAN Bus auslesen unter C#

  • Halli Hallo,


    ich habe ein Problemchen mit dem CAN BUS und der NETDCU 8.


    Ich soll in meinem Praxissemester für ein Fahrzeug einen digitalen Tacho programmiern. Der Tacho soll die aktuelle Geschwindikeit anzeigen. Die Geschwindigkeit(und andere Daten Kippwinkel, Temperaturen usw) bekomme ich über den CAN Bus zur Verfügung gestellt.


    Ich arbeite mit Visual Studio 2005 Prof, CF 2.0.


    Wozu brauche ich das NETDCU.sdk ??


    Kann leider auf dem Board noch nicht arbeiten, da der Adapter fürd Display noch fehlt.


    Habe vom Kundensupport eine C# Klasse für .Net programmierung des CAN Bus zur Verfügung gestellt bekommen.


    Hat jemand damit schon Erfahrungen ??


    Habe keine Ahnung wie ich die Klasse in mein Projekt einbinden kann, bzw. wie ich Sie nutze. Wäre um jede Hilfe dankbar


    Mfg Martin

  • Hallo,


    das SDK müssen Sie verwenden wenn Sie unter C++ entwickeln wollen. Dafür gibt es auch schon fertige CAN Beispiele (siehe Forum).


    Zu der C# Klasse für .NET gehört normalerweise auch ein Dokumentation mit Beispielen. Die Klasse ist normalerweise kostenplichtig. Falls Sie die Doku. benötigen setzen Sie sich mit unserem Vertrieb in Verbindung.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Vielen Dank für die schnelle Antwort,


    habe die Klasse von Ihrem Vertrieb bekommen, da es sich hierbei um ein Hochschulprojekt handelt und die Klasse nicht kommerziel eingesetzt wird. Setze mich dann mit dem entsprechendem Kollegen in Verbindung .


    Mfg


    martin Wolff

  • Quote from "MaWo80"

    Setze mich dann mit dem entsprechendem Kollegen in Verbindung .


    Das war wohl mein Fehler. Ich habe Ihnen die Doku soeben per E-Mail gesendet.


    Mit freundlichen Grüßen,


    H. Keller

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,


    I use a NetDCU8-Skit and I want to test the CAN connection with the programs CANCMD.exe, CANREAD.exe and CANWRITE.exe.


    My first try with CANCMD from DCUTermi (COM2) with this instruction:


    start cmd /k cancmd -d CID1: -b 500 -c FFFFFFFF -i 100 -x 0 -s -n FF


    gives me this information:


    1. in the window of CMD:


    Pocket CMD v 5.0
    CANCMD Version 001
    TEstERROR 87
    Transmit: ID=0x100, RTR=0, DLC=1, DATA=0xff


    2. in DCUTermi (COM1):


    ERROR: f:\wince500\platform\netdcu8\src\drivers\can\canlib\sja1000.c
    line 323: Can't set baudrate



    At this point, I did another try with CANREAD, from DCUTermi COM2 with the following instruction “start cmd /k canread -b 500 -d CID1: -f p.txtâ€Â. I found the same error.


    Do you know where could be the problem?


    Thank you in advance,


    Jose MATA
    IFR Automotive

  • Hello,


    i checked your command and it works without problems. So please check if CID1: is correctly loaded (CID1 must be be listet under HKLM\Drivers\Active\XX, see also boot output on serial debug port). Note also SKit always delivered with CAN chip but you can order NetDCU8 without SJA1000!

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,


    I ask for the NetDCU8-SKIT with CAN, so I hope it will be with this SJA1000 chip. How can I check this? I do not have any paper, neither any information on the CD. The only reference that I have from your Spanish dealer is “NETDCU8SKITWC5â€Â.


    I checked if the CAN port is loaded, and that is what I obtain:


    - DCUTermi COM1 / Serial Debug:


    CID: ActiveKey = Drivers\Active\24 (@ 0x0005BBF0)


    - DCUTermi COM2 / ndcucfg:


    !>reg open \Drivers\Active\24<LF>
    OK
    !>reg enum<LF>
    OK -> reg enum key \
    OK -> reg enum value \
    00 "Hnd"=dword:375408 \
    01 "Name"=string:CID1: \
    02 "Key"=string:Drivers\BuiltIn\CAN1 \
    03 "BusParent"=dword:206320 \
    04 "InterfaceType"=dword:0 \
    05 "BusName"=string:BuiltIn_0_21_0 \
    OK
    !>


    Is this correct?


    Mfg,


    Jose MATA
    IFR Automotive

  • Hello,


    your boot output shows that the driver is corrrectly installed.


    I ask for SJA1000 on NetDCU8 because sometimes customer put NetDCU8 without CAN onto SKit baseboard!
    You will find SJA1000 on NetDCU8s bottom side it is the second largest part (you can read easily "SJA1000"). Can you see any defect near this part? Which kernel version do you use?

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello Mr. Zutter,


    I purchased a NetDCU8-SKIT with a NDCU8-32FNCK-WCE50. I see on NetDCU8 bottom side the SJA1000 chip with this information printed on it:


    SJA1000T
    CE4895 02
    Tn605211


    It seems to be all right.


    I use the “NK82_CF2_061024†kernel version.


    Regards,


    Jose MATA
    IFR Automotive


    PS: What does "TEstERROR 87" on CANCMD code mean? I only have canread's and canwrite's codes at the end of WINCE_CAN_DOTNET_eng.pdf.

  • Hello,


    i test it with your configuration and command and everthing seems to be work! So i suggest something is wrong with your HW.


    Error 87 (see your previous post) means "The parameter is incorrect.".You can use the MSWindows "Error Lookup" for retrieve error information.
    Further you can do two things:
    1. Erase the registry to be sure that there are no troublesome entries
    2. Step through the initialization of CAN interface for detailed error information (e.g. insert a couple of "GetLastError()" in the "CCAN::Init()" from http://fs-net.de/phpBB2/viewtopic.php?t=64).


    If this not helps send the board for repair.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,


    I try to follow your indications:


    - Error Lookup:


    For Value 0x00000087; says try to use of JOIN or SUBST command in alredy replaced unit. (Exactly in Spanish: Se ha intentado utilizar el comando JOIN o SUBST en una unidad que ya se había sustituido.)


    It does not help so much :-(


    - Erase the registry:


    I did the following:


    <4>
    NetDCU Config Utility Ready
    Version: 028
    Type help for commands


    !>reg erase<LF>
    ERROR 215: Can't erase registry in flash memory
    !>


    What I should do to do that?


    - CanCheck.zip


    As you told me, I modify the code in file CAN.cpp and I add the following lines at the end of CCAN::Init


    DWORD dwError=GetLastError();
    OutputMessage(_T("Prueba Error 1: %d\r\n"),dwError);
    dwError=GetLastError();
    OutputMessage(_T("Prueba Error 2: %d\r\n"),dwError);


    I expect to see something on DCUTermi, but nothing appears. I saw how the program sent CAN messages, but nothing were received in the other “device Bâ€Â, neither the CAN messages sent from “device B†were received on the NetDCU8.


    As more messages were sent, I can only see this error:


    ERROR: f:\wince500\platform\netdcu8\src\drivers\can\canintf\canbuscore.c line 700: CAN: COM_Write - send_wait timed out
    CAN: Transmit Queue full !!!


    I modify as well the value for the Baudrate in CanCheckDlg.cpp


    #define CAN_BAUDRATE 500 //250000


    But I obtained the same error like before:


    ERROR: f:\wince500\platform\netdcu8\src\drivers\can\canlib\sja1000.c line 323: Can't set baudrate



    I wait for your comments.


    Regards,


    Jose MATA
    IFR Automotive


    Ps. I try to analize with a oscilloscope the signals in the NetDCU8-SKIT's connector. Did you do this analysis before? I would like to known what values to expect.

  • Hello,


    - Error Lookup:
    the error is labeled as "87" not "0x87" or "87h". So the value is a decimal value.


    - Erase the registry:
    For erase registry step into the bootloader. By the command "R" you can erase the registy. After erase the registry wait until the system has rebooted.


    - CanCheck.zip
    Debug messages must be visible on the serial debug line as well as in the debug window of EVC++.
    The lowest baudrate you can set is about 8000! For that 500 causes the error.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Dear Mr. Keller,


    I am working with CanPort C# class, which I already purchased to the sales department.


    I experiment a problem on my software. And it was that the NetDCU8 freezes without saying anything about the cause of it (No exception deployed).


    I try to detect the problem starting from scratch. And I saw that my code works without use the CanPort C# class.


    I develop another application that only send and receive CAN messages and the NetDCU8 freezes when It sends 254 CAN messages and receive 255 CAN messages (1 device changed + 254 Acknowledgements).


    I do another test, and I send continuously CAN messages to the NetDCU8 from another device. I see how the NetDCU8 received the CAN messages (more than 255) and continue working. I start to send CAN messages from the NetDCU8 to the other device and the NetDCU8 freezes only when it sends 254 CAN messages.


    CanWrite.cs class that I use to access CanPort class:




    This the code I use to send a messages from the Form.cs:


    Code
    1. msg0 = new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    2. l_debug_info_trans_text.Text = escribirCan.WriteMessages(0x100, 0, 1, msg0);


    (l_debug_info_trans_text is only a label.)


    I really appreciate your help to find a quick solution to this problem.


    Best Regards,


    Jose MATA
    IFR Automotive

  • Do I understand this correct that you create a new CanPort object for every message you want to write? This is wrong. The idea is to create *one* CanPort object and use it through the whole existence of the application.


    You have to understand how .NET and garbage collection works. When you don't use an object anymore, like pCAN after leaving function WriteMessages(), the object is not destroyed immediately. It still exists further on until the next run of the garbage collector. Therefore every new pCAN object you create exists in parallel with all the old pCAN objects. And as each object opens another file handle, it may be that WinCE is running out of device file handles after 254 open device files.


    Regards,


    H. Keller

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello Mr. Keller,


    Thank you very much for your quick and correct answer.


    I followed the example CanWrite.cs step by step, and I did not realize what I was really doing.


    So I correct it doing two methods, one to create and initialize only one CanPort, other to send the CAN message.


    Now it works.


    Best Regards,


    Jose MATA
    IFR Automotive