Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi ,
I am also trying to access CAN bus data in C++. I have PCAN_USB(my hardware board connected with CAN) and I am getting heart beats which i can see from PCAN_View(PEAK systems API) but what i need to do is to save all coming CAN Data(heart beats) into a log file (pcanlog.txt) using C++.
Now my headache is how to access CAN data (e.g CAN ID, Data and time stump) in C++ or QT?

Thanks
Posted
Updated 28-Oct-15 22:56pm
v2
Comments
[no name] 29-Oct-15 5:18am    
Just go to their website - "http://www.peak-system.com/Software-APIs.305.0.html?&L=1" - download the (FREE) api - read the documentation and bingo.
Ramiien 29-Oct-15 5:39am    
Thanks for your answer. I already did this. right now my position is i am getting data From DLL file. e.g

qDebug() << "Hardware Name is :" << PCAN_HARDWARE_NAME;
and it returns me "14" i dont know what this means and how to get Name of the hardware and further information of the hardware from these IDs??
similarly
qDebug() << "Hardware channel is :" << PCAN_CHANNEL_CONDITION
I get the output "13" but as per documentation expected values would be
PCAN_CHANNEL_AVAILABLE
PCAN_CHANNEL_UNAVAILABLE
PCAN_CHANNEL_OCCUPIED
PCAN_CHANNEL_PCANVIEW
I didnot get how to get these values from documentation.

Well, they provide the API documentation, at least[^]. You should carefully study the API and then write your application.
 
Share this answer
 
Comments
Ramiien 29-Oct-15 5:40am    
Thanks for your answer. I already did this partially. right now my position is i am getting data From DLL file. e.g

qDebug() << "Hardware Name is :" << PCAN_HARDWARE_NAME;
and it returns me "14" i dont know what this means and how to get Name of the hardware and further information of the hardware from these IDs??
[no name] 29-Oct-15 6:28am    
Have you worked through the example code?
Ramiien 29-Oct-15 7:13am    
if example code means code in API documentation than yes i didn't get it fully when I tried to do it in C++. would be nice if you guide me in this direction.
VB
PCAN_CHANNEL_AVAILABLE
PCAN_CHANNEL_UNAVAILABLE
PCAN_CHANNEL_OCCUPIED
PCAN_CHANNEL_PCANVIEW



These are likely #define'd symbols or an enumeration. You need to study the API. One of the API functions may return a channel status. Your code might read something like:

C++
int status = your_api_get_status();
switch (status)
{
case PCAN_CHANNEL_AVAILABLE:
    qDebug() << "available";
    break;
case PCAN_CHANNEL_UNAVAILABLE:
    qDebug() << "unavailable";
    break;
case PCAN_CHANNEL_OCCUPIED:
    qDebug() << "occupied";
    break;
case PCAN_CHANNEL_PCANVIEW:
    qDebug() << "pcanview";
    break;
default:
    break;
}
 
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