10-15-2015 10:57 AM
Hello,
I need to develop an application under Labwindows/CVI 2013 that can do basic diagnostics on LIN. I have installed the toolkit "Automotive Diagnostic Command Set" and even tested the 2 NI examples.
I have a PXI-8516 baord. I just need to send and recieve frames.
I know that this frame is a good one for example : 3C-92-F2-00-00-00-00-00-00
The problem with the example is that the 0x3C and 0x3D is not used. I need to know how can a create and send a frame and how recieve the ansewer (need to wait for few ms before reading ? )
here my code ( part on callaback function) :
unsigned char dataIn[8] = {146, 242, 0, 0, 0, 0, 0, 0}; //HEX : 92, F2, 00, 00, 00, 00, 00, 00 unsigned int len = 8; switch (event) { case EVENT_COMMIT: Delay(1); for(int i=0; i<8;i++) { status = ndUDSWriteDataByIdentifier(&DiagStruct, 0x3C, dataIn, len, &Success); Delay(1); status = ndUDSWriteDataByIdentifier(&DiagStruct, 0x3D, dataIn, len, &Success); Delay(1); }
Thank you in advance !
Solved! Go to Solution.
10-16-2015 12:08 PM
Blue_Strike,
Which examples are you using? Are they the ones the ship with CVI? Did you modify them?
10-17-2015 05:04 PM
Hello Becca M.
Yes I'm using the example provided when you install CVI 2013.
I didn't modified the source, I just copied few lines to my code.
10-19-2015 03:39 AM
I have Mux Trace too connected to my device and my Ni board (PXI 8516). When I send a frame with mux trace like 'HEX : 92, F2, 00, 00, 00, 00, 00, 00' and then a request resp frame, I get the frame answer.
I want to do the same thing but with CVI.
10-19-2015 08:29 AM
Blue_Strike,
Have you tried just running the examples without taking parts of it and putting it in your code? This is a great way to ensure that everything is connected correctly and that you are getting the desired functionality. Which examples are you looking at? And what exactly is not working with your code? Are you getting an error?
10-20-2015 04:18 AM
Hello,
I'm getting a general message error.
Firsteble, I call ndOpenDiagnosticOnLin (19200 baud LIN1) then ndUDSDiagnosticSessionControl (mode 0x81) then ndUDSReadDataByIdentifier function
Here is my Callaback function code to read LIN frame :
int CVICALLBACK UDSReadDataByIdentifierCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { char *Report_temp = NULL; unsigned short ID = 0; int ID_temp = 0; unsigned char dataIn[8] = {146, 242, 0, 0, 0, 0, 0, 0}; //HEX : 92, F2, 00, 00, 00, 00, 00, 00 unsigned char dataOut[8]; long len = 8; switch (event) { case EVENT_COMMIT: //Get TABPANEL handle and num GetPanelHandleFromTabPage (panelHandle, MAIN_PANEL_TABPANEL, 1, &DiagtabHandle); Report_temp = malloc(128 * sizeof(char)); ID = (unsigned short) ID_temp; Delay(1); status = ndUDSReadDataByIdentifier(&DiagStruct, DIAG_READ_ID, dataOut, len, &Success); //DIAG_READ_ID = 0x3D // Len = 8 Delay(0.05); CheckError ("ndUDSReadDataByIdentifier", status, Report_temp); SetCtrlVal(DiagtabHandle, TABDIAG_LED_Diag_RD_Data_Id, ON); if(status == 0) // first call OK { SetCtrlAttribute (DiagtabHandle, TABDIAG_LED_Diag_RD_Data_Id, ATTR_ON_COLOR , status == 0? VAL_GREEN : VAL_RED); SetCtrlVal(DiagtabHandle, TABDIAG_STATUS_FUNC_6, "PASS"); SetCtrlVal(DiagtabHandle, TABDIAG_REPORT_FUNC_6, Report_temp); } else //Error { SetCtrlAttribute (DiagtabHandle, TABDIAG_LED_Diag_RD_Data_Id, ATTR_ON_COLOR , VAL_RED); SetCtrlVal(DiagtabHandle, TABDIAG_STATUS_FUNC_6, "FAIL"); SetCtrlVal(DiagtabHandle, TABDIAG_REPORT_FUNC_6, Report_temp); } break; } return 0; }
I'm getting a general error in the line ndUDSReadDataByIdentifier. (See attached pic)
10-20-2015 04:38 AM
Besides, when I check the Mux Trace to see what the ndUDSReadDataByIdentifier send on the LIN, I see this :
but what I want to send is different. I mean, when i call the ndUDSWriteDataByIdentifier function.
10-20-2015 08:58 AM
Should I use the ndDiagFrameSend function to send a LIN diag frame ?
10-21-2015 02:34 AM - edited 10-21-2015 02:35 AM
To resume all this, how can I do to send this frame on LIN :
HEX : 92, F2, 00, 00, 00, 00, 00, 00
And how should I do to read ECU answer using the automotive toolkit.
10-21-2015 10:23 AM
Blue_Strike,
1. Are you seeing the same error/crash when you are just running the examples? If you haven't done so already, run the examples without changing them. Check to see what you are outputing by using the Bus Monitor.
2. Use the Bus Monitor so you can check what you are actually sending out on the bus. Do this for both your program as well as the examples. This will give confirmation of what is being sent, not what is actually on the ECU
3. Do you have a database?
4. Can you post your code where you set up your handle?