You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I have configured a ESP32-S3, to pop up as RNDIS device, everything works i can receive and transmit. But after i have built a web-server on top, that sends data from a websocket, some stability issues have occured.
My question is, is there a way to setup a interrupt or something very fast, so no packages are getting lost ?
Here is some of the functions i have implemented in my usb-service:
esp_netif_t *netif = (esp_netif_t *) arg;
size_t hs;
while(1){
/* Try and "take" the semaphore. This task will "sleep" until either the
semaphore is "given" by another task/ISR or the timeout (e.g. 10000ms) elapses. */
if ( xSemaphoreTake(tud_data_recd_sem, 10000 / portTICK_PERIOD_MS) == pdTRUE ) {
// Data was received!
if (tud_rx_len > 0){
esp_netif_receive(netif, tud_rx_buf, tud_rx_len, NULL);
//ESP_LOGI(TAG,"%x, %x, %x, %x, %x, %x, %x, %x",tud_rx_buf[0],tud_rx_buf[1],tud_rx_buf[2],tud_rx_buf[3],tud_rx_buf[4], tud_rx_buf[5], tud_rx_buf[6], tud_rx_buf[7]);
tud_network_recv_renew();
tud_rx_len = 0; //indicate buf is now read
hs = xPortGetFreeHeapSize();
//ESP_LOGI(TAG, "rx heap check (%u).", hs);
}
} else {
// Semaphore take timed out after 10000ms, i.e. no data received within 10000ms. Do we care?
ESP_LOGI(TAG, "no data received in the last 10s, will continue to wait.");
}
}
}```
```bool tud_network_recv_cb(const uint8_t *src, uint16_t size) {
if (tud_rx_len < 1) {
memcpy(tud_rx_buf, src, size);
tud_rx_len = size; //set tud_rx_len ONLY after finish copying
// "Give" the semaphore, signalling that data was received:
xSemaphoreGive(tud_data_recd_sem);
return true;
}else{
//unable to receive, busy
ESP_LOGW(TAG, "tud_network_recv_cb busy.");
return false;
}
}```
`uint16_t tud_network_xmit_cb(uint8_t *dst, void *ref, uint16_t arg) {
struct pbuf *p = (struct pbuf *)ref; //a linked list of pbufs
struct pbuf *q;
uint16_t len = 0;
(void)arg; // unused for this example
// traverse the "pbuf chain"; see ./lwip/src/core/pbuf.c for more info
for(q = p; q != NULL; q = q->next) {
memcpy(dst, (char *)q->payload, q->len);
dst += q->len; //increment the dst pointer (write further down)
len += q->len; //increment the total length
if (q->len == q->tot_len) break;
}
return len; //return total length of the dst buffer
}
`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I have configured a ESP32-S3, to pop up as RNDIS device, everything works i can receive and transmit. But after i have built a web-server on top, that sends data from a websocket, some stability issues have occured.
My question is, is there a way to setup a interrupt or something very fast, so no packages are getting lost ?
Here is some of the functions i have implemented in my usb-service:
Beta Was this translation helpful? Give feedback.
All reactions