Skip to main content
bluscape
Associate III
November 20, 2019
Solved

How to determine USB Data OUT end of packet

  • November 20, 2019
  • 6 replies
  • 1830 views

I'm busy with a USB to Ethernet implementation using the ST USB library and LwIP.

When I send a packet to the host (Data IN) that came from the ethernet interface, I know where is the end of an ethernet frame send a zero length packet (ZLP) accordingly.

But how do I know when it is the end of a USB packet from the host (Data OUT)? So that I can send an entire frame to the ethernet?

This topic has been closed for replies.
Best answer by bluscape

Actually, the logic is the same as the IN transfers. A transfer is considered to be complete if one of these two conditions are detected:

  1. A transaction with less than max-packet-size bytes
  2. A full length transaction followed by a ZLP

6 replies

Pavel A.
Super User
November 20, 2019

Which driver runs on the host? A "standard" CDC EEM Ethernet type? (usbnet.sys on Windows 10) or custom?

-- pa

bluscape
bluscapeAuthor
Associate III
November 20, 2019

Well, I'm implementing CDC ECM and windows does not have a driver for this. Unless you know of one that I can modify.

So I'm testing on an Ubtuntu VM. Still CDC ECM.

Ubuntu detects the network connection and I can ping the STM32. I've also implemented a DHCP and DNS on the STM32 but I can't get Ubuntu to get an IP from the DHCP so for now I'm giving it a static IP until the ethernet is working properly.

I chose CDC ECM because I actually want to interface the USB to iOS and Android. Apple detects the ethernet connection but I think my Android phone (Samsung) kernel version is too old or the USB implementation is not perfect.

bluscape
bluscapeAuthor
Associate III
November 24, 2019

Anybody?

Pavel A.
Super User
November 24, 2019

Windows has in-box RNDIS driver. I don't know which model works everywhere. Try to ask on Stack Overflow.

-- pa

bluscape
bluscapeAuthorBest answer
Associate III
November 26, 2019

Actually, the logic is the same as the IN transfers. A transfer is considered to be complete if one of these two conditions are detected:

  1. A transaction with less than max-packet-size bytes
  2. A full length transaction followed by a ZLP
Ben K
Senior III
November 27, 2019

This example uses CDC-NCM interface: https://github.com/IntergatedCircuits/IPoverUSB