cancel
Showing results for 
Search instead for 
Did you mean: 

What Can I do for solve this error? I refer to this GitHub! https://github.com/jrmejiaa/ESP8266 char *arg[CountOfParameter]; <-- this part makes error

wwgww
Associate II

0693W00000FDF8GQAX.png

#include "ESP8266.h"
#include "ESP8266Config.h"
 
//#########################################################################################################
bool Wifi_SendRaw(uint8_t *data,uint16_t len)
{
	if(len <= _WIFI_TX_SIZE)
	{
		// Send the information in data through the UART of the ESP8266
		memcpy(Wifi.TxBuffer,data,len);
		if(HAL_UART_Transmit(&_WIFI_USART,data,len,900) == HAL_OK)
			return true;
		else
			return false;
	}
	else
		return false;
}
//#########################################################################################################
bool Wifi_SendString(char *data)
{
	return Wifi_SendRaw((uint8_t*)data,strlen(data));
}
//#########################################################################################################
bool Wifi_SendStringAndWait(char *data,uint16_t DelayUs)
{
	if(Wifi_SendRaw((uint8_t*)data,strlen(data))==false)
		return false;
	DWT_Delay_us(DelayUs);
	return true;
}
//#########################################################################################################
bool Wifi_WaitForString(uint32_t TimeOut_ms,uint8_t *result,uint8_t CountOfParameter,...)
{
	/*
	 * It uses the CountOfParameter and the Parameters after that to compare with the
	 * information that it was received in the UART RX. If the parameter is in the
	 * received string the functions return a true value and the position of the
	 * parameter (according to the position in the function)
	 *
	 * Ex:
	 * Wifi_WaitForString(_WIFI_WAIT_TIME_LOW,&result,2,"OK","ERROR")
	 *
	 * If the ESP8266 return a AT+OK after the last command, the function is going to
	 * return a true value and the result number would be 1.
	 */
 
	if(result == NULL)
		return false;
	if(CountOfParameter == 0)
		return false;
 
	*result=0;
 
	va_list tag;
		va_start (tag,CountOfParameter);
		char *arg[CountOfParameter];
		for(uint8_t i=0; i<CountOfParameter ; i++)
			arg[i] = va_arg (tag, char *);
	va_end (tag);
 
	for(uint32_t t=0 ; t<TimeOut_ms ; t+=20)
	{
		DWT_Delay_us(20000);
		for(uint8_t	mx=0 ; mx<CountOfParameter ; mx++)
		{
			if(strstr((char*)Wifi.RxBuffer,arg[mx])!=NULL)
			{
				*result = mx+1;
				return true;
			}
		}
	}
	// timeout
	return false;
 
}
//#########################################################################################################
bool Wifi_ReturnString(char *result,uint8_t WantWhichOne,char *SplitterChars)
{
	if(result == NULL)
		return false;
	if(WantWhichOne==0)
		return false;
 
	char *str = (char*)Wifi.RxBuffer;
 
 
	str = strtok (str,SplitterChars);
	if(str == NULL)
	{
		strcpy(result,"");
		return false;
	}
	while (str != NULL)
  {
    str = strtok (NULL,SplitterChars);
		if(str != NULL)
			WantWhichOne--;
		if(WantWhichOne==0)
		{
			strcpy(result,str);
			return true;
		}
  }
	strcpy(result,"");
	return false;
}
//#########################################################################################################
bool Wifi_ReturnStrings(char *InputString,char *SplitterChars,uint8_t CountOfParameter,...)
{
	if(CountOfParameter == 0)
		return false;
	va_list tag;
		va_start (tag,CountOfParameter);
		char *arg[CountOfParameter];
		for(uint8_t i=0; i<CountOfParameter ; i++)
			arg[i] = va_arg (tag, char *);
	va_end (tag);
 
	char *str;
	str = strtok (InputString,SplitterChars);
	if(str == NULL)
		return false;
	uint8_t i=0;
	while (str != NULL)
  {
    str = strtok (NULL,SplitterChars);
		if(str != NULL)
			CountOfParameter--;
		strcpy(arg[i],str);
		i++;
		if(CountOfParameter==0)
		{
			return true;
		}
  }
	return false;
 
}

1 ACCEPTED SOLUTION

Accepted Solutions
Guillaume K
ST Employee

When you report a problem it's always helpful to indicate all the details: what STM32 you are using, what compiler, etc.

From the screen copy "Error[Pe028]" I suppose you are using IAR EWARM development environment.

the line "char *arg[CountOfParameter];" is a declaration of a variable length array. The array size will be known only at run time and will be dynamically allocated by the compiler-provided support library.

In IAR EWARM to enable this feature you have to check "Standard C" / "Allow VLA" in C/C++Compiler configuration in project options.

View solution in original post

1 REPLY 1
Guillaume K
ST Employee

When you report a problem it's always helpful to indicate all the details: what STM32 you are using, what compiler, etc.

From the screen copy "Error[Pe028]" I suppose you are using IAR EWARM development environment.

the line "char *arg[CountOfParameter];" is a declaration of a variable length array. The array size will be known only at run time and will be dynamically allocated by the compiler-provided support library.

In IAR EWARM to enable this feature you have to check "Standard C" / "Allow VLA" in C/C++Compiler configuration in project options.