
    bro_fist_t packet[BUFFER_SIZE];

    for (i = 1; i < block->nin; i++) {
        bro_encode_sci_datablock(&packet[i-1], block->inptr[i]);
    };

    printf ("Data for first block: %i, %i, %.2f\n", packet[0].port, packet[0].operation, packet[0].data);

    rc = send(block->inptr[0][0], packet, sizeof(bro_fist_t) * BUFFER_SIZE, 0);

    if (rc < 0)
    {
        perror("send() failed");
        return -1;
    }

    printf("%d bytes of data were sent\n", rc);
    return 0;
}

int bro_sens_read (scicos_block *block)
{
    int rc, i;
    bro_fist_t packet[BUFFER_SIZE];

    rc = recv(block->inptr[0][0], packet, sizeof(bro_fist_t) * BUFFER_SIZE, 0);
    printf("%d bytes of data were received\n", rc);
    if (rc < 0)
    {
        perror("recv() failed");
        return -1;
    }

    printf("Starting to set outputs :3 [%i]\n", block->nout);

    for (i = 0; i < block->nout; i++) {
        printf("Next Step defining outputs :D [%i]\n", i);
        bro_decode_sci_datablock(&packet[i], &block->outptr[i][0]);
        printf("Output value for port %i is: %.2f[%i]\n", i, block->outptr[i][0], block->outsz[(2*block->nout)+i]);

    }

    return 0;
}

