This is my seventh week as an intern at Aeste Works. This week was about figuring out which part of my USB CDC ECM code interfaces between the host and device in sending and receiving network packets so that I could integrate the lwIP TCP/IP stack later on. There are two functions that were found in the code that sends and receives data.  First, the application can send data to the Host by using the USB_DEVICE_CDC_Write function.  This function requests a data write to the USB Device CDC Function Driver in which the request gets serviced as data is requested by the USB Host. Similarly, the application can receive data from the host by using the USB_DEVICE_CDC_Read function. This function requests a data read from the USB Device CDC Function Driver Layer in which it the request gets serviced as data is made available by the USB Host. This was verified by a program I wrote that blinks the LED’s on the board whenever packets were being sent and received as observed on Wireshark.

Understandably, the USB host sends the network packets to try to get information about the USB CDC ECM device but the question was about the behaviour of the network packet being sent from the device back to the host. Observing this through Wireshark, one hint that was found was that the sent packet size to the host was always the same size as that of the received packet size from the host. Looking through the application state machine part of the code carefully, the application stores the data received from the host in a read buffer and would send the data in the buffer back to the host.  In the original USB CDC ACM demo where the device acts as a serial port, typing a key in a terminal window would result in the attached device echoing the next letter.  This explains the behaviour of the USB CDC  ECM sent network packets. To verify, removing the function from the application state machine would result in the USB device no longer sending network packets back to the host.

It was time to check whether Microchip’s TCP/IP stack could be used with the USB CDC ECM device before implementing lwIP. This was to further understanding on the interface between sending and receiving data. However, going through a program with Dr Shawn in which Microchip’s TCP/IP stack was used with an external ethernet controller, it proved to be quite a diffcult task as there were layer upon layer of interfaces between the TCP/IP stack and the external ethernet controller. Thus, we decided to directly implement lwIP’s TCP/IP stack. This would be my main task the following week.

 


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.