Commit d9ba94d3 authored by wangdong's avatar wangdong

尝试把Python返回的数据格式化为结构体

parent 41cfeb6c
......@@ -182,6 +182,8 @@ int rr_dl_run(module_id_t Mod_id,
return n_rbg_sched;
for (; !rbgalloc_mask[rbg]; rbg++) /* fast-forward */ ;
} else {
rnti_t rnti = UE_RNTI(Mod_id, UE_id);
subframe_t.rnti[UE_id] = rnti;
if (UE_info->UE_template[CC_id][UE_id].dl_buffer_total > 0) {//获取该dl的buffer,如果没Buffer就后面跳过了!!!
subframe_t.total_buffer[UE_id]=UE_info->UE_template[CC_id][UE_id].dl_buffer_total;
*cur_UE = UE_id;
......@@ -193,8 +195,24 @@ skip_ue:
UE_id = next_ue_list_looped(UE_list, UE_id);
} while (UE_id != *start_ue);
*cur_UE = -1; // mark end,巧妙的Hack!
if (UE_sched.head < 0)
return n_rbg_sched; // no UE has a transmission
if (UE_sched.head < 0){
cJSON *data_t = NULL;
// data = soctet_to_py(&subframe, RC.sockfd);sss
char *json_data = NULL;
char buf[MAXLINE];
int n = 0;
memset(buf, 0, MAXLINE);
cJSON *json_to_sent = struct_to_json(&subframe_t);
json_data = cJSON_Print(json_to_sent);
//printf("[SOCKET]Brfore: %s\n", json_data);
n = strlen(json_data);
write(RC.sockfd, json_data, n);
read(RC.sockfd, buf, MAXLINE);
cJSON *res = cJSON_Parse(buf);
Subframe *temp =NULL;
temp = json_to_struct(res);
return n_rbg_sched;
}// no UE has a transmission
// after allocating retransmissions: pre-allocate CCE, compute number of
// requested RBGs
// 计算每个调度帧内UE所需的RB
......@@ -204,7 +222,6 @@ skip_ue:
while (*cur_UE >= 0 && max_num_ue > 0) {
const int UE_id = *cur_UE;
cur_UE = &UE_sched.next[UE_id]; // go to next
rnti_t rnti = UE_RNTI(Mod_id, UE_id);
const uint8_t cqi = UE_info->UE_sched_ctrl[UE_id].dl_cqi[CC_id];
const int idx = CCE_try_allocate_dlsch(Mod_id, CC_id, subframe, UE_id, cqi);
......@@ -218,7 +235,6 @@ skip_ue:
const uint32_t B = UE_info->UE_template[CC_id][UE_id].dl_buffer_total;
rb_required[UE_id] = find_nb_rb_DL(mcs, B, n_rbg_sched * RBGsize, RBGsize);
subframe_t.nb_rb_max = n_rbg_sched * RBGsize;
subframe_t.rnti[UE_id] = rnti;
subframe_t.ammount[UE_id] = rb_required[UE_id];
max_num_ue--;
}
......@@ -233,11 +249,13 @@ skip_ue:
memset(buf, 0, MAXLINE);
cJSON *json_to_sent = struct_to_json(&subframe_t);
json_data = cJSON_Print(json_to_sent);
printf("[SOCKET]Brfore: %s\n", json_data);
//printf("[SOCKET]Brfore: %s\n", json_data);
n = strlen(json_data);
write(RC.sockfd, json_data, n);
read(RC.sockfd, buf, MAXLINE);
cJSON *res = cJSON_Parse(buf);
Subframe *temp =NULL;
temp = json_to_struct(res);
//printf("[SOCKET]After: %s\n", cJSON_Print(res));
//json_data = cJSON_Print(struct_to_json(&subframe));
//data = cJSON_Parse(json_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment