Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor10417301041730 Receiving Packets on a Network Device Anchor10417311041731NetDev_Rx() is called by μC/TCP-IP’s Receive task after the Interrupt Service Routine handler has signaled to the Receive task that a receive event has occurred. NetDev_Rx() requires that the device driver return a pointer to the data area containing the received data and return the size of the received frame via pointer. Anchor10417321041732

NetDev_Rx() should perform the following actions:

...

  1. 10417331041733Check for receive errors, if applicable. If an error should occur during reception, the driver should set *size to 0 and *p_data to (CPU_INT08U *)0 and return. Additional steps may be necessary depending on the device being serviced. Anchor10417341041734
  2. For Ethernet devices, get the size of the received frame and subtract four bytes for the CRC. It's recommended to first check the frame size to ensure that it is larger than four bytes before performing the subtraction, to ensure that an underflow does not occur. Set *size to the adjusted frame size.anchor
  3. 10417351041735Get a new data buffer area by calling NetBuf_GetDataPtr(). If memory is not available, an error will be returned and the device driver should set *size to 0 and *p_data to (CPU_INT08U *)0. Anchor
  4. 10417361041736If an error does not occur while getting a new data area, *p_data must be set to the address of the data area. Anchor10417371041737
  5. Set perr to NET_DEV_ERR_NONE and return from the receive function. Otherwise, set perr to an appropriate network device error code.