static char buf[32] = {0}; // Globally declared
char* itoa(int val, int base)
{
int i = 30;
for(; val && i ; --i, val /= base)
buf[i] = "0123456789abcdef"[val % base];
return &buf[i+1];
}
I am working with Xilinx Ethernetlite (lwip) design. With LWIP Echo template, I am able to make communication between FPGA board and PC (hercules). The issue is in hercules or in itoa Function. I am unable to make sure.
In Hercules, to print the data i am doing itoa conversion Function in echo file. Only if buf size is 32. I am able to read the properly. If i increase the buf size is 1024. I am not able to read the data in Herceuls.
err_t recv_callback(void *arg, struct tcp_pcb *tpcb,
struct pbuf *p, err_t err)
{
int i,j,Status;
Status=aurora_rx_main(); ///FUNCTION CALL
for(i=0;i<100;i++)
{
xil_printf("%d\n", DestinationBuffer[i]);
}
int base=10; // here 10 means decimal
char *result={0};
if (!p) {
tcp_close(tpcb);
tcp_recv(tpcb, NULL);
return ERR_OK;
}
/* indicate that the packet has been received */
tcp_recved(tpcb, p->len);
if (tcp_sndbuf(tpcb) > 100)
//if (tcp_sndbuf(tpcb) <= p->len)
{
for (j=0;j<=100;j++)
{
result= itoa(DestinationBuffer[j],base);
err = tcp_write(tpcb,",",1,1);
err = tcp_write(tpcb,result,100,1); // Unable to read the 100 values in Hercules.
tcp_sent( tpcb, NULL );
tcp_output(tpcb);
}
} else
//xil_printf("no space in tcp_sndbuf\n\r");
/* free the received pbuf */
pbuf_free(p);
return ERR_OK;
}
Question
Thausikan
static char buf[32] = {0}; // Globally declared char* itoa(int val, int base) { int i = 30; for(; val && i ; --i, val /= base) buf[i] = "0123456789abcdef"[val % base]; return &buf[i+1]; }
I am working with Xilinx Ethernetlite (lwip) design. With LWIP Echo template, I am able to make communication between FPGA board and PC (hercules). The issue is in hercules or in itoa Function. I am unable to make sure.
In Hercules, to print the data i am doing itoa conversion Function in echo file. Only if buf size is 32. I am able to read the properly. If i increase the buf size is 1024. I am not able to read the data in Herceuls.
err_t recv_callback(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err) { int i,j,Status; Status=aurora_rx_main(); ///FUNCTION CALL for(i=0;i<100;i++) { xil_printf("%d\n", DestinationBuffer[i]); } int base=10; // here 10 means decimal char *result={0}; if (!p) { tcp_close(tpcb); tcp_recv(tpcb, NULL); return ERR_OK; } /* indicate that the packet has been received */ tcp_recved(tpcb, p->len); if (tcp_sndbuf(tpcb) > 100) //if (tcp_sndbuf(tpcb) <= p->len) { for (j=0;j<=100;j++) { result= itoa(DestinationBuffer[j],base); err = tcp_write(tpcb,",",1,1); err = tcp_write(tpcb,result,100,1); // Unable to read the 100 values in Hercules. tcp_sent( tpcb, NULL ); tcp_output(tpcb); } } else //xil_printf("no space in tcp_sndbuf\n\r"); /* free the received pbuf */ pbuf_free(p); return ERR_OK; }
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.