Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

problem receiving data

Hi

I have build a small project which receives data sended by tcp. This works fine until the number of the sended packets exeeds 32. After receiving the 32nd packet the NIOS hangs.

My receiving function is

err_t port_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
char *src;
  err_t err2;
  if(err==ERR_OK && p!=NULL)
  {
    src=(char *) p->payload;
    tcp_recved(pcb, p->tot_len);
    if(src==0x6D)
      printf("%s\n",src);
    else
      printf("0x%x\n",src);
  }
  printf(">>> %d\n",p->tot_len);
  
  err2=tcp_write(pcb,src,p->tot_len,1);
  if(err2==ERR_OK)
  {
    tcp_ack_now(pcb);  
    exec_command(src);
    packnumber++;
    printf("# %d\n",packnumber);/*prints the number of packets*/
    //send finished cmd
    return ERR_OK; 
  }
  else
    return ERR_BUF;
  exec_command(src);/*calls an execute function*/
}

1 Reply