How to transmit video faster via wifi?

roctwo
Posts: 95
Joined: Mon Nov 28, 2016 3:12 am

Re: How to transmit video faster via wifi?

Postby roctwo » Mon Feb 20, 2017 12:03 pm

ESP_igrr wrote:Do you have some statistics, how much data and how often is the application sending to the UDP stack?
Which core is your line filter task running on? Is FreeRTOS running in single core or dual core mode?
Thank you for your response!
Do you have some statistics---------------It's estimated.Almost a half of udp packets is missing,maybe less than half.
how much data and how often is the application sending to the UDP stack?-----------------960 bytes per udp packet.Send a udp packet every 1.8ms.
Which core is your line filter task running on?---------------------pro CPU.
Is FreeRTOS running in single core or dual core mode?-------------------------single core.

roctwo
Posts: 95
Joined: Mon Nov 28, 2016 3:12 am

Re: How to transmit video faster via wifi?

Postby roctwo » Mon Feb 20, 2017 12:10 pm

ESP_igrr wrote:Do you have some statistics, how much data and how often is the application sending to the UDP stack?
Which core is your line filter task running on? Is FreeRTOS running in single core or dual core mode?
Do you have some statistics?----------------It's estimated.Almost a half of UDP packages is missing.Maybe less than half.
how much data and how often is the application sending to the UDP stack?--------------------960bytes per udp package.send a udp package every 1.8ms.
Which core is your line filter task running on?----------------pro CPU
Is FreeRTOS running in single core or dual core mode?----------single core

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: How to transmit video faster via wifi?

Postby ESP_igrr » Mon Feb 20, 2017 1:22 pm

That's about 4.5 Mbit/sec. Are you testing in air or in a shielded box?

Also, please update the code to check the return value from sendto and, in case if the return value is not as expected, the value of errno.
If errno is ENOMEM, you need to perform rate control by setting up a timer or using delay to attempt sending again.

Without this it is impossible to say whether the packets are really lost or just not accepted for transmission.

roctwo
Posts: 95
Joined: Mon Nov 28, 2016 3:12 am

Re: How to transmit video faster via wifi?

Postby roctwo » Tue Feb 21, 2017 9:29 am

ESP_igrr wrote:That's about 4.5 Mbit/sec. Are you testing in air or in a shielded box?

Also, please update the code to check the return value from sendto and, in case if the return value is not as expected, the value of errno.
If errno is ENOMEM, you need to perform rate control by setting up a timer or using delay to attempt sending again.

Without this it is impossible to say whether the packets are really lost or just not accepted for transmission.
Thank you for your response!Errno is ENOMEM.I did what you said,But things are not getting better.This bug is complicated.So for debugging, I want to figure out one question at first.Only focused on UDP problems of ESP32.I have a simple project that only send UDP packages constantly.Here is the code.

Code: Select all

static void udp_thread(void *p)
{
	int i = 0;
	int sock;
	struct sockaddr_in toAddr;
        xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, false, true, portMAX_DELAY);
	LWIP_UNUSED_ARG(p);
	sock = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
	if(sock < 0)
	{
		ESP_LOGI(TAG, "socket err");
	}
	memset(&toAddr,0,sizeof(toAddr));
	toAddr.sin_family=AF_INET;
	toAddr.sin_addr.s_addr=inet_addr("192.168.23.1");
        toAddr.sin_port = htons(REMOTE_PORT);
	while(1) 
	{
		usertimeout.tv_sec=1;
		usertimeout.tv_usec=0;
/*******************************start means the start of a frame ********************************************/
		sendto(sock,start,SEND_START_LEN,0,(struct sockaddr*)&toAddr,sizeof(toAddr));
/*******************************start contents of a frame ********************************************/	
	        for(i=0; i<LINES; i++)
		{
			FD_ZERO(&rdfds); 
			FD_CLR( sock, &rdfds);
			FD_SET(sock,&rdfds); 
			ret=select(sock+1,NULL,&rdfds,NULL,&usertimeout);
			if(ret>0)
			{
				if(FD_ISSET(sock,&rdfds))   
				{
					ret=sendto(sock,image[i],SEND_BUF_LEN,0,(struct sockaddr*)&toAddr,sizeof(toAddr));
			                if(ret<0)
					{
					        perror("send failed reason");
					        /*
				                ets_delay_us(500);
						ret=sendto(sock,image[i],SEND_BUF_LEN,0,(struct sockaddr*)&toAddr,sizeof(toAddr));
						*/
					}
				}
			}
		
		 }
/*******************************end means the end of a frame ********************************************/
			sendto(sock,end,SEND_END_LEN,0,(struct sockaddr*)&toAddr,sizeof(toAddr));
			gpio_set_level(16, 0);
		}

	close(sock);
	vTaskDelete(NULL);
}
From my test.The result of sending fail is "not enough space".This happens almost 5%.It's not too bad.If I add ets_delay_us(500) and then send the data again,things will getting better.Almost no sending fail happens.But adding delay is not a good method for my camera project.Is there any ohter methods can solve this problem instead of adding delay.

