Skip to content

Commit

Permalink
Fixed max recursion issue, fixed sleep function to support ms
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardobonati committed Mar 12, 2024
1 parent 6ba7425 commit aab4464
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/du_app/bs_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ void handleTimer(float* timer, uint32_t* ric_req_id) {

// start thread
report_data_nrt_ric = 1;
if (pthread_create(&thread, NULL, periodicDataReport, (void *) t_args) != 0) {
if (pthread_create(&thread, NULL, periodicDataReportThread, (void *) t_args) != 0) {
printf("Error creating thread\n");
}

printf("periodicDataReport thread created successfully\n");
}


// function to periodically report data
void *periodicDataReport(void* arg) {
void *periodicDataReportThread(void* arg) {

thread_args *t_args = (thread_args*) arg;

Expand All @@ -46,27 +45,28 @@ void *periodicDataReport(void* arg) {
uint32_t* ric_req_id = t_args->ric_req_id;
uint32_t ric_req_id_deref = ric_req_id[0];
printf("ricReqId %" PRIu32 "\n", ric_req_id_deref);


while (report_data_nrt_ric) {
periodicDataReport(ric_req_id_deref);
usleep(timer_deref * 1000000);
}
}


// function to periodically report data
void periodicDataReport(uint32_t ric_req_id_deref) {

if (DEBUG) {
// debug
printf("Debug mode\n");
char *payload = "0,1,2,3,4,5\n1,6,7,8,9,10\n2,11,12,13,14,15";

// to send timer as payload
//char *payload = NULL;
//asprintf(&payload, "%g", timer_deref);
char* payload = NULL;
payload = (char*) "0,1,2,3,4,5\n1,6,7,8,9,10\n2,11,12,13,14,15";

BuildAndSendRicIndicationReport(payload, strlen(payload), ric_req_id_deref);
}
else {
sendMetricsXapp(ric_req_id_deref);
}

sleep(timer_deref);

if (report_data_nrt_ric) {
periodicDataReport((void*) t_args);
}
}


Expand Down
3 changes: 2 additions & 1 deletion src/du_app/bs_connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ typedef struct {
} thread_args;

void handleTimer(float* timer, uint32_t* ric_req_id);
void *periodicDataReport(void* arg);
void *periodicDataReportThread(void* arg);
void periodicDataReport(uint32_t ric_req_id_deref);
void log_message(char* message, char* message_type, int len);
void stop_data_reporting_nrt_ric(void) ;

Expand Down

0 comments on commit aab4464

Please sign in to comment.