cancel
Showing results for 
Search instead for 
Did you mean: 

LWIP Web server on RAW, SSI tags do not work in STM32CubeIde 1.10.1

DK.7
Senior

Hi, stm32 LWIP Web server on RAW, SSI tags do not work in STM32CubeIde 1.10.1

if you will run this project in STM32CubeIde 1.8 and 1.9 everything works well!

PS - I checked LWIP, everything is the same, including the version!

0693W00000WICPqQAP.png

15 REPLIES 15
LCE
Principal

What Piranha means:

Check your SSI tags in your source code, compare to those in html file.

/* SSI handler for LED and ADC status reading */
u16_t Global_SSI_Handler(int iIndex, char *pcInsert, int iInsertLen);
 
#define SSI_NUMBER_OF_TAGS		21
 
/* SSI tags, must correspond to those used in html file */
char const *szSSI_tags[SSI_NUMBER_OF_TAGS] =
{
	"tFv", "tTn", "tPtp",
	"tL1", "tL2", "tL3", "tLb",
	"tAVM", "tAVY", "tAVP", "tAVS", "tAVA", "tAVI", "tARf",
	"tTmp", "tTsn",
	"tPer",
	"tSfrq", "tSamp", "tSoff",
	"tSact"
};
 
 

 You must use these tags in the html file, example:

<br>
<h3>SPDIF TX settings</h3>
<br>
<b>Sine settings:</b><br><br>
<form action="/spdif.cgi" method="get">
<!--#tSfrq-->
<label for="lname">&nbsp;frequency</label>
<br>
<br>
<!--#tSamp-->
<label for="lname">&nbsp;attenuation</label>
<br>
<br>
<!--#tSoff-->
<label for="lname">&nbsp;offset</label>
<br>

... and in the handler: 

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/**
  * @brief  Global_SSI_Handler : SSI handler for all pages
  */
