fetisov / lrndis

stm32 ethernet over usb (rndis + lwip)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Frames with Length%64=0

nicokorn opened this issue · comments

Hi,

how do you verify if the message is completely received, if the length is "Length%64=0":

if (ep->xfer_count != RNDIS_DATA_OUT_SZ)

I wasn't able to deliver such messages on to my bus and had to modify your code slightly, by getting the message length in the first usb frame from the header and receiving following frames until I had a complete message by comparing received bytes with the message length in the header:

if (rndis_received + ep->xfer_count <= RNDIS_RX_BUFFER_SIZE)
{
// copy fragment into frame buffer
memcpy(&rndis_rx_buffer[rndis_received], usb_rx_buffer, ep->xfer_count);

// if first fragment, extract frame length
if( rndis_received == 0 )
{
rndis_header = (rndis_data_packet_t *)rndis_rx_buffer;
rndis_MessageLength = rndis_header->MessageLength;
}

rndis_received += ep->xfer_count;
if (ep->xfer_count != RNDIS_DATA_OUT_SZ || rndis_received == rndis_MessageLength)
{
handle_packet(rndis_rx_buffer, rndis_received);
rndis_received = 0;
}
}

Thanks a lot for your answer. Very useful rndis code, thanks alot for your effort! I'm using it to send ethernet frames over RS485 on a STM32F411 Black Pill board. With 2 statically allocated ringbuffers on each usb and uart peripheral I'm doing zero copy on sending and receiving data (except on the first usb packet for the OUT endpoint). I also tried a linked list, but performance was worse, because of malloc, enable/disable irq all the time for a packets.

Thanks again. The problem has been fixed. As a bonus, the data transfer code has also been improved. I would be very grateful if you share your experience of using the new version.

Hi Sergey, I tested your new version and it works! Thanks a lot.

You have done several changes I appreciate, like the padding/short packets, the tx struct ect.

It was also easy to embbed your new version into my project which is using zero copy ringbuffers in an other c file.

Hello. Glad I was able to help and thank you again for your contribution!