• AVR Freaks

AnsweredHot!Problem on Processing Forms (web_net_server_nvm_mpfs)

Author
yts
Super Member
  • Total Posts : 632
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
2020/07/05 19:56:50 (permalink)
0

Problem on Processing Forms (web_net_server_nvm_mpfs)

PIC32MZ2048EFM064-I/PT + LAN8740Ai
net v3.6.1
Firefox

The following codes are in the file "custom_http_net_app.c"

TCPIP_HTTP_DYN_PRINT_RES TCPIP_HTTP_Print_ledSelected(TCPIP_HTTP_NET_CONN_HANDLE connHandle, const TCPIP_HTTP_DYN_VAR_DCPT *vDcpt)
{
    // Determine which LED to check
    if(vDcpt->nArgs >= 2 && vDcpt->dynArgs->argType == TCPIP_HTTP_DYN_ARG_TYPE_INT32 && (vDcpt->dynArgs + 1)->argType == TCPIP_HTTP_DYN_ARG_TYPE_INT32)
    {
        int nLed = vDcpt->dynArgs->argInt32;
        int state = (vDcpt->dynArgs + 1)->argInt32;

        switch(nLed)


Here the condition of if-statement is never met and "switch(nLed)" statement" is never called.

As a result, two combo boxes on Processing Forms show always ON (negative logic?) as shown in fig.png.

When I remove  this if-statement completely, the firmware works well.

yts
post edited by yts - 2020/07/05 20:47:59

Attached Image(s)

#1
rainad
Moderator
  • Total Posts : 1387
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: offline
Re: Problem on Processing Forms (web_net_server_nvm_mpfs) 2020/07/06 06:35:14 (permalink)
0
Thanks for bringing this up.
I'll look into it and find what exactly makes this test to fail.
At first glance the test seems correct.
I'll update when I have some news.
 
 
#2
XorLor
Junior Member
  • Total Posts : 71
  • Reward points : 0
  • Joined: 2009/10/23 00:17:05
  • Location: 0
  • Status: offline
Re: Problem on Processing Forms (web_net_server_nvm_mpfs) 2020/07/06 08:11:18 (permalink) ☼ Best Answerby yts 2020/07/06 16:41:57
1 (1)
The problem is the 2nd argType is a string but the if statement is checking for int32_t.
 
Here is how I fixed it:
 

TCPIP_HTTP_DYN_PRINT_RES TCPIP_HTTP_Print_ledSelected(TCPIP_HTTP_NET_CONN_HANDLE connHandle, const TCPIP_HTTP_DYN_VAR_DCPT *vDcpt)
{
// Determine which LED to check
if(vDcpt->nArgs >= 2 && vDcpt->dynArgs->argType == TCPIP_HTTP_DYN_ARG_TYPE_INT32 && (vDcpt->dynArgs + 1)->argType == TCPIP_HTTP_DYN_ARG_TYPE_STRING)
{
int nLed = vDcpt->dynArgs->argInt32;
int state = 0;
if(strcmp((vDcpt->dynArgs + 1)->argStr, "true") == 0)
state = 1;

switch(nLed)
{
case 0:
nLed = APP_LED_1StateGet();
break;
case 1:
nLed = APP_LED_2StateGet();
break;
case 2:
nLed = APP_LED_3StateGet();
break;
default:
nLed = 0;
}
// Print output if true and ON or if false and OFF
if((state && nLed) || (!state && !nLed))
TCPIP_HTTP_NET_DynamicWriteString(vDcpt, "SELECTED", false);
}
return TCPIP_HTTP_DYN_PRINT_RES_DONE;
}

post edited by XorLor - 2020/07/06 09:05:56
#3
rainad
Moderator
  • Total Posts : 1387
  • Reward points : 0
  • Joined: 2009/05/01 13:39:25
  • Location: 0
  • Status: offline
Re: Problem on Processing Forms (web_net_server_nvm_mpfs) 2020/07/06 11:00:24 (permalink)
0
Yes XorLor is correct, the forms.htm contains:
 ~ledSelected(2,true)~
 ~ledSelected(2,false)~
so the 2nd parameter is a string.
Either replace the forms.htm with
 ~ledSelected(2,1)~
or use the suggested change above.
We'll update the code or the page to match.
 
#4
yts
Super Member
  • Total Posts : 632
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re: Problem on Processing Forms (web_net_server_nvm_mpfs) 2020/07/06 16:41:39 (permalink)
0
Hi. XorLor,
Thank you for your suggestion. Your codes work perfectly. Positive logic is realized.

Hi. rainad,
Thank you for your detailed explanation. I can understand what was wrong.

yts
#5
Jump to:
© 2020 APG vNext Commercial Version 4.5