Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

w5x00_lwip.c: unused Ethernet CRC #2

Open
Chris660 opened this issue Jun 1, 2024 · 1 comment
Open

w5x00_lwip.c: unused Ethernet CRC #2

Chris660 opened this issue Jun 1, 2024 · 1 comment

Comments

@Chris660
Copy link

Chris660 commented Jun 1, 2024

I'm building a project where I hope to use the W5100S with the LWIP IP stack, and
noticed gcc complaining about several set but unused (never read) variables.

For example, in w5x00_lwip.c:110:

  1. send_len is set but never used.
  2. The crc calculated by ethernet_frame_crc is never used.

The example code seems to work, so I assume (2) is okay because the W5100S calculates the CRC?

Is this repository the best reference for using the W5100S with LWIP, or should I be looking elsewhere?

err_t netif_output(struct netif *netif, struct pbuf *p)
{
    uint32_t send_len = 0;
    uint32_t tot_len = 0;

    memset(tx_frame, 0x00, sizeof(tx_frame));

    for (struct pbuf *q = p; q != NULL; q = q->next)
    {
        memcpy(tx_frame + tot_len, q->payload, q->len);

        tot_len += q->len;

        if (q->len == q->tot_len)
        {
            break;
        }
    }

    if (tot_len < 60)
    {
        // pad
        tot_len = 60;
    }

    uint32_t crc = ethernet_frame_crc(tx_frame, tot_len);  // crc set, never used

    send_len = send_lwip(0, tx_frame, tot_len);  // send_len set, never used

    return ERR_OK;
}
@Chris660
Copy link
Author

Chris660 commented Jun 2, 2024

Is this repository the best reference for using the W5100S with LWIP, or should I be looking elsewhere?

For anyone else wondering this, the wiznet5k driver from MicroPython provides a more complete implementation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant