lib/uwb_ccp/src/uwb_ccp.c
/**
 * @fn ccp_postprocess(struct dpl_event * ev)
 * @brief API that serves as a place holder for timescale processing and by default is creates json string for the event.
 *
 * @param ev   pointer to dpl_events.
 * @return void
 */
@fn ccp_postprocess(struct dpl_event * ev)
@brief API that serves as a place holder for timescale processing and by default is creates json string for the event.

@param ev   pointer to dpl_events.
@return void
@fn ccp_postprocess ( struct dpl_event * ev ) @brief API that serves as a place holder for timescale processing and by default is creates json string for the event . @param ev pointer to dpl_events . @return void
static void
ccp_postprocess(struct dpl_event * ev)
{
    assert(ev != NULL);
    assert(dpl_event_get_arg(ev));
    struct uwb_ccp_instance * ccp = (struct uwb_ccp_instance *) dpl_event_get_arg(ev);
    uwb_ccp_frame_t * previous_frame = ccp->frames[(uint16_t)(ccp->idx-1)%ccp->nframes];
    uwb_ccp_frame_t * frame = ccp->frames[(ccp->idx)%ccp->nframes];
    uint64_t delta = 0;
    if (ccp->config.role == CCP_ROLE_MASTER){
        delta = (frame->transmission_timestamp.timestamp - previous_frame->transmission_timestamp.timestamp);
    } else {
        delta = (frame->reception_timestamp - previous_frame->reception_timestamp);
    }
    delta = delta & ((uint64_t)1<<63)?delta & 0xFFFFFFFFFF :delta;
    dpl_float64_t carrier_integrator = uwb_calc_clock_offset_ratio(ccp->dev_inst, frame->carrier_integrator, UWB_CR_CARRIER_INTEGRATOR);
    ccp_json_t json = {
        .utime = ccp->master_epoch.timestamp,
        .seq = frame->seq_num,
        .ccp = {DPL_FLOAT64_U64_TO_F64(frame->transmission_timestamp.timestamp),
                DPL_FLOAT64_U64_TO_F64(delta)},
        .ppm = DPL_FLOAT64_MUL(carrier_integrator, DPL_FLOAT64_INIT(1e6l))
    };
    ccp_json_write_uint64(&json);
#ifdef __KERNEL__
    size_t n = strlen(json.iobuf);
    json.iobuf[n]='\n';
    json.iobuf[n+1]='\0';
    ccp_chrdev_output(ccp->dev_inst->idx, json.iobuf, n+1);
#else
#ifdef UWB_CCP_VERBOSE
    printf("%s\n",json.iobuf);
#endif
#endif
}
static void ccp_postprocess ( struct dpl_event * ev ) { assert ( ev != NULL ) ; assert ( dpl_event_get_arg ( ev ) ) ; struct uwb_ccp_instance * ccp = ( struct uwb_ccp_instance * ) dpl_event_get_arg ( ev ) ; uwb_ccp_frame_t * previous_frame = ccp -> frames [ ( uint16_t ) ( ccp -> idx - 1 ) % ccp -> nframes ] ; uwb_ccp_frame_t * frame = ccp -> frames [ ( ccp -> idx ) % ccp -> nframes ] ; uint64_t delta = 0 ; if ( ccp -> config . role == CCP_ROLE_MASTER ) { delta = ( frame -> transmission_timestamp . timestamp - previous_frame -> transmission_timestamp . timestamp ) ; } else { delta = ( frame -> reception_timestamp - previous_frame -> reception_timestamp ) ; } delta = delta & ( ( uint64_t ) 1 << 63 ) ? delta & 0xFFFFFFFFFF : delta ; dpl_float64_t carrier_integrator = uwb_calc_clock_offset_ratio ( ccp -> dev_inst , frame -> carrier_integrator , UWB_CR_CARRIER_INTEGRATOR ) ; ccp_json_t json = { . utime = ccp -> master_epoch . timestamp , . seq = frame -> seq_num , . ccp = { DPL_FLOAT64_U64_TO_F64 ( frame -> transmission_timestamp . timestamp ) , DPL_FLOAT64_U64_TO_F64 ( delta ) } , . ppm = DPL_FLOAT64_MUL ( carrier_integrator , DPL_FLOAT64_INIT ( 1e6l ) ) } ; ccp_json_write_uint64 ( & json ) ; #ifdef __KERNEL__ size_t n = strlen ( json . iobuf ) ; json . iobuf [ n ] = ' \n ' ; json . iobuf [ n + 1 ] = ' \0 ' ; ccp_chrdev_output ( ccp -> dev_inst -> idx , json . iobuf , n + 1 ) ; #else #ifdef UWB_CCP_VERBOSE printf ( " \n " , json . iobuf ) ; #endif #endif }
@fn ccp_postprocess(struct dpl_event * ev)
 @brief API that serves as a place holder for timescale processing and by default is creates json string for the event.
@fn ccp_postprocess ( struct dpl_event * ev ) @brief API that serves as a place holder for timescale processing and by default is creates json string for the event .