can't read any message from the bus but the CAN analyzier can capture the reply message

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
wuchangzheng
Posts: 1
Joined: Fri 24. Sep 2021, 16:58

can't read any message from the bus but the CAN analyzier can capture the reply message

Post by wuchangzheng » Fri 24. Sep 2021, 17:19

Hi.

I have send my CAN msg through a thread and receive the reply msg through another thread. But i can't read any message from the bus. I have used a CAN analyzier, the analyzier tool can capture the reply message.

My code just as follows:

Code: Select all


void *receive_func(void *param) //the receive thraed
{
    TPCANMsgFD get;
   
    TPCANStatus Status;

    while (true)
    {
        if ((Status = CAN_ReadFD(PCAN_PCIBUS1, &get, NULL)) == PCAN_ERROR_OK)
        {
            printf("  - R ID:%4x LEN:%1x DATA:%02x %02x %02x %02x %02x %02x\n",
                   (int)get.ID, (int)get.DLC, (int)get.DATA[0],
                   (int)get.DATA[1], (int)get.DATA[2],
                   (int)get.DATA[3], (int)get.DATA[4],
                   (int)get.DATA[5]);
        }
        if (Status == PCAN_ERROR_QRCVEMPTY)
        {
            printf("CAN_FDRead(%xh) failure 0x%x\n", Device, (int)Status);

        }
    }
}
Waiting for your help

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1251
Joined: Fri 10. Sep 2010, 19:34

Re: can't read any message from the bus but the CAN analyzier can capture the reply message

Post by U.Wilhelm » Mon 27. Sep 2021, 10:34

We do not know your environment, setup etc. so how should we help? Please run PCAN-View and check if your receive CAN Frames on your CAN-Network.
Also you must check the MsgType after Receiving - it also could be a Staus CAN Frame - then the Data is no real CAN data.
But without more deteiled information - we could not help. Please, always test our sample code first. Check if it works, and if this happened - you could start to develop your own application.
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

Post Reply