u16_t Global_SSI_Handler(int iIndex, char *pcInsert, int iInsertLen)
{
	uint16_t u16AdcVal = 0;
	float flVal = 0.0f;
	char szAdcVal[32] = { 0 };
 
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* system info */
 
/* SSI index = 0 -> firmware version */
	if( 0 == iIndex )
	{
		char szMACAdr[32] = { 0 };
		char szFw4SSI[256] = { 0 };
 
		/* prepare data to be inserted in html */
		sprintf(szMACAdr, "<b>MAC:</b> %02X:%02X:%02X:%02X:%02X:%02X", gNetIf.hwaddr[0], gNetIf.hwaddr[1], gNetIf.hwaddr[2], gNetIf.hwaddr[3], gNetIf.hwaddr[4], gNetIf.hwaddr[5]);
#if( 0 == NUCLEO_F767 )
		sprintf(szFw4SSI, "STM32F767 ETH_Test_Rev_A<br>build date: %s, %s<br>%s<br><b>DNS:</b> %s.?", szFW_date, szFW_time, szMACAdr, gNetIf.hostname);
#else
		sprintf(szFw4SSI, "STM32F767 Nucleo<br>build date: %s, %s<br>%s<br><b>DNS:</b> %s.?", szFW_date, szFW_time, szMACAdr, gNetIf.hostname);
#endif
 
		strcpy(pcInsert, szFw4SSI);
		return strlen(szFw4SSI);
	}
 
/* SSI index = 1 -> time now */
	else if( 1 == iIndex )
	{
		RTC_TimeTypeDef sTimeOut = { 0 };
		RTC_DateTypeDef sDateOut = { 0 };
		uint32_t TickNow = 0;
		char szTime4SSI[128] = { 0 };
 
		/* get time and date */
		if( HAL_RTC_GetTime(&hrtc, &sTimeOut, FORMAT_BIN) != HAL_OK ) uart_printf("Error HAL_RTC_GetTime()\n\r");
		if( HAL_RTC_GetDate(&hrtc, &sDateOut, FORMAT_BIN) != HAL_OK ) uart_printf("Error HAL_RTC_GetDate()\n\r");
		TickNow = HAL_GetTick();
		/* prepare data to be inserted in html */
		sprintf(szTime4SSI, "RTC Time: %02d:%02d:%02d, 20%02d-%02d-%02d<br>RTC seconds since start: %u (%u min)<br>Systick: %ld",
					sTimeOut.Hours, sTimeOut.Minutes, sTimeOut.Seconds, sDateOut.Year, sDateOut.Month, sDateOut.Date, u16RTC_seconds, (uint16_t)(u16RTC_seconds/60), TickNow);
 
		strcpy(pcInsert, szTime4SSI);
		return strlen(szTime4SSI);
	}
 
/* SSI index = 2 -> PTP stuff */
	else if( 2 == iIndex )
	{
		char szPtp[384] = { 0 };
		char szPtpOffset[128] = { 0 };
		char szPtpTime[64] = { 0 };
		sPtpTime_t sTimestamp;
 
		/* read current timestamp registers */
		ETH_PTPTime_GetTime(&sTimestamp);
		Unix2szTime((time_t)sTimestamp.seconds, szPtpTime, sizeof(szPtpTime));
 
		/* offset from master info */
		if( PTP_MASTER == PTPClockGlobal.portDS.portState )
		{
			sprintf(szPtpOffset, "state: %s", szPtpStates[PTPClockGlobal.portDS.portState]);
		}
		else
		{
			if( u8PtpOffsSyncCnt < PTP_SYNC_COUNT_MIN )
			{
				sprintf(szPtpOffset, "state: %s<br>offset from master: %+ld ns<br><b>not synced</b>",
						szPtpStates[PTPClockGlobal.portDS.portState], PTPClockGlobal.currentDS.offsetFromMaster.nanosec);
			}
			else
			{
				sprintf(szPtpOffset, "state: %s<br>offset from master: %+ld ns<br>max since <b>synced</b>: <b>%+ld ns / %+ld ns</b>",
						szPtpStates[PTPClockGlobal.portDS.portState], PTPClockGlobal.currentDS.offsetFromMaster.nanosec,
						s32PtpOffsMaxSyncedPos, s32PtpOffsMaxSyncedNeg);
			}
		}
		/* prepare data to be inserted in html */
		sprintf(szPtp, "PTP time: %lu s + %ld ns<br> = %s<br>%s",
					sTimestamp.seconds, sTimestamp.nanosec, szPtpTime, szPtpOffset);
 
		strcpy(pcInsert, szPtp);
		return strlen(szPtp);
	}
 
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* LED */
 
/* SSI index = 3..5 -> LED 1..3 on/off */
	else if( iIndex >= 3 && iIndex <= 5 )
	{
		if( LED_STATE_ON == LedState[iIndex - 3] )
		{
			/* LED is ON -> make its checkbox checked! */
			char szLednOn[] = "<input value=\"n\" name=\"led\" type=\"checkbox\" checked>";
			szLednOn[14] = '1' + (char)iIndex - 3;
			strcpy(pcInsert, szLednOn);
			return strlen(szLednOn);
		}
		else
		{
			char szLednOff[] = "<input value=\"n\" name=\"led\" type=\"checkbox\">";
			szLednOff[14] = '1' + (char)iIndex - 3;
			strcpy(pcInsert, szLednOff);
			return strlen(szLednOff);
		}
	}
 
...

not using HAL:

RTFM, try to understand, and directly read and write registers.

You will find that HAL stuff is usually made to "fit all sizes", which means that it's doing lots of things you don't need.

And every now and then there are some things you cannot do with HAL, or some minor errors.

Anyway, your lwIP / SSI problem has nothing to with HAL.

Thanks for sharing your code! I did not find significant differences. 

PS - I bought the same board. Because my stm32f407vg don't have enough RAM for my project on FreeRTOS.

RTFM - That's the problem! I am a beginner and do not have a complete understanding of how LWIP works!

It's a long way to the top...

lwIP is kinda monster if you have to get into it, but usually you don't need to, because there are enough functions to the "outside world".

In your case it lwIP's SSI handler.

Go step by step, if you're working on SSI, then start reading how that works, and try to understand what's going on in the examples.