CCP_Read on daqlist results in PCAN_ERROR_QRCVEMPTY

A free API for the Communication with Control Units based on the CAN Calibration Protocol (CCP) by ASAM for Windows®
Post Reply
lslahrs_
Posts: 11
Joined: Tue 25. Jun 2013, 11:24

CCP_Read on daqlist results in PCAN_ERROR_QRCVEMPTY

Post by lslahrs_ » Tue 25. Jun 2013, 11:42

I created and started a daq-list on an ecu and also created a windows-event in my application like that:

Code: Select all

CCPConnection::WaitForRecvEvent()
{
    HANDLE receiveHandle = CreateEvent(NULL, FALSE, FALSE, NULL);

    DWORD result = 0;
    DWORD temp = 0;

    //set PCAN_RECEIVE_EVENT and assign it a handle
    CAN_SetValue(m_can_handle, PCAN_RECEIVE_EVENT, &receiveHandle, sizeof(receiveHandle));

    do {
       result = WaitForSingleObject(receiveHandle, INFINITE);

       if(result == WAIT_OBJECT_0) {
           qDebug() << "Got message-object.";
           ReceiveMessages();
       }

    } while(m_measurement_running);

    CAN_SetValue(m_can_handle, PCAN_RECEIVE_EVENT, &temp, sizeof(temp));
}
The method ReceiveMessages which gets called after catching the event looks like that:

Code: Select all

void
CCPConnection::ReceiveMessages()
{
    TCCPResult result;
    TCCPMsg message;
    do {
        result = CCP_ReadMsg(m_ccp_handle,
                &message);

        if ((result & 0x7FFFFFFF) == PCAN_ERROR_QRCVEMPTY) {
            qDebug() << "Empty queue";
            continue;
        } else if (CCP_ERROR_ACKNOWLEDGE_OK != result) {
            Debug(result, "CCP_ReadMsg");
        } else {

            qDebug() << "Got message for PID:" << message.Data[0];
            qDebug() << message.Data[1]
                << QString::number(message.Data[2], 16)
                << QString::number(message.Data[3], 16)
                << QString::number(message.Data[4], 16)
                << QString::number(message.Data[5], 16)
                << QString::number(message.Data[6], 16)
                << QString::number(message.Data[7], 16);
        }

    } while (true);        
}
The event is correctly triggered and watching PCAN-View I see, that the correct packages arrive on my PC, but I always get the error PCAN_ERROR_QRCVEMPTY.
With my code I am able to read single measurements using CCP_Upload, so I guess my initialization and connection-setup works fine.
Also due to the correct output in PCAN-View the daqlist seems to get initialized and started correctly.
Do you have any idea on what am I doing wrong? Do I have to start the message-queue first or something?

Thanks in advance!

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: CCP_Read on daqlist results in PCAN_ERROR_QRCVEMPTY

Post by K.Wagner » Tue 25. Jun 2013, 12:04

Hello lslahrs_,

About the Event:
Registering an event through CAN_SetValue will signalizes that CAN data has arrived. This signal is also received internally by the CCP API in order to work out CAN Frames (convert it to a CCP Frame). It is possible that you receive your event signaled before the CCP frame is actually inserted into the queue. Try using a Timer instead to see if you get the frame at any other time.

About the DTO:
Which DTO are you waiting to receive? It is the one passed on CCP_Connect (using the SlaveData strucutre), or is a dedicated DTO? If it is a dedicated DTO, you have to set this first using the function CCP_GetDAQListSize.
Best regards,
Keneth

lslahrs_
Posts: 11
Joined: Tue 25. Jun 2013, 11:24

Re: CCP_Read on daqlist results in PCAN_ERROR_QRCVEMPTY

Post by lslahrs_ » Tue 25. Jun 2013, 16:04

Thanks a lot for your fast response!
K.Wagner wrote:Hello lslahrs_,

About the Event:
Registering an event through CAN_SetValue will signalizes that CAN data has arrived. This signal is also received internally by the CCP API in order to work out CAN Frames (convert it to a CCP Frame). It is possible that you receive your event signaled before the CCP frame is actually inserted into the queue. Try using a Timer instead to see if you get the frame at any other time.
Thanks for this note.
But I guess that's not the problem, because running CCP_Read in an endless-loop (without any events) results in the same error, that the queue is always empty.
K.Wagner wrote:About the DTO:
Which DTO are you waiting to receive? It is the one passed on CCP_Connect (using the SlaveData strucutre), or is a dedicated DTO? If it is a dedicated DTO, you have to set this first using the function CCP_GetDAQListSize.
I'm trying to read DTOs send by the ecu after calling CCP_StartStopDataTransmission and of course, after initializing the corresponding daqlist at first. I also called the command CCP_GetDAQListSize before initializing the daqlist.
But maybe I did it wrong. I don't really know what to put into the third argument called DTOId.
Could that be the problem?
Actually I don't think so, because after running CCP_StartStopDataTransmission I can verify that the ecu already sends the correct data using PCAN-View. It's just the CCP_Read command in my application which always returns with PCAN_ERROR_QRCVEMPTY.

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: CCP_Read on daqlist results in PCAN_ERROR_QRCVEMPTY

Post by K.Wagner » Tue 25. Jun 2013, 16:26

Hello,

An ECU can use 2 manners for DTO sending:
  • Using the Standard DTO (CAN-ID): This ID is passed to the API at connection time, CCP_Connect(TCCPSlaveData).

    Code: Select all

    typedef struct 
    {
          WORD EcuAddress; // Station address (Intel format)
          DWORD IdCRO;      // CAN Id used for CRO packages (29 Bits = MSB set)
          DWORD IdDTO;      // CAN Id used for DTO packages (29 Bits = MSB set)
          bool IntelFormat;
    }TCCPSlaveData;
  • Using dedicated DTOs: This are oher CAN-Ids that the ECU uses for Data-Transmission.
Please verify which DTOs (CAN-IDs) are being sent from the ECU after you start the data transmission. If the ECU is using the standard DTO, than the CAN-ID must be the same as passed on CCP_Connect as IdDTO. If they are different, then you have to use GetDAQListSize with each, so that they are included in the internal filter.
Best regards,
Keneth

lslahrs_
Posts: 11
Joined: Tue 25. Jun 2013, 11:24

Re: CCP_Read on daqlist results in PCAN_ERROR_QRCVEMPTY

Post by lslahrs_ » Wed 26. Jun 2013, 10:13

Hello,

thanks a lot! The ECU uses dedicated DTOs and I did not know about that. I called CCP_GetDAQListSize with the standard CAN-Id, which was obviously wrong. Now - using the daqlist-specific DTO - it works.

Do you know where I can read more about those dedicated/non-dedicated DTOs? I haven't heard anything about them before you mentioned them in this thread.

Thank you very much for your help! Nice support! :)

Best regards

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: CCP_Read on daqlist results in PCAN_ERROR_QRCVEMPTY

Post by K.Wagner » Wed 26. Jun 2013, 10:45

Hello lslahrs_,

glad to see that your problem is solved. There is not too much information about dedicated DTOs. It is described within the ASAM document "Can Calibration Protocol - Version 2.1". It just explain that an ECU can use different Ids (DTOs) for data Acquisition frames.

This information is stored within the configuration file of an ECU (A2L file). In there you can see if (and which) dedicated Ids are being used by an ECU. Maybe you get more information on dedicated DTOs by searching for such files.
Best regards,
Keneth

Post Reply