Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am doing CAN first time using C++: I am using API function to initialize CAN. Function for API CAN intialization is as following
XML
/// <summary>
/// Initializes a PCAN Channel
/// </summary>
/// <param name="Channel">"The handle of a PCAN Channel"</param>
/// <param name="Btr0Btr1">"The speed for the communication (BTR0BTR1 code)"</param>
/// <param name="HwType">"NON PLUG&PLAY: The type of hardware and operation mode"</param>
/// <param name="IOPort">"NON PLUG&PLAY: The I/O address for the parallel port"</param>
/// <param name="Interrupt">"NON PLUG&PLAY: Interrupt number of the parallel port"</param>
/// <returns>"A TPCANStatus error code"</returns>
TPCANStatus __stdcall CAN_Initialize(
        TPCANHandle Channel,
        TPCANBaudrate Btr0Btr1,
        TPCANType HwType _DEF_ARG,
        DWORD IOPort _DEF_ARG,
        WORD Interrupt _DEF_ARG);


I am not sure about the last 3 parameters what will come here and how to find them
e.g CAN_Initialize(PCAN_NONEBUS, PCAN_BAUD_5K, ??, ??, ?? );

Any help\suggestion please????
Posted
Updated 30-Oct-15 4:49am
v3
Comments
Jochen Arndt 30-Oct-15 11:43am    
I have used CAN too but the answer is obvious:
- If you have a plug&play device just pass zero or omit the parameters.
- If not, the parameters depend on your CAN hardware and should be part of the device documentation.
Ramiien 30-Oct-15 12:02pm    
I am using PCAN_USB so it means all parallel parameters would be 0 ??
Jochen Arndt 30-Oct-15 13:35pm    
Yes.

When replying to a comment you should use the "Reply" button right of the poster's name like I have done here. Then an email is send upon the new comment. This time it was just by chance that I saw your above comment.
Ramiien 30-Oct-15 17:36pm    
Thanks for guidance
I am facing problem in connecting DLL file in my class(myclass.cpp). it is giving me linked crash error "program has unexpectedly finished"
in .pro file i am giving the path of dll file like given below
--------------------------------------------------------------
CONFIG += "C:/mypro/debug/PCANBasic.dll"

and in myclass.cpp file
-------------------------------
#define PCANBasic.h //header file of API

CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_5K) //function of PCAN_USB API

please guide me in this problem.
Jochen Arndt 31-Oct-15 4:42am    
Check first if the DLL has matching dependencies (e.g. requires other DLL with a specific version). These should be documented.

Then you must identify the function that terminates your app. This can be done using debug mode and stepping through your program until the error occurs. Ensure that all function parameters are valid.

In general you should check all function return values for errors.

1 solution

to access DLL file. use Loadlibrary() and GetProcAddress()

for example check this link
https://www.c-plusplus.net/forum/128715-full
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900