00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <stdio.h>
00031 #include <string.h>
00032 #include <stdlib.h>
00033 #include <pthread.h>
00034 #include <sys/types.h>
00035 #include <arpa/inet.h>
00036 #include "parser.h"
00037 #include "global.h"
00038 #include "connections.h"
00039 #include "recreate.h"
00040 #include "new_pmu_or_pdc.h"
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 void recreate_cfg_objects(){
00064
00065
00066
00067
00068 pthread_mutex_init(&mutex_file, NULL);
00069 pthread_mutex_init(&mutex_cfg, NULL);
00070 pthread_mutex_init(&mutex_status_change, NULL);
00071 pthread_mutex_init(&mutex_Lower_Layer_Details, NULL);
00072 pthread_mutex_init(&mutex_Upper_Layer_Details, NULL);
00073
00074 CMDSYNC[0] = 0xaa;
00075 CMDSYNC[1] = 0x41;
00076 CMDSYNC[2] = '\0';
00077
00078 CMDCFGSEND[0] = 0x00;
00079 CMDCFGSEND[1] = 0x05;
00080 CMDCFGSEND[2] = '\0';
00081
00082 CMDDATASEND[0] = 0x00;
00083 CMDDATASEND[1] = 0x02;
00084 CMDDATASEND[2] = '\0';
00085
00086 CMDDATAOFF[0] = 0x00;
00087 CMDDATAOFF[1] = 0x01;
00088 CMDDATAOFF[2] = '\0';
00089
00090 DATASYNC[0] = 0xaa;
00091 DATASYNC[1] = 0x01;
00092 DATASYNC[2] = '\0';
00093
00094 CFGSYNC[0] = 0xaa;
00095 CFGSYNC[1] = 0x31;
00096 CFGSYNC[2] = '\0';
00097
00098 int yes =1;
00099
00100
00101
00102 if ((DB_sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
00103
00104 perror("socket");
00105 exit(1);
00106
00107 } else {
00108
00109 printf("DB Socket:Sucessfully created\n");
00110
00111 }
00112 if (setsockopt(DB_sockfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) {
00113 perror("setsockopt");
00114 exit(1);
00115 }
00116
00117 bzero(&DB_Server_addr,sizeof(DB_Server_addr));
00118 DB_Server_addr.sin_family = AF_INET;
00119 DB_Server_addr.sin_port = htons(DBPORT);
00120 DB_Server_addr.sin_addr.s_addr = inet_addr(dbserver_ip);
00121 memset(&(DB_Server_addr.sin_zero),'\0', 8);
00122
00123
00124
00125
00126 static const char filename[] = "cfg.bin";
00127 FILE *file = fopen (filename,"rb");
00128
00129 unsigned char *line,frame_len[2];
00130 unsigned int framesize;
00131 unsigned long fileLen;
00132
00133 if (file != NULL) {
00134
00135
00136 fseek(file, 0, SEEK_END);
00137 fileLen = ftell(file);
00138 fseek(file, 0, SEEK_SET);
00139 printf("FILE LEN LEFT %ld\n",fileLen);
00140 printf("Creating objects for entries in cfg.bin\n");
00141
00142 while (fileLen != 0) {
00143
00144 fseek (file,2 ,SEEK_CUR);
00145 fread(frame_len, sizeof(unsigned char),2, file);
00146 fseek (file,-4 ,SEEK_CUR);
00147
00148 framesize = to_intconvertor(frame_len);
00149 line = malloc(framesize*sizeof(unsigned char));
00150 memset(line,'\0',sizeof(line));
00151
00152 fread(line, sizeof(unsigned char),framesize,file);
00153 init_cfgparser(line);
00154 free(line);
00155 fileLen -= framesize;
00156 }
00157 fclose (file);
00158
00159 } else {
00160 perror (filename);
00161 }
00162
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172 void init_cfgparser(unsigned char st[]){
00173
00174 unsigned char *s;
00175 unsigned int phn,ann,dgn,num_pmu;
00176 int i,j,dgchannels;
00177 struct cfg_frame *cfg;
00178 struct channel_names *cn;
00179
00180
00181
00182 cfg = malloc(sizeof(struct cfg_frame));
00183 if(!cfg) {
00184 fprintf(fp_log,"Not enough memory for cfg\n");
00185 }
00186
00187 s = st;
00188
00189
00190
00191
00192 cfg->framesize = malloc(3*sizeof(unsigned char));
00193 if(!cfg->framesize) {
00194 printf("Not enough memory for cfg->framesize\n");
00195 }
00196
00197
00198 cfg->idcode = malloc(3*sizeof(unsigned char));
00199 if(!cfg->idcode) {
00200 printf("Not enough memory for cfg->framesize\n");
00201 }
00202
00203
00204 cfg->soc = malloc(5*sizeof(unsigned char));
00205 if(!cfg->soc) {
00206 printf("Not enough memory for cfg->soc\n");
00207 }
00208
00209
00210 cfg->fracsec = malloc(5*sizeof(unsigned char));
00211 if(!cfg->fracsec) {
00212 printf("Not enough memory for cfg->fracsec\n");
00213 }
00214
00215
00216 cfg->time_base = malloc(5*sizeof(unsigned char));
00217 if(!cfg->time_base) {
00218 printf("Not enough memory for cfg->time_base\n");
00219 }
00220
00221
00222 cfg->num_pmu = malloc(3*sizeof(unsigned char));
00223 if(!cfg->num_pmu) {
00224 printf("Not enough memory for cfg->num_pmu\n");
00225 }
00226
00227
00228 cfg->data_rate = malloc(3*sizeof(unsigned char));
00229 if(!cfg->data_rate) {
00230 printf("Not enough memory for cfg->data_rate\n");
00231 }
00232
00233
00234 s = s + 2;
00235
00236
00237 copy_cbyc (cfg->framesize,(unsigned char *)s,2);
00238 cfg->framesize[2]='\0';
00239 s = s + 2;
00240
00241
00242 copy_cbyc (cfg->idcode,(unsigned char *)s,2);
00243 cfg->idcode[2]='\0';
00244 int id = to_intconvertor(cfg->idcode);
00245 printf("ID Code %d\n",id);
00246 s = s + 2;
00247
00248
00249 copy_cbyc (cfg->soc,(unsigned char *)s,4);
00250 cfg->soc[4]='\0';
00251 s = s + 4;
00252
00253
00254 copy_cbyc (cfg->fracsec,(unsigned char *)s,4);
00255 cfg->fracsec[4]='\0';
00256 s = s + 4;
00257
00258
00259 copy_cbyc (cfg->time_base,(unsigned char *)s,4);
00260 cfg->time_base[4]='\0';
00261 s = s + 4;
00262
00263
00264 copy_cbyc (cfg->num_pmu,(unsigned char *)s,2);
00265 cfg->num_pmu[2]='\0';
00266 s = s + 2;
00267
00268 num_pmu = to_intconvertor(cfg->num_pmu);
00269 printf("No of PMU %d\n",num_pmu);
00270 fprintf(fp_log,"INT No of PMU %d\n",num_pmu);
00271
00272
00273 cfg->pmu = malloc(num_pmu* sizeof(struct for_each_pmu *));
00274 if(!cfg->pmu) {
00275 printf("Not enough memory pmu[][]\n");
00276 exit(1);
00277 }
00278
00279 for (i = 0; i < num_pmu; i++) {
00280 cfg->pmu[i] = malloc(sizeof(struct for_each_pmu));
00281 }
00282
00283 j = 0;
00284
00286 while(j<num_pmu) {
00287
00288
00289 cfg->pmu[j]->stn = malloc(17*sizeof(unsigned char));
00290 if(!cfg->pmu[j]->stn) {
00291 printf("Not enough memory cfg->pmu[j]->stn\n");
00292 exit(1);
00293 }
00294
00295
00296 cfg->pmu[j]->idcode = malloc(3*sizeof(unsigned char));
00297 if(!cfg->pmu[j]->idcode) {
00298 printf("Not enough memory cfg->pmu[j]->idcode\n");
00299 exit(1);
00300 }
00301
00302
00303 cfg->pmu[j]->data_format = malloc(3*sizeof(unsigned char));
00304 if(!cfg->pmu[j]->data_format) {
00305 printf("Not enough memory cfg->pmu[j]->data_format\n");
00306 exit(1);
00307 }
00308
00309
00310 cfg->pmu[j]->phnmr = malloc(3*sizeof(unsigned char));
00311 if(!cfg->pmu[j]->phnmr) {
00312 printf("Not enough memory cfg->pmu[j]->phnmr\n");
00313 exit(1);
00314 }
00315
00316
00317 cfg->pmu[j]->annmr = malloc(3*sizeof(unsigned char));
00318 if(!cfg->pmu[j]->annmr) {
00319 printf("Not enough memory cfg->pmu[j]->annmr\n");
00320 exit(1);
00321 }
00322
00323
00324 cfg->pmu[j]->dgnmr = malloc(3*sizeof(unsigned char));
00325 if(!cfg->pmu[j]->dgnmr) {
00326 printf("Not enough memory cfg->pmu[j]->dgnmr\n");
00327 exit(1);
00328 }
00329
00330
00331 cfg->pmu[j]->fnom = malloc(3*sizeof(unsigned char));
00332 if(!cfg->pmu[j]->fnom) {
00333 printf("Not enough memory cfg->pmu[j]->fnom\n");
00334 exit(1);
00335 }
00336
00337
00338 cfg->pmu[j]->cfg_cnt = malloc(3*sizeof(unsigned char));
00339 if(!cfg->pmu[j]->cfg_cnt) {
00340 printf("Not enough memory cfg->pmu[j]->cfg_cnt\n");
00341 exit(1);
00342 }
00343
00344
00345
00346 copy_cbyc (cfg->pmu[j]->stn,(unsigned char *)s,16);
00347 cfg->pmu[j]->stn[16]='\0';
00348 s = s + 16;
00349
00350
00351 copy_cbyc (cfg->pmu[j]->idcode,(unsigned char *)s,2);
00352 cfg->pmu[j]->idcode[2]='\0';
00353 s = s + 2;
00354
00355
00356 copy_cbyc (cfg->pmu[j]->data_format,(unsigned char *)s,2);
00357 cfg->pmu[j]->data_format[2]='\0';
00358 s = s + 2;
00359
00360
00361 unsigned char hex = cfg->pmu[j]->data_format[1];
00362 hex <<= 4;
00363
00364
00365 cfg->pmu[j]->fmt = malloc(sizeof(struct format));
00366 if((hex & 0x80) == 0x80) cfg->pmu[j]->fmt->freq = '1'; else cfg->pmu[j]->fmt->freq = '0';
00367 if((hex & 0x40) == 0x40 ) cfg->pmu[j]->fmt->analog = '1'; else cfg->pmu[j]->fmt->analog = '0';
00368 if((hex & 0x20) == 0x20) cfg->pmu[j]->fmt->phasor = '1'; else cfg->pmu[j]->fmt->phasor = '0';
00369 if((hex & 0x10) == 0x10) cfg->pmu[j]->fmt->polar = '1'; else cfg->pmu[j]->fmt->polar = '0';
00370
00371
00372 copy_cbyc (cfg->pmu[j]->phnmr,(unsigned char *)s,2);
00373 cfg->pmu[j]->phnmr[2]='\0';
00374 s = s + 2;
00375 phn = to_intconvertor(cfg->pmu[j]->phnmr);
00376
00377
00378 copy_cbyc (cfg->pmu[j]->annmr,(unsigned char *)s,2);
00379 cfg->pmu[j]->annmr[2]='\0';
00380 s = s + 2;
00381 ann = to_intconvertor(cfg->pmu[j]->annmr);
00382
00383
00384 copy_cbyc (cfg->pmu[j]->dgnmr,(unsigned char *)s,2);
00385 cfg->pmu[j]->dgnmr[2] = '\0';
00386 s = s + 2;
00387 dgn = to_intconvertor(cfg->pmu[j]->dgnmr);
00388 printf("Phasor %d Analogs %d Digitals %d\n",phn,ann,dgn);
00389
00390 cn = malloc(sizeof(struct channel_names));
00391 if(!cn) {
00392 printf("Not enough memory cn\n");
00393 exit(1);
00394 }
00395 cn->first = NULL;
00396
00398 if(phn != 0){
00399 cn->phnames = malloc(phn*sizeof(unsigned char*));
00400 if(!cn->phnames) {
00401 printf("Not enough memory cfg->pmu[j]->cn->phnames[][]\n");
00402 exit(1);
00403 }
00404
00405 for (i = 0; i < phn; i++) {
00406
00407 cn->phnames[i] = malloc(17*sizeof(unsigned char));
00408
00409 }
00410
00411 i = 0;
00412 while(i<phn){
00413 copy_cbyc (cn->phnames[i],(unsigned char *)s,16);
00414 cn->phnames[i][16] = '\0';
00415 printf("Phnames %s\n",cn->phnames[i]);
00416 s = s + 16;
00417 i++;
00418
00419 }
00420 }
00421
00422
00423 if(ann!=0){
00424 cn->angnames = malloc(ann*sizeof(unsigned char*));
00425 if(!cn->angnames) {
00426 printf("Not enough memory cfg->pmu[j]->cn->phnames[][]\n");
00427 exit(1);
00428 }
00429
00430 for (i = 0; i < ann; i++) {
00431
00432 cn->angnames[i] = malloc(17*sizeof(unsigned char));
00433
00434 }
00435
00436
00437 i=0;
00438 while(i<ann){
00439 copy_cbyc (cn->angnames[i],(unsigned char *)s,16);
00440 cn->angnames[i][16]='\0';
00441 printf("ANGNAMES %s\n",cn->angnames[i]);
00442 s =s + 16;
00443 i++;
00444 }
00445 }
00446
00447 struct dgnames *q;
00448 i = 0;
00449 while(i<dgn) {
00450
00451 struct dgnames *temp1 = malloc(sizeof(struct dgnames));
00452
00453 temp1->dgn = malloc(16*sizeof(unsigned char *));
00454
00455 if(!temp1->dgn) {
00456 printf("Not enough memory temp1->dgn\n");
00457 exit(1);
00458 }
00459
00460 for (i = 0; i < 16; i++) {
00461 temp1->dgn[i] = malloc(17*sizeof(unsigned char));
00462
00463 }
00464
00465 temp1->dg_next = NULL;
00466
00467 for(dgchannels=0;dgchannels<16;dgchannels++){
00468
00469 copy_cbyc (temp1->dgn[dgchannels],(unsigned char *)s,16);
00470 temp1->dgn[dgchannels][16]='\0';
00471 s += 16;
00472 printf("%s\n",temp1->dgn[dgchannels]);
00473
00474 }
00475
00476 if(cn->first == NULL){
00477 cn->first = q = temp1;
00478 } else {
00479 while(q->dg_next!=NULL){
00480 q = q->dg_next;
00481 }
00482 q->dg_next = temp1;
00483 }
00484 i++;
00485 }
00486
00487 cfg->pmu[j]->cnext = cn;
00488
00489
00491 if(phn != 0){
00492
00493 cfg->pmu[j]->phunit = malloc(phn*sizeof(unsigned char*));
00494 if(!cfg->pmu[j]->phunit) {
00495 printf("Not enough memory cfg->pmu[j]->phunit[][]\n");
00496 exit(1);
00497 }
00498
00499 for (i = 0; i < phn; i++) {
00500 cfg->pmu[j]->phunit[i] = malloc(5*sizeof(unsigned char));
00501 }
00502
00503 i = 0;
00504 while(i<phn){
00505 copy_cbyc (cfg->pmu[j]->phunit[i],(unsigned char *)s,4);
00506 cfg->pmu[j]->phunit[i][4] = '\0';
00507 s = s + 4;
00508 i++;
00509 }
00510 }
00511
00512
00513 if(ann != 0){
00514
00515 cfg->pmu[j]->anunit = malloc(ann*sizeof(unsigned char*));
00516 if(!cfg->pmu[j]->anunit) {
00517 printf("Not enough memory cfg->pmu[j]->anunit[][]\n");
00518 exit(1);
00519 }
00520
00521 for (i = 0; i < ann; i++) {
00522 cfg->pmu[j]->anunit[i] = malloc(5*sizeof(unsigned char));
00523
00524 }
00525
00526 i = 0;
00527 while(i<ann){
00528 copy_cbyc (cfg->pmu[j]->anunit[i],(unsigned char *)s,4);
00529 cfg->pmu[j]->anunit[i][4] = '\0';
00530 s = s + 4;
00531 i++;
00532 }
00533
00534 }
00535
00536 if(dgn != 0){
00537
00538 cfg->pmu[j]->dgunit = malloc(dgn*sizeof(unsigned char*));
00539 if(!cfg->pmu[j]->dgunit) {
00540 printf("Not enough memory cfg->pmu[j]->dgunit[][]\n");
00541 exit(1);
00542 }
00543
00544 for (i = 0; i < dgn; i++) {
00545 cfg->pmu[j]->dgunit[i] = malloc(5*sizeof(unsigned char));
00546
00547 }
00548
00549 i = 0;
00550 while(i<dgn){
00551
00552 copy_cbyc (cfg->pmu[j]->dgunit[i],(unsigned char *)s,4);
00553 cfg->pmu[j]->dgunit[i][4] = '\0';
00554 s = s + 4;
00555 i++;
00556 }
00557 }
00558
00559
00560 copy_cbyc (cfg->pmu[j]->fnom,(unsigned char *)s,2);
00561 cfg->pmu[j]->fnom[2]='\0';
00562 s = s + 2;
00563
00564 copy_cbyc (cfg->pmu[j]->cfg_cnt,(unsigned char *)s,2);
00565 cfg->pmu[j]->cfg_cnt[2] = '\0';
00566 s = s + 2;
00567 j++;
00568 }
00569
00570
00571 copy_cbyc (cfg->data_rate,(unsigned char *)s,2);
00572 cfg->data_rate[2] = '\0';
00573 cfg->cfgnext = NULL;
00574
00575
00576 if (cfgfirst == NULL) {
00577 cfgfirst = cfg;
00578 } else {
00579
00580 struct cfg_frame *t=cfgfirst;
00581 while(t->cfgnext != NULL){
00582 t = t->cfgnext;
00583 }
00584 t->cfgnext = cfg;
00585 }
00586
00587 }
00588
00589
00590
00591
00592
00593
00594 void recreate_Connection_Table() {
00595
00596 FILE *f;
00597 char line[40],*ip,*port,*protocol,*id;
00598 int err;
00599
00600
00601 pthread_attr_t attr;
00602 pthread_attr_init(&attr);
00603 if((err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))) {
00604
00605 perror(strerror(err));
00606 exit(1);
00607
00608 }
00609 if((err = pthread_attr_setschedpolicy(&attr,SCHED_FIFO))) {
00610
00611 perror(strerror(err));
00612 exit(1);
00613 }
00614
00615 f = fopen("ipaddress.txt","r");
00616 if (f != NULL) {
00617
00618 printf("#### CONNECTION TABLE OF SOURCE DEVICES ####\n");
00619 printf("-----------------------------------------------------------------\n");
00620 printf("| PMU ID | Lower IP | Port | Protocol |\n");
00621 printf("-----------------------------------------------------------------\n");
00622 while (fgets (line, 40,f) != NULL) {
00623
00624
00625 id = strtok (line," ");
00626 ip = strtok (NULL," ");
00627 port = strtok (NULL," ");
00628 protocol = strtok (NULL," ");
00629 *(protocol+3) = '\0';
00630 printf("|\t%d\t|%s\t|\t%d\t|\t%s\t|\n",atoi(id),ip,atoi(port),protocol);
00631
00632 struct Lower_Layer_Details *temp_pmu;
00633 temp_pmu = malloc(sizeof(struct Lower_Layer_Details));
00634 if(!temp_pmu) {
00635
00636 printf("Not enough memory temp_pmu\n");
00637 exit(1);
00638
00639 }
00640
00641 temp_pmu->pmuid = atoi(id);
00642 strcpy(temp_pmu->ip,ip);
00643 temp_pmu->port = atoi(port);
00644 strcpy(temp_pmu->protocol,protocol);
00645 temp_pmu->data_transmission_off = 0;
00646 temp_pmu->pmu_remove = 0;
00647 temp_pmu->request_cfg_frame = 0;
00648 temp_pmu->next = NULL;
00649 temp_pmu->prev = NULL;
00650
00651 if(!strncasecmp(temp_pmu->protocol,"UDP",3)) {
00652
00653 recreate_udp_connections(temp_pmu);
00654 }
00655
00656 if(!strncasecmp(temp_pmu->protocol,"TCP",3)) {
00657
00658 recreate_tcp_connections(temp_pmu);
00659 }
00660
00661 memset(line,'\0',40);
00662 }
00663 printf("-----------------------------------------------------------------\n");
00664 fclose(f);
00665
00666 } else {
00667
00668 perror("ipaddress.txt");
00669 }
00670
00671 f = fopen("upperpdc_ip.txt","r");
00672 if (f != NULL) {
00673
00674 printf("#### CONNECTION TABLE OF DESTINATION DEVICES ####\n");
00675 printf("-------------------------------------------------\n");
00676 printf("| Upper IP | Port | Protocol |\n");
00677 printf("-------------------------------------------------\n");
00678 while(fgets (line, 40,f) != NULL) {
00679
00680
00681 ip = strtok (line," ");
00682 port = strtok (NULL," ");
00683 protocol = strtok (NULL," ");
00684 *(protocol+3) = '\0';
00685 printf("|%s\t|\t%d\t|\t%s\t|\n",ip,atoi(port),protocol);
00686
00687 struct Upper_Layer_Details *temp_pdc;
00688 temp_pdc = malloc(sizeof(struct Upper_Layer_Details));
00689 if(!temp_pdc) {
00690
00691 printf("Not enough memory temp_pmu\n");
00692 exit(1);
00693
00694 }
00695
00696 strcpy(temp_pdc->ip,ip);
00697 temp_pdc->port = atoi(port);
00698 strcpy(temp_pdc->protocol,protocol);
00699
00700 bzero(&temp_pdc->pdc_addr,sizeof(temp_pdc->pdc_addr));
00701 temp_pdc->pdc_addr.sin_family = AF_INET;
00702 temp_pdc->pdc_addr.sin_addr.s_addr = inet_addr(temp_pdc->ip);
00703 temp_pdc->pdc_addr.sin_port = htons(temp_pdc->port);
00704
00705 memset(&(temp_pdc->pdc_addr.sin_zero), '\0', 8);
00706 temp_pdc->config_change = 0;
00707 temp_pdc->UL_upper_pdc_cfgsent = 0;
00708 temp_pdc->UL_data_transmission_off = 1;
00709 temp_pdc->address_set = 0;
00710 temp_pdc->tcpup = 1;
00711
00712 if(ULfirst == NULL) {
00713
00714 ULfirst = temp_pdc;
00715 temp_pdc->prev = NULL;
00716
00717 } else {
00718
00719 ULlast->next = temp_pdc;
00720 temp_pdc->prev = ULlast;
00721
00722 }
00723
00724 ULlast = temp_pdc;
00725 temp_pdc->next = NULL;
00726 memset(line,'\0',40);
00727 }
00728 printf("-------------------------------------------------\n");
00729 fclose(f);
00730
00731 } else {
00732
00733 perror("upperpdc_ip.txt");
00734 }
00735 }
00736
00737
00738
00739
00740
00741 void recreate_udp_connections(struct Lower_Layer_Details *t11) {
00742
00743 int err;
00744 pthread_attr_t attr;
00745 pthread_attr_init(&attr);
00746 if((err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))) {
00747
00748 perror(strerror(err));
00749 exit(1);
00750
00751 }
00752 if((err = pthread_attr_setschedpolicy(&attr,SCHED_FIFO))) {
00753
00754 perror(strerror(err));
00755 exit(1);
00756 }
00757
00758 pthread_t t;
00759
00760 if(pthread_create(&t,&attr,connect_pmu_udp,(void *)t11)) {
00761
00762 perror(strerror(err));
00763 exit(1);
00764 }
00765 }
00766
00767
00768
00769
00770
00771 void recreate_tcp_connections(struct Lower_Layer_Details *t12) {
00772
00773 int err;
00774 pthread_attr_t attr;
00775 pthread_attr_init(&attr);
00776 if((err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))) {
00777
00778 perror(strerror(err));
00779 exit(1);
00780
00781 }
00782 if((err = pthread_attr_setschedpolicy(&attr,SCHED_FIFO))) {
00783
00784 perror(strerror(err));
00785 exit(1);
00786 }
00787
00788 pthread_t t;
00789
00790 if(pthread_create(&t,&attr,connect_pmu_tcp,(void *)t12)) {
00791 perror(strerror(err));
00792 exit(1);
00793 }
00794 }