Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

LIN API with C++

Hi
 
I am using the LIN API library nicanmsc.lib and Nican.h file to work with the MFC application that I am writing in Visual C++ 6.0.
 
The problem i am encounter with one the API of Nican.h  called  "ncWrite(NCTYPE_OBJH          ObjHandle,
                           NCTYPE_UINT32        SizeofData,
                           NCTYPE_ANY_P         Data)"
 
As this API is used to configure the LIN Interface Slave task to configure or subscribe the data.To do that you have to have frame type is response Entry frame and  one of Data Type called "Is Remote " value equal to 16. Now I am doing exactly same things to achieve configure response entry frame to send data from slave based on the ID from master. As I am able to run this API from my application and its executing correctly and sending correct information that I want to send to Master but the problem I am seeing is that when you execute any of this API it comes with STATUS  back of the execution part went correctly on not based on the value that it returns. In my case eventhough the command looks to me executed correctly as sending the correct data but the STATUS comes with negative value which means it has something wrong in it. I can't figure out the problem in here.
 
Let me know if you any body encounter this kind of problem before. I described you the best way i can describe the problem but if any body has more question feel free to ask it.
 
Thanks
 
Chirayu
0 Kudos
Message 1 of 6
(8,561 Views)
Hi Chirayu,
 
When the status code returned is nonzero, an error or warning is indicated during communication. I would suggest using the ncStatusToString function to debug the application and obtain a description of the error/warning.  This will give us a better idea of what might be causing the status to return a negative value.
 
If you want to avoid displaying error messages while debugging the application, you can use the Explain.exe utility. This console application is located in the Utilities subfolder of the NI-CAN installation folder, which is typically \Program Files\National Instruments\NI-CAN\Utilities.
 
Regards,
Andy L.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(8,544 Views)
Attached is the error message that I am getting when I am using ncWrite command .Eventhough it looks like the command is executed correctly.
 
I will try that Explain.exe also.
 
Let me know if you have any more questions.This problems looks little weird to me. I am thinking might be it has some conflict with C++ MFC Application .
 
Thanks
 
Chirayu
0 Kudos
Message 3 of 6
(8,542 Views)
Hi,
 
Have you tried using an example program?  I would suggest trying a simple write/read example to ensure the hardware is working properly.  From the error message you attached it looks like the frame is not constructed correctly.  Are you sending a header over the bus before sending the message? 
 
After successfully communicating with an example we can verify what might be different in your program and change the log bus error attributes  to true for more specific error reporting to help in debugging the program.   
 
Regards,
Andy L.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(8,519 Views)

Hi,

Thanks For the reply.

I tried the Example of LIN Slave Response and Receive and for that example which is written in console C. It works perfectly fine and giving no Status error at all.I tried to do same things in C++ with MFC that particular  API (ncWrite) giving me errorneous status. Ya In this application Master is sending the Header and ID and based on this ID the slave is responding with the data value of the frame. Example program sending the data correctly and sending zero as status back While my GUI sending data correctly as I can verify through Scope and through my controller which is the Master bu getting STATUS back as negative number that means some error in frame. I have a error attributes also true in my App.

Let me know what would next I can try to figure out this mystery. As I can't see any thing after once API get called  in my debugger even.

Thanks

Chirayu

0 Kudos
Message 5 of 6
(8,516 Views)
Hi,
 
There must be something wrong with your frame type. Is the frame type (IsRemote) really dezimal 16. Perhaps you configured it in hex 16 and then it translates to d22?
Could you perhaps enable Error Logging to receive an Error frame with detailed error information?
 
DirkW
0 Kudos
Message 6 of 6
(8,488 Views)