Problem with nx_tcp_socket_send while porting code from S7G2 SK to S7G2 DK

I'm working on a webserver application that is currently working on the S7G2 SK. Today I tried to port it to S7G2 DK but I'm seeing some problems. The program starts up,

status = nx_ip_interface_status_check(&g_ip0, 0, NX_IP_LINK_ENABLED, &actual_status, TX_WAIT_FOREVER);

succeeds and it also successfully acquires an IP using the DHCP client.

However, when I try to initiate a connection to the webserver with a web browser, the function

status = nx_tcp_socket_send(&(server_ptr -> nx_http_server_socket), resp_packet_ptr, NX_HTTP_SERVER_TIMEOUT_SEND);

fails with NX_WINDOW_OVERFLOW. I ported it back to the SK and it works fine again. Changes I made mainly concern the Channel 1 Phy Reset Pin (IOPORT_PORT_07_PIN_06 on DK and IOPORT_PORT_08_PIN_06 on SK) in the ethernet driver sf_el_nx. The ethernet channel is set to 1 in both cases. Any idea what could be causing this? For reference, I'm pasting the (shortened) code for responding to the request below.

I have to admit I'm not sure about the calculation of the content length header field in serve_integrated_resources(), so if anyone has comments on that it would be nice as well. It's currently working but I think it should be the length of the data?

 

UINT request_notify(NX_HTTP_SERVER *server_ptr, UINT request_type, CHAR *resource, NX_PACKET *packet_ptr)
{
    SSP_PARAMETER_NOT_USED(server_ptr);
    SSP_PARAMETER_NOT_USED(request_type);
    SSP_PARAMETER_NOT_USED(resource);
    SSP_PARAMETER_NOT_USED(packet_ptr);

    if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)
        printf("Requested %s from server while in state %d\r\n", resource, config_state.message_type);
    //Serve resources compiled into the program
    for(unsigned int i = 0; i < sizeof(html_resources) / sizeof(html_resources[0]); i++)
    {
        struct html_resource * res = &html_resources[i];
        //Test of integrated web page serving
        if ((NX_HTTP_SERVER_GET_REQUEST == request_type) && (NULL != strstr(resource+1, res->name)))
            return serve_integrated_resources(server_ptr, request_type, resource, packet_ptr, res);
    }
    return(NX_SUCCESS);
}

UINT serve_integrated_resources(NX_HTTP_SERVER *server_ptr, UINT request_type, CHAR *resource, NX_PACKET *packet_ptr, struct html_resource * res)
{
    UINT        status;
    NX_PACKET   *resp_packet_ptr;
    ULONG       string_length;
    CHAR        temp_string[30];
    ULONG       length = 0;

    length = res->length;

    /* Derive the client request type from the client request.  */
    string_length =  (ULONG) nx_http_server_type_get(server_ptr, server_ptr->nx_http_server_request_resource, temp_string);

    /* Null terminate the string. */
    temp_string[string_length] = 0;

    /* Now build a response header with server status is OK and no additional header info.  */
    status = nx_http_server_callback_generate_response_header(server_ptr, &resp_packet_ptr, NX_HTTP_STATUS_OK, length, temp_string, NX_NULL);

    /* If status is NX_SUCCESS, the header was successfully appended. */

    /* add data to packet */
    status = nx_packet_data_append(resp_packet_ptr, res->data, res->length, server_ptr->nx_http_server_packet_pool_ptr,
                                                  NX_WAIT_FOREVER);
    if (status != NX_SUCCESS)
    {
       nx_packet_release(resp_packet_ptr);
       return status;
    }

    /* Now send the packet! */
    status = nx_tcp_socket_send(&(server_ptr -> nx_http_server_socket), resp_packet_ptr, NX_HTTP_SERVER_TIMEOUT_SEND);

    if (status != NX_SUCCESS)
    {
      nx_packet_release(resp_packet_ptr);
      return status;
    }

    /* Let HTTP server know the response has been sent. */
    return NX_HTTP_CALLBACK_COMPLETED;
}

  • In reply to ChrisS:

    hmmm, The dip switches look correct. I do note that you are using version 3.0 whilst my board is a 3.1 (no green wire).
    I did confirm that the PDC peripheral (CAM switch on the breakout board) conflicts with Ethernet 1.

    I ran the Netx Webserver (with USB stick) on my 3.1 board and am experiencing the same results as you. With the board un-attached it works fine, but with the breakout board attached I get timeouts on pings, and the server doesn't work.

    Maybe something simple, but I don't see it.
  • In reply to Dale Drinkard:

    The camera interface is connected to PDC, which is shared with ENET1. However, as you can see on the pictures above I have disabled the CAM dip switch on S101 and enabled ENET1 on S5 so this should not be a problem?
    For testing I have just tried to enable the CAM switch (camera not attached). In this scenario I also get 0x39. Disabling ENET1 completely prevents ethernet communication as expected.
  • In reply to Dale Drinkard:

    Good to know it's not a unique problem on my end. I'll try to reconfigure the project to use ENET0 on the breakout board and see if that works for me so I can keep using the breakout board.
  • In reply to ChrisS:

    So I just switched to ENET0 and it works fine with the breakout board. I will keep using that for now but I suppose this warrants a hardware fix on further revisions.