Xilinx Echo Server Data Variable

289 views Asked by At

I want to have my Zedboard return a numeric value using the Xilinx lwIP example as a base but no matter what I do I can't figure out what stores the data received or transmitted.

I have found the void type payload but I don't know what to do with it.

Snapshot of one instance of payload and a list of lwIP files

Below is the closest function to my goal:

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_sndbuf\n\r");

/* free the received pbuf */
pbuf_free(p);

return ERR_OK;
}

Any guidance is appreciated.

Thanks, Turtlemii

1

There are 1 answers

0
Turtlemii On

-I cheated and just made sure that the function has access to Global_tpcb from echo.c -tcp_write() reads in an address and displays each char it seems.

 void Print_Code()
 {
        /* Prepare for TRANSMISSION */
        char header[] = "\rSwitch: 1 2 3 4 5 6 7 8\n\r";    //header text
        char data_t[] = "                       \n\r\r";    //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
}