Xilinx Echo服务器数据变量



我想让我的Zedboard以Xilinx lwIP示例为基础返回一个数值,但无论我做什么,我都无法确定接收或传输的数据存储在什么地方。

我已经找到了无效类型的有效载荷,但我不知道该怎么办。

有效载荷的一个实例和lwIP文件列表的快照

以下是最接近我目标的函数:

err_t recv_callback(void *arg, struct tcp_pcb *tpcb,
struct pbuf *p, err_t err){    
/* do not read the packet if we are not in ESTABLISHED state */
if (!p) {
tcp_close(tpcb);
tcp_recv(tpcb, NULL);
return ERR_OK;
}
/* indicate that the packet has been received */
tcp_recved(tpcb, p->len);
/* echo back the payload */
/* in this case, we assume that the payload is < TCP_SND_BUF */
if (tcp_sndbuf(tpcb) > p->len) {
err = tcp_write(tpcb, p->payload, p->len, 1);
//I need to change p->paylod but IDK where it is given a value.
} else
xil_printf("no space in tcp_sndbufnr");
/* free the received pbuf */
pbuf_free(p);
return ERR_OK;
}

欢迎提供任何指导。

谢谢,Turtlemii

-我作弊了,只是确保函数可以从echo.c访问Global_tpcb-tcp_write((读取一个地址并显示它所显示的每个字符。

void Print_Code()
{
/* Prepare for TRANSMISSION */
char header[] = "rSwitch: 1 2 3 4 5 6 7 8nr";    //header text
char data_t[] = "                       nrr";    //area for storing the 
data
unsigned char mask = 10000000;                  //mask to decode switches
swc_value = XGpio_DiscreteRead(&SWCInst, 1);    //Save switch values
/* Write switch values to the LEDs for visual. */
XGpio_DiscreteWrite(&LEDInst, LED_CHANNEL, swc_value);
for (int i =0; i<=7; i++) //load data_t with switch values (0/1)
{
data_t[8+2*i] = '0' + ((swc_value & mask)/mask); //convert one bit to 0/1
mask = mask >> 1;//move to next bit
}
int len_header = *(&header + 1) - header;       //find the length of the 
header string
int len_data = *(&data_t + 1) - data_t; //find the length of the data string

tcp_write(Global_tpcb, &header, len_header, 1); //print the header
tcp_write(Global_tpcb, &data_t, len_data, 1);   //print the data
}

最新更新