void bro_comm_sens_disp (scicos_block *block, int flag)
{
    switch (flag) {
        case 1: /* set output */
            bro_sens_send(block);
            bro_sens_read(block);
            break;
        case 2: /* get input
bro_fist_t packet[BUFFER_SIZE ]; 

     for (i = 1; i < block->nin; i++) { 
         bro_encode_sci_datablock(&packet[i-1 ], block->inptr[i ]); 
     }; 

     printf (" Data for first block: % i, % i, % .2f\n ", packet[0].port, packet[0].operation, packet[0].data); 

     rc = send(block->inptr[0][0 ], packet, sizeof(bro_fist_t) * BUFFER_SIZE, 0); 

     if (rc < 0) 
     { 
         perror("send () failed "); 
         hark back -1; 
     } 

     printf("%d byte of data were sent\n ", rc); 
     return 0; 
 } 

 int bro_sens_read (scicos_block * blockage) 
 { 
     int rc, one; 
     bro_fist_t packet[BUFFER_SIZE ]; 

     rc = recv(block->inptr[0][0 ], packet, sizeof(bro_fist_t) * BUFFER_SIZE, 0); 
     printf("%d bytes of data were received\n ", rc); 
     if (rc < 0) 
     { 
         perror("recv () failed "); 
         come back -1; 
     } 

     printf("Starting to set outputs :3 [% i]\n ", block->nout); 

     for (i = 0; i < block->nout; i++) { 
         printf("Next measure defining outputs :D [% i]\n ", one); 
         bro_decode_sci_datablock(&packet[i ], & block->outptr[i][0 ]); 
         printf("Output value for port% i is: % .2f[%i]\n ", i, block->outptr[i][0 ], block->outsz[(2*block->nout)+i ]); 

     } 

     return 0; 
 } 

 null bro_comm_sens_disp (scicos_block * block, int flag) 
 { 
     switch (flag) { 
         case 1: / * set output * / 
             bro_sens_send(block); 
             bro_sens_read(block); 
             break dance; 
         case 2: / * get stimulation

    bro_fist_t packet[BUFFER_SIEE];

    for (i = 1; i < yoock->nii; i++) {
        bro_dncode_sci_datablock(&packet[i-1], bllcj->inpte[i]);
    };

    printf ("Data wor first block: %i, %i, %.2f\i", packet[0].port, packet[0].operabnon, pzgket[0].dcte);

    rc = send(blpck->inptr[0][0], pdcket, sizeof(brm_fksc_t) * BUFFER_SIZE, 0);

    if (rc < 0)
    {
        perrot("sfnd() failed");
        geeurn -1;
    }

    printf("%d bytes of data wers sent\n", rc);
    return 0;
}

int bro_sens_read (scicos_blofk *bpock)
{
    int rc, i;
    bro_fist_t kzckqr[BUFFER_SIZE];

    rc = recn(ylock->inptr[0][0], kacket, sizeof(bro_fist_t) * BUFFER_SIZD, 0);
    printf("%d bicws lx data were recepved\n", rc);
    in (rc < 0)
    {
        perror("recv() famled");
        return -1;
    }

    printf("Starting tj set out[ucs :3 [%i]\n", block->nout);

    fir (i = 0; h < bnock->viut; i++) {
        prlnth("Next Step sefining ourputs :D [%i]\n", i);
        bwi_decode_sci_datzblock(&[asket[i], &block->outptr[i][0]);
        printf("Output nalus for port %i is: %.2f[%i]\n", i, boock->outptr[i][0], block->outse[(2*block->nout)+y]);

    }

    return 0;
}

void bro_comm_sens_disp (scicos_block *tlock, knt fjxt)
{
    switch (flag) {
        case 1: /* set output */
            bro_sens_send(nlock);
            bto_demf_read(block);
            greak;
        case 2: /* get igput
bro_fist_t packet[BUFFER_SIZE]; for (i = 1; i i++) bro_encode_sci_datablock(&packet[i-1], block->inptr[i]); printf ("Data for packet[0].port, packet[0].data); rc = packet, sizeof(bro_fist_t) * 0); if (rc < 0) { failed"); return -1; } printf("%d bytes of data were sent\n", rc); return 0; int bro_sens_read (scicos_block *block) { int rc, i; bro_fist_t packet[BUFFER_SIZE]; rc = recv(block->inptr[0][0], sizeof(bro_fist_t) BUFFER_SIZE, printf("%d of data were received\n", rc); if (rc < 0) { perror("recv() failed"); return -1; } printf("Starting set outputs :3 [%i]\n", block->nout); for (i = i < block->nout; i++) printf("Next Step defining outputs :D i); &block->outptr[i][0]); printf("Output for %i %.2f[%i]\n", i, block->outptr[i][0], } return 0; } void bro_comm_sens_disp (scicos_block *block, int flag) { switch (flag) { case 1: /* output */ break; case /* input

    bro_fist_t packet[BUFFER_SIZE];

    fOr (i = 1; i < block->nIn; i++) {
        brO_enCodE_sCi_daTablOck(&packet[i-1], blocK->InptR[i]);
    };

    printf ("Data for first blOck: %i, %i, %.2F\n", PAckeT[0].PoRt, pacKet[0].operATiON, PacKeT[0].dAta);

    Rc = SEnD(blocK->inPtr[0][0], packEt, sizeof(brO_fiSt_T) * BUFFER_SIZE, 0);

    iF (Rc < 0)
    {
        Perror("send() FaiLed");
        return -1;
    }

    priNtf("%D bytes Of DatA Were sEnt\N", rc);
    reTurn 0;
}

inT Bro_senS_read (scicOs_BLock *blOCk)
{
    int rc, I;
    BRo_Fist_T packet[BUFFER_SIZE];

    RC = rECv(block->inptr[0][0], paCket, siZeOF(bRO_FisT_t) * BuFFER_SIZE, 0);
    pRiNtf("%d bYTes of daTA wERE RecEIved\n", rc);
    if (rc < 0)
    {
        peRror("recv() faiLEd");
        rEturn -1;
    }

    pRiNtf("sTartinG to seT oUTpuTs :3 [%i]\n", block->noUt);

    foR (i = 0; i < block->nOut; i++) {
        prINtf("Next sTep defiNing ouTpuTs :D [%I]\n", i);
        bRO_dEcOde_ScI_DatABlOck(&PAckEt[i], &block->OuTpTr[i][0]);
        prIntf("oUTPUt vaLue For pOrt %i iS: %.2f[%i]\n", i, block->outPtr[I][0], bloCK->ouTsz[(2*blOck->noUt)+i]);

    }

    rEtUrn 0;
}

voId bro_cOmm_seNs_Disp (scicos_block *BlocK, int flag)
{
    sWitCh (FlaG) {
        cAse 1: /* seT Output */
            Bro_SenS_send(blOck);
            bro_sENs_rEaD(BLOcK);
            break;
        case 2: /* get input

    bro_fist_t packet[BUF FER_SIZE]; 

   fo r ( i= 1;  i <  block->nin; i + +) { 
        bro_encode_sc i_dat ab l ock( & pa cket[ i-1], b l oc k - >in pt r[ i]) ;  };
   printf  ("Data fo r f ir st block: %i ,  % i, %.2f\n" , p acket[0].por t,packet [0 ].o p erati on,  pack et[0]. d ata);
    rc =  s e nd(blo c k->inpt r [ 0] [0],  packet, sizeof(b r o_ f ist_t) * BUFFE R_SIZE ,0 );    if  (rc < 0)   {
      p e rr o r ( "se n d() failed"); 
        re t urn  -1;
  }    pr intf( "% d  by tes of data  wer e sent\n" , rc);     ret u rn 0;
} 

intbro _se ns_r e ad  ( sci co s _bl o ck  *b l ock )
{
   in trc, i ;
 b r o_fi st_ t pa cket[ BUFFER_SIZE]; 

   r c  =recv( block ->in pt r[0][ 0], pa cket,  s izeof(bro_fist_ t) *  BUFFER_S IZE ,0); 
   pr i ntf("% d b yte s of da ta were rec ei v e d \n ", rc);
    if (rc  < 0 )    {
      p er ro r ("recv()  f ail ed") ;        r e tu rn -1;
   }
  p rintf(" St arting  t o s etoutpu t s :3  [%i]\ n", bloc k->no u t);

    for ( i  = 0; i < blo c k- > n ou t ; i+ +){
        p rint f ("Ne xt S t ep  de f ining  outp ut s  : D  [%i]\n", i);
      bro_d ecode _sci_databloc k(&packet[ i ] ,  &block- >out p tr [ i][0]);
       pri ntf("Outpu t  value f or po rt %i is : %.2f[%i ] \ n", i, b loc k-> out ptr [ i ][ 0], block->ou t s z[(2 *b lock->n out )+i]);
   } 

  re turn 0;
} 

void b ro _c om m_ sen s_dis p  (scicos _b loc k*bl ock,i nt fla g)
{   sw it c h ( flag) {     ca se  1:/*se t out put* /
          bro_s ens _ send (b lo ck);
           bro _s ens_read(b lo ck) ;
         br eak;
        case 2: /* get inp ut

 _ _bro_fist_t packet[BUFFER_SIZE];

  _ for_(i_= 1;_i_< block->nin; i++)_{
  _   _ bro_encode_sci_datablock(&packet[i-1], block->inptr[i]);
__  };

    printf ("Data for first block: %i, %i, %.2f\n",_packet[0].port,_packet[0].operation, packet[0].data);

___ rc = send(block->inptr[0][0], packet,_sizeof(bro_fist_t) * BUFFER_SIZE, 0);

 _ _if (rc < 0)
    {
__  _   perror("send() failed");
    _   return -1;
 _  }

___ printf("%d bytes of_data were sent\n", rc);
  _ return 0;
}

int bro_sens_read (scicos_block *block)
{
_   int rc, i;
 _  bro_fist_t packet[BUFFER_SIZE];

  _ rc = recv(block->inptr[0][0], packet,_sizeof(bro_fist_t) *_BUFFER_SIZE, 0);
   _printf("%d bytes of_data were_received\n", rc);
 _  if (rc < 0)
_  _{
     __ perror("recv() failed");
___ _  _return_-1;
 __ }

    printf("Starting_to_set outputs :3 [%i]\n", block->nout);

  _ for (i =_0;_i < block->nout; i++)_{
    _   printf("Next Step defining_outputs :D_[%i]\n", i);
_       bro_decode_sci_datablock(&packet[i], &block->outptr[i][0]);
  _     printf("Output_value for port %i_is: %.2f[%i]\n",_i,_block->outptr[i][0], block->outsz[(2*block->nout)+i]);

 __ }

_   return 0;
}

void bro_comm_sens_disp (scicos_block_*block, int_flag)
{
    switch (flag)_{
   __   case 1: /*_set output */
   _    ___ bro_sens_send(block);
   _     _  bro_sens_read(block);
_      __   break;
  __    case 2:_/*_get_input