rosimildo
Posts: 13
Joined: Fri Nov 11, 2016 7:20 pm

Re: How to transmit video faster via wifi?

Postby rosimildo » Wed Feb 22, 2017 12:30 am

I ran on similar issue with BLE. I had to put a delay between sends.

I guess the question how can I query the remaining memory available ?

Rosimildo

roctwo
Posts: 95
Joined: Mon Nov 28, 2016 3:12 am

Re: How to transmit video faster via wifi?

Postby roctwo » Wed Feb 22, 2017 3:20 am

ESP_igrr wrote:That's about 4.5 Mbit/sec. Are you testing in air or in a shielded box?

Also, please update the code to check the return value from sendto and, in case if the return value is not as expected, the value of errno.
If errno is ENOMEM, you need to perform rate control by setting up a timer or using delay to attempt sending again.

Without this it is impossible to say whether the packets are really lost or just not accepted for transmission.
Can increase the UDP send buffer size to solve this problem.Can sendto() blocks until buffer is avaliable?

roctwo
Posts: 95
Joined: Mon Nov 28, 2016 3:12 am

Re: How to transmit video faster via wifi?

Postby roctwo » Wed Feb 22, 2017 8:33 am

rosimildo wrote:I ran on similar issue with BLE. I had to put a delay between sends.

I guess the question how can I query the remaining memory available ?

Rosimildo
Yes,If ESP users can query the remaining memery available,Sending will be more efficient.I'd want to konw how to query the remaining memory available too."ENOMEM",this problem that many ESP32/ESP8266 user met.So if engineers of Espressif can provide more suggestion,it will good for ESP users.

roctwo
Posts: 95
Joined: Mon Nov 28, 2016 3:12 am

Re: How to transmit video faster via wifi?

Postby roctwo » Thu Feb 23, 2017 8:15 am

Hi igrr!
Question is from my camera project. When I slow down fps to 0.2fps.(A frame size is QVGA(320*240))Failure probability of sending fail is 1%.But if I set fps to 2fps, failure probability is more than 50%,Fail reason is ENOMEM. Sending again after adding delay makes no difference.It seems time is enough for sending even in 2fps.Failure probability in 2fps is wrong.What make this situation happen?Can you share your views.Is the timing conflict about wifi task between my task?I will appreciate it very much.

roctwo
Posts: 95
Joined: Mon Nov 28, 2016 3:12 am

Re: How to transmit video faster via wifi?

Postby roctwo » Thu Feb 23, 2017 11:09 am

Is the APB bus conflict after wifi functions are added.If it is,how to avoid this?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: How to transmit video faster via wifi?

Postby ESP_igrr » Fri Feb 24, 2017 7:37 am

Can you try doing a UDP send benchmark without any camera related code running? That will give some indication of the bandwidth you can achieve.

There may be a priority conflict if you run your sending task at a priority higher than lwip task. So I suggest setting the priority of the sending task to 1.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 261 guests