Position2GO C ComLib get Target_Info_t data

Announcements

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
user19
Level 1
Level 1
First reply posted First question asked Welcome!

Hello,

I need some help with the Position2Go C Comlib. I want to read the data from Target_Info_t for example the radius.

I included EndpointTargetDetection.h in extract_raw_data.c.

I registered the callback with ep_targetdetect_set_callback_target_processing() and called ep_targetdetect_get_targets() to get the targets.

The callback funtion which I call with ep_targetdetect_set_callback_target_processing() has the parameters of Callback_Target_Processing_t. In the function I want to read out the struct Target_Info_t and print the data.
 
I read the documentation and basically imitated the way it was done with the ADC samples.
 
But unfortunately it doesn't work.
Am I doing something wrong?

May somebody help me with this?

0 Likes
1 Solution
Honey_D
Moderator
Moderator
Moderator
5 comments on blog 50 likes received 250 replies posted

Hello @user19 ,

The code you developed is giving a endpoint compatibility error, so while modifying the Commlib files you will need to do appropriate updates in the firmware as well to make it compatible. Please refer to the Radar Host Communication Library document from /IFX_D2GL-HW-SW_V1.0.0/Firmware_Software/Communication%20Library/ComLib_C_Interface/documentation/html/index.html for more detailed explanation. 

Also the information you want to display will only be possible after making some appropriate changes in the endpoint files.

In case to execute the given Commlib file we would suggest you to refer the following threads on the similar topic: https://community.infineon.com/t5/Radar-sensor/Position2Go-Compile-extract-raw-data-c-example/td-p/2... .

Build and run the C Commlib Interface example code for Position2Go Demo board using the Cmake List file provided in the above thread.

Hope this make things clear!

Best Regards

Honey

View solution in original post

0 Likes
3 Replies
Honey_D
Moderator
Moderator
Moderator
5 comments on blog 50 likes received 250 replies posted

Hello @user19 ,

Can you please share the code you have build and also the error log you are getting? 

Meanwhile please refer to the code documentation from Position2Go kit  : /IFX_P2G-HW-SW_V1.0.4/Documentation/FW_API/html/index.html

Best Regards

Honey

0 Likes
user19
Level 1
Level 1
First reply posted First question asked Welcome!

Sure I can share my code. I don't get any errors when I run extract_raw_data.c. I use Visual Studio Code and the ComLib C interface.

 

#include <stdio.h>
#include <string.h>
#include "Protocol.h"
#include "COMPort.h"
#include "EndpointRadarBase.h"
#include "EndpointTargetDetection.h"

#define AUTOMATIC_DATA_FRAME_TRIGGER (1)        // define if automatic trigger is active or not

#define AUTOMATIC_DATA_TRIGER_TIME_US (1000000) // get ADC data each 1ms in automatic trigger mode



void received_target_data(void* context,
                                            int32_t protocol_handle,
                                            uint8_t endpoint,
                                            const Target_Info_t* targets,
                                            uint8_t num_targets)
{
    printf("f%", targets->radius);
}

// called every time ep_radar_base_get_frame_data method is called to return measured time domain signals
void received_frame_data(void* context,
                        int32_t protocol_handle,
                        uint8_t endpoint,
                        const Frame_Info_t* frame_info)
{
    // Print the sampled data which can be found in frame_info->sample_data
    for (uint32_t i = 0; i < frame_info->num_samples_per_chirp; i++)
    {
        printf("ADC sample %d: %f\n", i, frame_info->sample_data[i]);
    }
}

int radar_auto_connect(void)
{
    int radar_handle = 0;
    int num_of_ports = 0;
    char comp_port_list[256];
    char* comport;
    const char *delim = ";";

    //----------------------------------------------------------------------------

    num_of_ports = com_get_port_list(comp_port_list, (size_t)256);

    if (num_of_ports == 0)
    {
        return -1;
    }
    else
    {
        comport = strtok(comp_port_list, delim);

        while (num_of_ports > 0)
        {
            num_of_ports--;

            // open COM port
            radar_handle = protocol_connect(comport);

            if (radar_handle >= 0)
            {
                break;
            }

            comport = strtok(NULL, delim);
        }

        return radar_handle;
    }

}

int main(void)
{
    int res = -1;
    int protocolHandle = 0;
    int endpointRadarBase = 0;

    // open COM port
    protocolHandle = radar_auto_connect();

    // get endpoint ids
    if (protocolHandle >= 0)
    {
        for (int i = 1; i <= protocol_get_num_endpoints(protocolHandle); ++i) {
            // current endpoint is radar base endpoint
            if (ep_radar_base_is_compatible_endpoint(protocolHandle, i) == 0) {
                endpointRadarBase = i;
                continue;
            }
        }
    }


    if (endpointRadarBase >= 0)
    {
        // register call back functions for adc data
        //ep_radar_base_set_callback_data_frame(received_frame_data, NULL);
        ep_targetdetect_set_callback_target_processing(received_target_data, NULL);

        // enable/disable automatic trigger
        if (AUTOMATIC_DATA_FRAME_TRIGGER)
        {
            res = ep_radar_base_set_automatic_frame_trigger(protocolHandle,
                                                            endpointRadarBase,
                                                            AUTOMATIC_DATA_TRIGER_TIME_US);
        }
        else
        {
            res = ep_radar_base_set_automatic_frame_trigger(protocolHandle,
                                                            endpointRadarBase,
                                                            0);
        }

        while (1)
        {
            // get raw data
            //res = ep_radar_base_get_frame_data(protocolHandle, endpointRadarBase, 1);
            res = ep_targetdetect_get_targets(protocolHandle, endpointRadarBase);
        }
    }

    return res;
}
0 Likes
Honey_D
Moderator
Moderator
Moderator
5 comments on blog 50 likes received 250 replies posted

Hello @user19 ,

The code you developed is giving a endpoint compatibility error, so while modifying the Commlib files you will need to do appropriate updates in the firmware as well to make it compatible. Please refer to the Radar Host Communication Library document from /IFX_D2GL-HW-SW_V1.0.0/Firmware_Software/Communication%20Library/ComLib_C_Interface/documentation/html/index.html for more detailed explanation. 

Also the information you want to display will only be possible after making some appropriate changes in the endpoint files.

In case to execute the given Commlib file we would suggest you to refer the following threads on the similar topic: https://community.infineon.com/t5/Radar-sensor/Position2Go-Compile-extract-raw-data-c-example/td-p/2... .

Build and run the C Commlib Interface example code for Position2Go Demo board using the Cmake List file provided in the above thread.

Hope this make things clear!

Best Regards

Honey

0 Likes